summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaleb Keithley <kaleb@freedesktop.org>2003-11-14 15:54:39 +0000
committerKaleb Keithley <kaleb@freedesktop.org>2003-11-14 15:54:39 +0000
commite3925d3087dc381a24b47c5602e086645e942fcf (patch)
tree23db50792445254b4d4f58acace3f261c176fcc4
downloadxorg-lib-libXmu-e3925d3087dc381a24b47c5602e086645e942fcf.tar.gz
R6.6 is the Xorg base-lineXORG-MAIN
-rw-r--r--README8
-rw-r--r--include/X11/Xmu/Atoms.h128
-rw-r--r--include/X11/Xmu/CharSet.h64
-rw-r--r--include/X11/Xmu/CloseHook.h79
-rw-r--r--include/X11/Xmu/Converters.h266
-rw-r--r--include/X11/Xmu/CurUtil.h49
-rw-r--r--include/X11/Xmu/CvtCache.h59
-rw-r--r--include/X11/Xmu/DisplayQue.h167
-rw-r--r--include/X11/Xmu/Drawing.h172
-rw-r--r--include/X11/Xmu/Editres.h35
-rw-r--r--include/X11/Xmu/EditresP.h342
-rw-r--r--include/X11/Xmu/Error.h60
-rw-r--r--include/X11/Xmu/ExtAgent.h45
-rw-r--r--include/X11/Xmu/Initer.h64
-rw-r--r--include/X11/Xmu/Misc.h65
-rw-r--r--include/X11/Xmu/StdCmap.h112
-rw-r--r--include/X11/Xmu/StdSel.h59
-rw-r--r--include/X11/Xmu/SysUtil.h45
-rw-r--r--include/X11/Xmu/WhitePoint.h65
-rw-r--r--include/X11/Xmu/WidgetNode.h101
-rw-r--r--include/X11/Xmu/WinUtil.h66
-rw-r--r--include/X11/Xmu/Xct.h171
-rw-r--r--include/X11/Xmu/Xmu.h52
-rw-r--r--src/AllCmap.c155
-rw-r--r--src/Atoms.c157
-rw-r--r--src/ClientWin.c89
-rw-r--r--src/CloseHook.c300
-rw-r--r--src/CmapAlloc.c334
-rw-r--r--src/CrCmap.c523
-rw-r--r--src/CrPixFBit.c75
-rw-r--r--src/CursorName.c146
-rw-r--r--src/CvtCache.c128
-rw-r--r--src/CvtStdSel.c329
-rw-r--r--src/DefErrMsg.c169
-rw-r--r--src/DelCmap.c66
-rw-r--r--src/DisplayQue.c193
-rw-r--r--src/Distinct.c90
-rw-r--r--src/DrRndRect.c180
-rw-r--r--src/DrawLogo.c154
-rw-r--r--src/EditresCom.c1886
-rw-r--r--src/ExtAgent.c44
-rw-r--r--src/FToCback.c46
-rw-r--r--src/GetHost.c77
-rw-r--r--src/GrayPixmap.c137
-rw-r--r--src/Initer.c106
-rw-r--r--src/LocBitmap.c294
-rw-r--r--src/Lookup.c317
-rw-r--r--src/LookupCmap.c310
-rw-r--r--src/Lower.c121
-rw-r--r--src/RdBitF.c401
-rw-r--r--src/ScrOfWin.c57
-rw-r--r--src/ShapeWidg.c189
-rw-r--r--src/StdCmap.c218
-rw-r--r--src/StrToBS.c82
-rw-r--r--src/StrToBmap.c148
-rw-r--r--src/StrToCurs.c334
-rw-r--r--src/StrToGrav.c101
-rw-r--r--src/StrToJust.c75
-rw-r--r--src/StrToLong.c53
-rw-r--r--src/StrToOrnt.c75
-rw-r--r--src/StrToShap.c88
-rw-r--r--src/StrToWidg.c183
-rw-r--r--src/UpdMapHint.c59
-rw-r--r--src/VisCmap.c175
-rw-r--r--src/WidgetNode.c305
-rw-r--r--src/Xct.c695
-rw-r--r--src/sharedlib.c71
67 files changed, 12009 insertions, 0 deletions
diff --git a/README b/README
new file mode 100644
index 0000000..d618e2a
--- /dev/null
+++ b/README
@@ -0,0 +1,8 @@
+This library contains miscellaneous utilities and is not part of the Xlib
+standard. It contains routines which only use public interfaces so that it
+may be layered on top of any proprietary implementation of Xlib or Xt.
+
+It is intended to support clients in the MIT distribution; vendors
+may choose not to distribute this library if they wish. Therefore,
+applications developers who depend on this library should be prepared to
+treat it as part of their software base when porting.
diff --git a/include/X11/Xmu/Atoms.h b/include/X11/Xmu/Atoms.h
new file mode 100644
index 0000000..53c16b3
--- /dev/null
+++ b/include/X11/Xmu/Atoms.h
@@ -0,0 +1,128 @@
+/* $Xorg: Atoms.h,v 1.4 2001/02/09 02:03:51 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.
+
+*/
+
+/*
+ * The interfaces described by this header file are for miscellaneous utilities
+ * and are not part of the Xlib standard.
+ */
+
+#ifndef _XMU_ATOMS_H_
+#define _XMU_ATOMS_H_
+
+#include <X11/Intrinsic.h>
+#include <X11/Xfuncproto.h>
+
+typedef struct _AtomRec *AtomPtr;
+
+extern AtomPtr
+ _XA_ATOM_PAIR,
+ _XA_CHARACTER_POSITION,
+ _XA_CLASS,
+ _XA_CLIENT_WINDOW,
+ _XA_CLIPBOARD,
+ _XA_COMPOUND_TEXT,
+ _XA_DECNET_ADDRESS,
+ _XA_DELETE,
+ _XA_FILENAME,
+ _XA_HOSTNAME,
+ _XA_IP_ADDRESS,
+ _XA_LENGTH,
+ _XA_LIST_LENGTH,
+ _XA_NAME,
+ _XA_NET_ADDRESS,
+ _XA_NULL,
+ _XA_OWNER_OS,
+ _XA_SPAN,
+ _XA_TARGETS,
+ _XA_TEXT,
+ _XA_TIMESTAMP,
+ _XA_USER;
+
+#define XA_ATOM_PAIR(d) XmuInternAtom(d, _XA_ATOM_PAIR)
+#define XA_CHARACTER_POSITION(d) XmuInternAtom(d, _XA_CHARACTER_POSITION)
+#define XA_CLASS(d) XmuInternAtom(d, _XA_CLASS)
+#define XA_CLIENT_WINDOW(d) XmuInternAtom(d, _XA_CLIENT_WINDOW)
+#define XA_CLIPBOARD(d) XmuInternAtom(d, _XA_CLIPBOARD)
+#define XA_COMPOUND_TEXT(d) XmuInternAtom(d, _XA_COMPOUND_TEXT)
+#define XA_DECNET_ADDRESS(d) XmuInternAtom(d, _XA_DECNET_ADDRESS)
+#define XA_DELETE(d) XmuInternAtom(d, _XA_DELETE)
+#define XA_FILENAME(d) XmuInternAtom(d, _XA_FILENAME)
+#define XA_HOSTNAME(d) XmuInternAtom(d, _XA_HOSTNAME)
+#define XA_IP_ADDRESS(d) XmuInternAtom(d, _XA_IP_ADDRESS)
+#define XA_LENGTH(d) XmuInternAtom(d, _XA_LENGTH)
+#define XA_LIST_LENGTH(d) XmuInternAtom(d, _XA_LIST_LENGTH)
+#define XA_NAME(d) XmuInternAtom(d, _XA_NAME)
+#define XA_NET_ADDRESS(d) XmuInternAtom(d, _XA_NET_ADDRESS)
+#define XA_NULL(d) XmuInternAtom(d, _XA_NULL)
+#define XA_OWNER_OS(d) XmuInternAtom(d, _XA_OWNER_OS)
+#define XA_SPAN(d) XmuInternAtom(d, _XA_SPAN)
+#define XA_TARGETS(d) XmuInternAtom(d, _XA_TARGETS)
+#define XA_TEXT(d) XmuInternAtom(d, _XA_TEXT)
+#define XA_TIMESTAMP(d) XmuInternAtom(d, _XA_TIMESTAMP)
+#define XA_USER(d) XmuInternAtom(d, _XA_USER)
+
+_XFUNCPROTOBEGIN
+
+extern char *XmuGetAtomName(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ Atom /* atom */
+#endif
+);
+
+extern Atom XmuInternAtom(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ AtomPtr /* atom_ptr */
+#endif
+);
+
+extern void XmuInternStrings(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ String * /* names */,
+ Cardinal /* count */,
+ Atom * /* atoms_return */
+#endif
+);
+
+extern AtomPtr XmuMakeAtom(
+#if NeedFunctionPrototypes
+ _Xconst char * /* name */
+#endif
+);
+
+extern char *XmuNameOfAtom(
+#if NeedFunctionPrototypes
+ AtomPtr /* atom_ptr */
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XMU_ATOMS_H_ */
diff --git a/include/X11/Xmu/CharSet.h b/include/X11/Xmu/CharSet.h
new file mode 100644
index 0000000..e017458
--- /dev/null
+++ b/include/X11/Xmu/CharSet.h
@@ -0,0 +1,64 @@
+/* $Xorg: CharSet.h,v 1.4 2001/02/09 02:03:51 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.
+
+*/
+
+/*
+ * The interfaces described by this header file are for miscellaneous utilities
+ * and are not part of the Xlib standard.
+ */
+
+#ifndef _XMU_CHARSET_H_
+#define _XMU_CHARSET_H_
+
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+extern void XmuCopyISOLatin1Lowered(
+#if NeedFunctionPrototypes
+ char * /* dst_return */,
+ _Xconst char * /* src */
+#endif
+);
+
+extern void XmuCopyISOLatin1Uppered(
+#if NeedFunctionPrototypes
+ char * /* dst_return */,
+ _Xconst char * /* src */
+#endif
+);
+
+extern int XmuCompareISOLatin1(
+#if NeedFunctionPrototypes
+ _Xconst char * /* first */,
+ _Xconst char * /* second */
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XMU_CHARSET_H_ */
diff --git a/include/X11/Xmu/CloseHook.h b/include/X11/Xmu/CloseHook.h
new file mode 100644
index 0000000..b69290a
--- /dev/null
+++ b/include/X11/Xmu/CloseHook.h
@@ -0,0 +1,79 @@
+/* $Xorg: CloseHook.h,v 1.5 2001/02/09 02:03:51 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.
+
+*/
+
+/*
+ * The interfaces described by this header file are for miscellaneous utilities
+ * and are not part of the Xlib standard.
+ */
+
+#ifndef _XMU_CLOSEHOOK_H_
+#define _XMU_CLOSEHOOK_H_
+
+#include <X11/Xlib.h>
+#include <X11/Xfuncproto.h>
+
+typedef XPointer CloseHook;
+
+typedef int (*XmuCloseHookProc)(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ XPointer /* data */
+#endif
+);
+
+_XFUNCPROTOBEGIN
+
+extern CloseHook XmuAddCloseDisplayHook(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ XmuCloseHookProc /* proc */,
+ XPointer /* arg */
+#endif
+);
+
+extern Bool XmuLookupCloseDisplayHook(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ CloseHook /* handle */,
+ XmuCloseHookProc /* proc */,
+ XPointer /* arg */
+#endif
+);
+
+extern Bool XmuRemoveCloseDisplayHook(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ CloseHook /* handle */,
+ XmuCloseHookProc /* proc */,
+ XPointer /* arg */
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XMU_CLOSEHOOK_H_ */
diff --git a/include/X11/Xmu/Converters.h b/include/X11/Xmu/Converters.h
new file mode 100644
index 0000000..3b3a448
--- /dev/null
+++ b/include/X11/Xmu/Converters.h
@@ -0,0 +1,266 @@
+/* $Xorg: Converters.h,v 1.5 2001/02/09 02:03:51 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.
+
+*/
+
+/*
+ * The interfaces described by this header file are for miscellaneous utilities
+ * and are not part of the Xlib standard.
+ */
+
+#ifndef _XMU_STRCONVERT_H_
+#define _XMU_STRCONVERT_H_
+
+#include <X11/Intrinsic.h>
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+/*
+ * Converters - insert in alphabetical order
+ */
+
+/******************************************************************************
+ * XmuCvtFunctionToCallback
+ */
+extern void XmuCvtFunctionToCallback(
+#if NeedFunctionPrototypes
+ XrmValue* /* args */,
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */
+#endif
+);
+
+
+/******************************************************************************
+ * XmuCvtStringToBackingStore
+ */
+#define XtNbackingStore "backingStore"
+#define XtCBackingStore "BackingStore"
+#define XtRBackingStore "BackingStore"
+#define XtEnotUseful "notUseful"
+#define XtEwhenMapped "whenMapped"
+#define XtEalways "always"
+#define XtEdefault "default"
+extern void XmuCvtStringToBackingStore(
+#if NeedFunctionPrototypes
+ XrmValue* /* args */,
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */
+#endif
+);
+
+
+/******************************************************************************
+ * XmuCvtStringToCursor
+ */
+extern void XmuCvtStringToCursor(
+#if NeedFunctionPrototypes
+ XrmValue* /* args */,
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */
+#endif
+);
+extern Boolean XmuCvtStringToColorCursor(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ XrmValue* /* args */,
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */,
+ XtPointer* /* converter_data */
+#endif
+);
+
+#define XtRColorCursor "ColorCursor"
+#define XtNpointerColor "pointerColor"
+#define XtNpointerColorBackground "pointerColorBackground"
+
+
+/******************************************************************************
+ * XmuCvtStringToGravity
+ */
+typedef int XtGravity;
+
+#ifndef XtRGravity
+#define XtRGravity "Gravity"
+#endif
+#define XtEForget "forget"
+#define XtENorthWest "northwest"
+#define XtENorth "north"
+#define XtENorthEast "northeast"
+#define XtEWest "west"
+#define XtECenter "center"
+#define XtEEast "east"
+#define XtESouthWest "southwest"
+#define XtESouth "south"
+#define XtESouthEast "southeast"
+#define XtEStatic "static"
+#define XtEUnmap "unmap"
+
+extern void XmuCvtStringToGravity (
+#if NeedFunctionPrototypes
+ XrmValue* /* args */,
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */
+#endif
+);
+
+
+/******************************************************************************
+ * XmuCvtStringToJustify
+ */
+typedef enum {
+ XtJustifyLeft, /* justify text to left side of button */
+ XtJustifyCenter, /* justify text in center of button */
+ XtJustifyRight /* justify text to right side of button */
+} XtJustify;
+#define XtEleft "left"
+#define XtEcenter "center"
+#define XtEright "right"
+#define XtEtop "top"
+#define XtEbottom "bottom"
+
+extern void XmuCvtStringToJustify(
+#if NeedFunctionPrototypes
+ XrmValue* /* args */,
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */
+#endif
+);
+
+
+/******************************************************************************
+ * XmuCvtStringToLong
+ */
+#define XtRLong "Long"
+extern void XmuCvtStringToLong(
+#if NeedFunctionPrototypes
+ XrmValue* /* args */,
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */
+#endif
+);
+
+
+/******************************************************************************
+ * XmuCvtStringToOrientation
+ */
+typedef enum {XtorientHorizontal, XtorientVertical} XtOrientation;
+extern void XmuCvtStringToOrientation(
+#if NeedFunctionPrototypes
+ XrmValue* /* args */,
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */
+#endif
+);
+
+
+/******************************************************************************
+ * XmuCvtStringToBitmap
+ */
+extern void XmuCvtStringToBitmap(
+#if NeedFunctionPrototypes
+ XrmValue* /* args */,
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */
+#endif
+);
+
+
+/******************************************************************************
+ * XmuCvtStringToShapeStyle; is XtTypeConverter (i.e. new style)
+ * no conversion arguments, not particularly useful to cache the results.
+ */
+
+#define XtRShapeStyle "ShapeStyle"
+#define XtERectangle "Rectangle"
+#define XtEOval "Oval"
+#define XtEEllipse "Ellipse"
+#define XtERoundedRectangle "RoundedRectangle"
+
+#define XmuShapeRectangle 1
+#define XmuShapeOval 2
+#define XmuShapeEllipse 3
+#define XmuShapeRoundedRectangle 4
+
+extern Boolean XmuCvtStringToShapeStyle(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ XrmValue* /* args */,
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */,
+ XtPointer* /* converter_data */
+#endif
+);
+
+extern Boolean XmuReshapeWidget(
+#if NeedFunctionPrototypes
+ Widget /* w */,
+ int /* shape_style */,
+ int /* corner_width */,
+ int /* corner_height */
+#endif
+);
+
+/******************************************************************************
+ * XmuCvtStringToWidget
+ */
+extern void XmuCvtStringToWidget(
+#if NeedFunctionPrototypes
+ XrmValue* /* args */,
+ Cardinal* /* num_args */,
+ XrmValuePtr /* fromVal */,
+ XrmValuePtr /* toVal */
+#endif
+);
+
+/******************************************************************************
+ * XmuNewCvtStringToWidget
+ */
+extern Boolean XmuNewCvtStringToWidget(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XrmValue* /* args */,
+ Cardinal* /* num_args */,
+ XrmValue* /* fromVal */,
+ XrmValue* /* toVal */,
+ XtPointer* /* converter_data */
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XMU_STRCONVERT_H_ */
diff --git a/include/X11/Xmu/CurUtil.h b/include/X11/Xmu/CurUtil.h
new file mode 100644
index 0000000..5ac79fc
--- /dev/null
+++ b/include/X11/Xmu/CurUtil.h
@@ -0,0 +1,49 @@
+/* $Xorg: CurUtil.h,v 1.4 2001/02/09 02:03:51 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.
+
+*/
+
+/*
+ * The interfaces described by this header file are for miscellaneous utilities
+ * and are not part of the Xlib standard.
+ */
+
+#ifndef _XMU_CURUTIL_H_
+#define _XMU_CURUTIL_H_
+
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+extern int XmuCursorNameToIndex(
+#if NeedFunctionPrototypes
+ _Xconst char* /* name */
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XMU_CURUTIL_H_ */
diff --git a/include/X11/Xmu/CvtCache.h b/include/X11/Xmu/CvtCache.h
new file mode 100644
index 0000000..db020e7
--- /dev/null
+++ b/include/X11/Xmu/CvtCache.h
@@ -0,0 +1,59 @@
+/* $Xorg: CvtCache.h,v 1.4 2001/02/09 02:03:52 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.
+
+*/
+
+/*
+ * Public Interfaces
+ *
+ * XmuCvtCache *XmuCvtCacheLookupDisplay (dpy)
+ * Display *dpy;
+ */
+
+#ifndef _XMU_CVTCACHE_H_
+#define _XMU_CVTCACHE_H_
+
+#include <X11/Xmu/DisplayQue.h>
+#include <X11/Xfuncproto.h>
+
+typedef struct _XmuCvtCache {
+ struct {
+ char **bitmapFilePath;
+ } string_to_bitmap;
+ /* add other per-display data that needs to be cached */
+} XmuCvtCache;
+
+_XFUNCPROTOBEGIN
+
+extern XmuCvtCache *_XmuCCLookupDisplay(
+#if NeedFunctionPrototypes
+ Display* /* dpy */
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XMU_CVTCACHE_H_ */
diff --git a/include/X11/Xmu/DisplayQue.h b/include/X11/Xmu/DisplayQue.h
new file mode 100644
index 0000000..57bb7a5
--- /dev/null
+++ b/include/X11/Xmu/DisplayQue.h
@@ -0,0 +1,167 @@
+/* $Xorg: DisplayQue.h,v 1.4 2001/02/09 02:03:52 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.
+
+*/
+
+#ifndef _XMU_DISPLAYQUE_H_
+#define _XMU_DISPLAYQUE_H_
+
+#include <X11/Xmu/CloseHook.h>
+#include <X11/Xfuncproto.h>
+
+/*
+ * Public Entry Points
+ *
+ *
+ * XmuDisplayQueue *XmuDQCreate (closefunc, freefunc, data)
+ * XmuCloseDisplayQueueProc closefunc;
+ * XmuFreeDisplayQueueProc freefunc;
+ * XPointer data;
+ *
+ * Creates and returns a queue into which displays may be placed. When
+ * the display is closed, the closefunc (if non-NULL) is upcalled with
+ * as follows:
+ *
+ * (*closefunc) (queue, entry)
+ *
+ * The freeproc, if non-NULL, is called whenever the last display is
+ * closed, notifying the creator that display queue may be released
+ * using XmuDQDestroy.
+ *
+ *
+ * Bool XmuDQDestroy (q, docallbacks)
+ * XmuDisplayQueue *q;
+ * Bool docallbacks;
+ *
+ * Releases all memory for the indicated display queue. If docallbacks
+ * is true, then the closefunc (if non-NULL) is called for each
+ * display.
+ *
+ *
+ * XmuDisplayQueueEntry *XmuDQLookupDisplay (q, dpy)
+ * XmuDisplayQueue *q;
+ * Display *dpy;
+ *
+ * Returns the queue entry for the specified display or NULL if the
+ * display is not in the queue.
+ *
+ *
+ * XmuDisplayQueueEntry *XmuDQAddDisplay (q, dpy, data)
+ * XmuDisplayQueue *q;
+ * Display *dpy;
+ * XPointer data;
+ *
+ * Adds the indicated display to the end of the queue or NULL if it
+ * is unable to allocate memory. The data field may be used by the
+ * caller to attach arbitrary data to this display in this queue. The
+ * caller should use XmuDQLookupDisplay to make sure that the display
+ * hasn't already been added.
+ *
+ *
+ * Bool XmuDQRemoveDisplay (q, dpy)
+ * XmuDisplayQueue *q;
+ * Display *dpy;
+ *
+ * Removes the specified display from the given queue. If the
+ * indicated display is not found on this queue, False is returned,
+ * otherwise True is returned.
+ */
+
+typedef struct _XmuDisplayQueue XmuDisplayQueue;
+typedef struct _XmuDisplayQueueEntry XmuDisplayQueueEntry;
+
+typedef int (*XmuCloseDisplayQueueProc)(
+#if NeedFunctionPrototypes
+ XmuDisplayQueue* /* queue */,
+ XmuDisplayQueueEntry* /* entry */
+#endif
+);
+
+typedef int (*XmuFreeDisplayQueueProc)(
+#if NeedFunctionPrototypes
+ XmuDisplayQueue* /* queue */
+#endif
+);
+
+struct _XmuDisplayQueueEntry {
+ struct _XmuDisplayQueueEntry *prev, *next;
+ Display *display;
+ CloseHook closehook;
+ XPointer data;
+};
+
+struct _XmuDisplayQueue {
+ int nentries;
+ XmuDisplayQueueEntry *head, *tail;
+ XmuCloseDisplayQueueProc closefunc;
+ XmuFreeDisplayQueueProc freefunc;
+ XPointer data;
+};
+
+_XFUNCPROTOBEGIN
+
+extern XmuDisplayQueue *XmuDQCreate(
+#if NeedFunctionPrototypes
+ XmuCloseDisplayQueueProc /* closefunc */,
+ XmuFreeDisplayQueueProc /* freefunc */,
+ XPointer /* data */
+#endif
+);
+
+extern Bool XmuDQDestroy(
+#if NeedFunctionPrototypes
+ XmuDisplayQueue* /* q */,
+ Bool /* docallbacks */
+#endif
+);
+
+extern XmuDisplayQueueEntry *XmuDQLookupDisplay(
+#if NeedFunctionPrototypes
+ XmuDisplayQueue* /* q */,
+ Display* /* dpy */
+#endif
+);
+
+extern XmuDisplayQueueEntry *XmuDQAddDisplay(
+#if NeedFunctionPrototypes
+ XmuDisplayQueue* /* q */,
+ Display* /* dpy */,
+ XPointer /* data */
+#endif
+);
+
+extern Bool XmuDQRemoveDisplay(
+#if NeedFunctionPrototypes
+ XmuDisplayQueue* /* q */,
+ Display* /* dpy */
+#endif
+);
+
+_XFUNCPROTOEND
+
+#define XmuDQNDisplays(q) ((q)->nentries)
+
+#endif /* _XMU_DISPLAYQUE_H_ */
diff --git a/include/X11/Xmu/Drawing.h b/include/X11/Xmu/Drawing.h
new file mode 100644
index 0000000..3aee8d7
--- /dev/null
+++ b/include/X11/Xmu/Drawing.h
@@ -0,0 +1,172 @@
+/* $Xorg: Drawing.h,v 1.5 2001/02/09 02:03:52 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.
+
+*/
+
+/*
+ * The interfaces described by this header file are for miscellaneous utilities
+ * and are not part of the Xlib standard.
+ */
+
+#ifndef _XMU_DRAWING_H_
+#define _XMU_DRAWING_H_
+
+#include <X11/Xlib.h>
+#include <X11/Xfuncproto.h>
+
+#if NeedFunctionPrototypes
+#include <stdio.h>
+#if ! defined(_XtIntrinsic_h) && ! defined(PIXEL_ALREADY_TYPEDEFED)
+typedef unsigned long Pixel;
+#endif
+#endif
+
+_XFUNCPROTOBEGIN
+
+extern void XmuDrawRoundedRectangle(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ Drawable /* draw */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ int /* w */,
+ int /* h */,
+ int /* ew */,
+ int /* eh */
+#endif
+);
+
+extern void XmuFillRoundedRectangle(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ Drawable /* draw */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ int /* w */,
+ int /* h */,
+ int /* ew */,
+ int /* eh */
+#endif
+);
+
+extern void XmuDrawLogo(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ Drawable /* drawable */,
+ GC /* gcFore */,
+ GC /* gcBack */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */
+#endif
+);
+
+extern Pixmap XmuCreatePixmapFromBitmap(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ Drawable /* d */,
+ Pixmap /* bitmap */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int /* depth */,
+ unsigned long /* fore */,
+ unsigned long /* back */
+#endif
+);
+
+extern Pixmap XmuCreateStippledPixmap(
+#if NeedFunctionPrototypes
+ Screen* /* screen */,
+ Pixel /* fore */,
+ Pixel /* back */,
+ unsigned int /* depth */
+#endif
+);
+
+extern void XmuReleaseStippledPixmap(
+#if NeedFunctionPrototypes
+ Screen* /* screen */,
+ Pixmap /* pixmap */
+#endif
+);
+
+extern Pixmap XmuLocateBitmapFile(
+#if NeedFunctionPrototypes
+ Screen* /* screen */,
+ _Xconst char* /* name */,
+ char* /* srcname_return */,
+ int /* srcnamelen */,
+ int* /* width_return */,
+ int* /* height_return, */,
+ int* /* xhot_return */,
+ int* /* yhot_return */
+#endif
+);
+
+extern Pixmap XmuLocatePixmapFile(
+#if NeedFunctionPrototypes
+ Screen* /* screen */,
+ _Xconst char* /* name */,
+ unsigned long /* fore */,
+ unsigned long /* back */,
+ unsigned int /* depth */,
+ char* /* srcname_return */,
+ int /* srcnamelen */,
+ int* /* width_return */,
+ int* /* height_return, */,
+ int* /* xhot_return */,
+ int* /* yhot_return */
+#endif
+);
+
+extern int XmuReadBitmapData(
+#if NeedFunctionPrototypes
+ FILE* /* fstream */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */,
+ unsigned char** /* datap_return */,
+ int* /* xhot_return */,
+ int* /* yhot_return */
+#endif
+);
+
+extern int XmuReadBitmapDataFromFile(
+#if NeedFunctionPrototypes
+ _Xconst char* /* filename */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */,
+ unsigned char** /* datap_return */,
+ int* /* xhot_return */,
+ int* /* yhot_return */
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XMU_DRAWING_H_ */
diff --git a/include/X11/Xmu/Editres.h b/include/X11/Xmu/Editres.h
new file mode 100644
index 0000000..94e0b3b
--- /dev/null
+++ b/include/X11/Xmu/Editres.h
@@ -0,0 +1,35 @@
+/* $Xorg: Editres.h,v 1.4 2001/02/09 02:03:52 xorgcvs Exp $ */
+
+/*
+
+Copyright 1991, 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 <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+void _XEditResCheckMessages();
+
+_XFUNCPROTOEND
diff --git a/include/X11/Xmu/EditresP.h b/include/X11/Xmu/EditresP.h
new file mode 100644
index 0000000..44dfd38
--- /dev/null
+++ b/include/X11/Xmu/EditresP.h
@@ -0,0 +1,342 @@
+/* $Xorg: EditresP.h,v 1.4 2001/02/09 02:03:52 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.
+
+*/
+
+/*
+ * Author: Chris D. Peterson, MIT X Consortium
+ */
+
+/************************************************************
+
+ The Editres Protocol
+
+
+ The Client message sent to the application is:
+
+ ATOM = "ResEditor" --- RES_EDITOR_NAME
+
+ FORMAT = 32 --- RES_EDIT_SEND_EVENT_FORMAT
+
+ l[0] = timestamp
+ l[1] = command atom name
+ l[2] = ident of command.
+ l[3] = protocol version number to use.
+
+
+
+ The binary protocol has the following format:
+
+ Card8: 8-bit unsingned integer
+ Card16: 16-bit unsingned integer
+ Card32: 32-bit unsingned integer
+ Int16: 16-bit signed integer
+ Window: 32-bit value
+ Widget: 32-bit value
+ String8: ListOfCard8
+
+ [a][b][c] represent an exclusive list of choices.
+
+ All widgets are passed as a list of widgets, containing the
+ full instance heirarch of this widget. The hierarchy is ordered
+ from parent to child. Thus the first element of each list is
+ the root of the widget tree (this makes verifying that the widget
+ still exists, MUCH faster).
+
+ ListOfFoo comprises a list of things in the following format:
+
+ number: Card16
+ <number> things: ????
+
+ This is a synchronous protocol, every request MUST be followed by a
+ reply.
+
+ Request:
+
+ Serial Number: Card8
+ Op Code: Card8 - { SendWidgetTree = 0,
+ SetValues = 1,
+ GetResources = 2,
+ GetGeometry = 3,
+ FindChild = 4,
+ GetValues = 5 }
+ Length: Card32
+ Data:
+
+ Reply:
+
+ Serial Number: Card8
+ Type: Card8 - { Formatted = 0,
+ Unformatted = 1,
+ ProtocolMismatch = 2
+ }
+ Length: Card32
+
+
+ Byte Order:
+
+ All Fields are MSB -> LSB
+
+ Data:
+
+ Formatted:
+
+ The data contains the reply information for the request as
+ specified below if the reply type is "Formatted". The return
+ values for the other reply types are shown below.
+
+ Unformatted:
+
+ Message: String8
+
+ ProtocolMismatch:
+
+ RequestedVersion: Card8
+
+------------------------------------------------------------
+
+ SendWidgetTree:
+
+ --->
+
+ Number of Entries: Card16
+ Entry:
+ widget: ListOfWidgets
+ name: String8
+ class: String8
+ window: Card32
+ toolkit: String8
+
+ Send Widget Tree returns the toolkit type, and a fuly specified list
+ of widgets for each widget in the tree. This is enough information
+ to completely reconstruct the entire widget heirarchy.
+
+ The window return value contains the Xid of the window currently
+ used by this widget. If the widget is unrealized then 0 is returned,
+ and if widget is a non-windowed object a value of 2 is returned.
+
+ SetValues:
+
+ name: String8
+ type: String8
+ value: String8
+ Number of Entries: Card16
+ Entry:
+ widget: ListOfWidgets
+
+ --->
+
+ Number of Entries: Card16
+ Entry:
+ widget: ListOfWidgets
+ message: String8
+
+ SetValues will allow the same resource to be set on a number of
+ widgets. This function will return an error message if the SetValues
+ request caused an Xt error.
+
+ GetValues:
+
+ names: ListOfString8
+ widget: Widget
+
+ --->
+ novalues: ListOfCard16
+ values: ListOfString8
+
+ GetValues will allow a number of resource values to be read
+ on a particular widget. The request specifies the names of
+ the resources wanted and the widget id these resources are
+ from. The reply returns a list of indices from the requests
+ name list of resources for which a value can not be returned.
+ It also returns a list of returned values, in the order of the
+ requests names list, skipping those indices present in novalues.
+
+ GetResources:
+
+ Number of Entries: Card16
+ Entry
+ widget: ListOfWidgets:
+
+ ---->
+
+ Number of Entries: Card16
+ Entry
+ Widget: ListOfWidgets:
+ Error: Bool
+
+ [ Message: String 8 ]
+ [ Number of Resources: Card16
+ Resource:
+ Kind: {normal, constraint}
+ Name: String8
+ Class: String8
+ Type: String8 ]
+
+ GetResource retrieves the kind, name, class and type for every
+ widget passed to it. If an error occured with the resource fetch
+ Error will be set to True for the given widget and a message
+ is returned rather than the resource info.
+
+ GetGeometry:
+
+ Number of Entries: Card16
+ Entry
+ Widget: ListOfWidgets:
+
+ ---->
+
+ Number of Entries: Card16
+ Entry
+ Widget: ListOfWidgets:
+ Error: Bool
+
+ [ message: String 8 ]
+ [ mapped: Boolean
+ X: Int16
+ Y: Int16
+ Width: Card16
+ Height: Card16
+ BorderWidth: Card16 ]
+
+ GetGeometry retreives the mapping state, x, y, width, height
+ and border width for each widget specified. If an error occured
+ with the geometry fetch "Error" will be set to True for the given
+ widget and a message is returned rather than the geometry info.
+ X an Y corrospond to the root coordinates of the upper left corner
+ of the widget (outside the window border).
+
+ FindChild:
+
+ Widget: ListOfWidgets
+ X: Int16
+ Y: Int16
+
+ --->
+
+ Widget: ListOfWidgets
+
+ Find Child returns a descendent of the widget specified that
+ is at the root coordinates specified.
+
+ NOTE:
+
+ The returned widget is undefined if the point is contained in
+ two or more mapped widgets, or in two overlapping Rect objs.
+
+ GetValues:
+
+ names: ListOfString8
+ widget: Widget
+
+ --->
+
+ values: ListOfString8
+
+ GetValues will allow a number of resource values to be read
+ on a particular widget. Currently only InterViews 3.0.1 Styles
+ and their attributes are supported. In addition, the current
+ user interface only supports the return of 1 resource. The ability
+ to specify and return multiple resources is defined for future editres
+ interfaces where some or all of a widgets resource values are returned
+ and displayed at once.
+
+
+************************************************************/
+
+#include <X11/Intrinsic.h>
+#include <X11/Xfuncproto.h>
+
+#define XER_NBBY 8 /* number of bits in a byte */
+#define BYTE_MASK 255
+
+#define HEADER_SIZE 6
+
+#define EDITRES_IS_OBJECT 2
+#define EDITRES_IS_UNREALIZED 0
+
+/*
+ * Format for atoms.
+ */
+
+#define EDITRES_FORMAT 8
+#define EDITRES_SEND_EVENT_FORMAT 32
+
+/*
+ * Atoms
+ */
+
+#define EDITRES_NAME "Editres"
+#define EDITRES_COMMAND_ATOM "EditresCommand"
+#define EDITRES_COMM_ATOM "EditresComm"
+#define EDITRES_CLIENT_VALUE "EditresClientVal"
+#define EDITRES_PROTOCOL_ATOM "EditresProtocol"
+
+typedef enum { SendWidgetTree = 0,
+ SetValues = 1,
+ GetResources = 2,
+ GetGeometry = 3,
+ FindChild = 4,
+ GetValues = 5
+ } EditresCommand;
+
+typedef enum {NormalResource = 0, ConstraintResource = 1} ResourceType;
+
+/*
+ * The type of a resource identifier.
+ */
+
+typedef unsigned char ResIdent;
+
+typedef enum {PartialSuccess= 0, Failure= 1, ProtocolMismatch= 2} EditResError;
+
+typedef struct _WidgetInfo {
+ unsigned short num_widgets;
+ unsigned long * ids;
+ Widget real_widget;
+} WidgetInfo;
+
+typedef struct _ProtocolStream {
+ unsigned long size, alloc;
+ unsigned char *real_top, *top, *current;
+} ProtocolStream;
+
+/************************************************************
+ *
+ * Function definitions for reading and writing protocol requests.
+ *
+ ************************************************************/
+
+_XFUNCPROTOBEGIN
+
+void _XEditResPutString8(), _XEditResPut8(), _XEditResPut16();
+void _XEditResPut32(), _XEditResPutWidgetInfo(), _XEditResPutWidget();
+void _XEditResResetStream();
+
+Boolean _XEditResGet8(), _XEditResGet16(), _XEditResGetSigned16();
+Boolean _XEditResGet32(), _XEditResGetString8(), _XEditResGetWidgetInfo();
+
+_XFUNCPROTOEND
diff --git a/include/X11/Xmu/Error.h b/include/X11/Xmu/Error.h
new file mode 100644
index 0000000..0fd97c2
--- /dev/null
+++ b/include/X11/Xmu/Error.h
@@ -0,0 +1,60 @@
+/* $Xorg: Error.h,v 1.5 2001/02/09 02:03:52 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.
+
+*/
+
+/*
+ * The interfaces described by this header file are for miscellaneous utilities
+ * and are not part of the Xlib standard.
+ */
+
+#ifndef _XMU_ERROR_H_
+#define _XMU_ERROR_H_
+
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+extern int XmuPrintDefaultErrorMessage(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ XErrorEvent* /* event */,
+ FILE* /* fp */
+#endif
+);
+
+extern int XmuSimpleErrorHandler(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ XErrorEvent* /* errorp */
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XMU_ERROR_H_ */
diff --git a/include/X11/Xmu/ExtAgent.h b/include/X11/Xmu/ExtAgent.h
new file mode 100644
index 0000000..81e5c67
--- /dev/null
+++ b/include/X11/Xmu/ExtAgent.h
@@ -0,0 +1,45 @@
+/* $Xorg: ExtAgent.h,v 1.5 2001/02/09 02:03:52 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 <X11/Intrinsic.h>
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+extern void
+XmuRegisterExternalAgent(
+#if NeedFunctionPrototypes
+ Widget /* w */,
+ XtPointer /* data */,
+ XEvent* /* event */,
+ Boolean* /* cont */
+#endif
+);
+
+_XFUNCPROTOEND
+
diff --git a/include/X11/Xmu/Initer.h b/include/X11/Xmu/Initer.h
new file mode 100644
index 0000000..ad744cc
--- /dev/null
+++ b/include/X11/Xmu/Initer.h
@@ -0,0 +1,64 @@
+/* $Xorg: Initer.h,v 1.5 2001/02/09 02:03:52 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.
+
+*/
+
+/*
+ * The interfaces described by this header file are for miscellaneous utilities
+ * and are not part of the Xlib standard.
+ */
+
+#ifndef _XMU_INITER_H_
+#define _XMU_INITER_H_
+
+#include <X11/Intrinsic.h>
+#include <X11/Xfuncproto.h>
+
+typedef void (*XmuInitializerProc)(
+#if NeedFunctionPrototypes
+ XtAppContext /* app_context */,
+ XPointer /* data */
+#endif
+);
+
+_XFUNCPROTOBEGIN
+
+extern void XmuCallInitializers(
+#if NeedFunctionPrototypes
+ XtAppContext /* app_context */
+#endif
+);
+
+extern void XmuAddInitializer(
+#if NeedFunctionPrototypes
+ XmuInitializerProc /* func */,
+ XPointer /* data */
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XMU_INITER_H_ */
diff --git a/include/X11/Xmu/Misc.h b/include/X11/Xmu/Misc.h
new file mode 100644
index 0000000..b47fbba
--- /dev/null
+++ b/include/X11/Xmu/Misc.h
@@ -0,0 +1,65 @@
+/* $Xorg: Misc.h,v 1.4 2001/02/09 02:03:53 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.
+
+******************************************************************/
+
+/* Various useful constant and macro definitions */
+
+#ifndef _Xmu_Misc_h
+#define _Xmu_Misc_h
+
+#define MAXDIMENSION ((1 << 31)-1)
+
+#define Max(x, y) (((x) > (y)) ? (x) : (y))
+#define Min(x, y) (((x) < (y)) ? (x) : (y))
+#define AssignMax(x, y) {if ((y) > (x)) x = (y);}
+#define AssignMin(x, y) {if ((y) < (x)) x = (y);}
+
+#endif /*_Xmu_Misc_h*/
diff --git a/include/X11/Xmu/StdCmap.h b/include/X11/Xmu/StdCmap.h
new file mode 100644
index 0000000..3ee8f0d
--- /dev/null
+++ b/include/X11/Xmu/StdCmap.h
@@ -0,0 +1,112 @@
+/* $Xorg: StdCmap.h,v 1.5 2001/02/09 02:03:53 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.
+
+*/
+
+/*
+ * The interfaces described by this header file are for miscellaneous utilities
+ * and are not part of the Xlib standard.
+ */
+
+#ifndef _XMU_STDCMAP_H_
+#define _XMU_STDCMAP_H_
+
+#include <X11/Intrinsic.h>
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+Status XmuAllStandardColormaps(
+#if NeedFunctionPrototypes
+ Display* /* dpy */
+#endif
+);
+
+Status XmuCreateColormap(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ XStandardColormap* /* colormap */
+#endif
+);
+
+void XmuDeleteStandardColormap(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ int /* screen */,
+ Atom /* property */
+#endif
+);
+
+Status XmuGetColormapAllocation(
+#if NeedFunctionPrototypes
+ XVisualInfo* /* vinfo */,
+ Atom /* property */,
+ unsigned long* /* red_max_return */,
+ unsigned long* /* green_max_return */,
+ unsigned long* /* blue_max_return */
+#endif
+);
+
+Status XmuLookupStandardColormap(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ int /* screen */,
+ VisualID /* visualid */,
+ unsigned int /* depth */,
+ Atom /* property */,
+ Bool /* replace */,
+ Bool /* retain */
+#endif
+);
+
+XStandardColormap *XmuStandardColormap(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ int /* screen */,
+ VisualID /* visualid */,
+ unsigned int /* depth */,
+ Atom /* property */,
+ Colormap /* cmap */,
+ unsigned long /* red_max */,
+ unsigned long /* green_max */,
+ unsigned long /* blue_max */
+#endif
+);
+
+Status XmuVisualStandardColormaps(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ int /* screen */,
+ VisualID /* visualid */,
+ unsigned int /* depth */,
+ Bool /* replace */,
+ Bool /* retain */
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XMU_STDCMAP_H_ */
diff --git a/include/X11/Xmu/StdSel.h b/include/X11/Xmu/StdSel.h
new file mode 100644
index 0000000..a38f8d7
--- /dev/null
+++ b/include/X11/Xmu/StdSel.h
@@ -0,0 +1,59 @@
+/* $Xorg: StdSel.h,v 1.5 2001/02/09 02:03:53 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.
+
+*/
+
+/*
+ * The interfaces described by this header file are for miscellaneous utilities
+ * and are not part of the Xlib standard.
+ */
+
+#ifndef _XMU_SELECTION_H_
+#define _XMU_SELECTION_H_
+
+#include <X11/Intrinsic.h>
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+extern Boolean XmuConvertStandardSelection(
+#if NeedFunctionPrototypes
+ Widget /* w */,
+ Time /* time */,
+ Atom* /* selection */,
+ Atom* /* target */,
+ Atom* /* type_return */,
+ XPointer * /* value_return */,
+ unsigned long * /* length_return */,
+ int * /* format_return */
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XMU_SELECTION_H_ */
+
+
diff --git a/include/X11/Xmu/SysUtil.h b/include/X11/Xmu/SysUtil.h
new file mode 100644
index 0000000..3306492
--- /dev/null
+++ b/include/X11/Xmu/SysUtil.h
@@ -0,0 +1,45 @@
+/* $Xorg: SysUtil.h,v 1.4 2001/02/09 02:03:53 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.
+
+*/
+
+#ifndef _SYSUTIL_H_
+#define _SYSUTIL_H_
+
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+extern int XmuGetHostname(
+#if NeedFunctionPrototypes
+ char* /* buf_return */,
+ int /* maxlen */
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* _SYSUTIL_H_ */
diff --git a/include/X11/Xmu/WhitePoint.h b/include/X11/Xmu/WhitePoint.h
new file mode 100644
index 0000000..a05bddd
--- /dev/null
+++ b/include/X11/Xmu/WhitePoint.h
@@ -0,0 +1,65 @@
+/* $Xorg: WhitePoint.h,v 1.4 2001/02/09 02:03:53 xorgcvs Exp $ */
+
+/*
+
+Copyright 1991, 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.
+
+*/
+
+
+/*
+ *
+ * DESCRIPTION
+ * This file contains a series of standard white point values.
+ */
+#define CIE_A_u 0.2560
+#define CIE_A_v 0.5243
+#define CIE_A_Y 1.0000
+
+#define CIE_B_u 0.2137
+#define CIE_B_v 0.4852
+#define CIE_B_Y 1.0000
+
+#define CIE_C_u 0.2009
+#define CIE_C_v 0.4609
+#define CIE_C_Y 1.0000
+
+#define CIE_D55_u 0.2044
+#define CIE_D55_v 0.4808
+#define CIE_D55_Y 1.0000
+
+#define CIE_D65_u 0.1978
+#define CIE_D65_v 0.4684
+#define CIE_D65_Y 1.0000
+
+#define CIE_D75_u 0.1935
+#define CIE_D75_v 0.4586
+#define CIE_D75_Y 1.0000
+
+#define ASTM_D50_u 0.2092
+#define ASTM_D50_v 0.4881
+#define ASTM_D50_Y 1.0000
+
+#define WP_9300K_u 0.1884
+#define WP_9300K_v 0.4463
+#define WP_9300K_Y 1.0000
diff --git a/include/X11/Xmu/WidgetNode.h b/include/X11/Xmu/WidgetNode.h
new file mode 100644
index 0000000..f24a8fa
--- /dev/null
+++ b/include/X11/Xmu/WidgetNode.h
@@ -0,0 +1,101 @@
+/* $Xorg: WidgetNode.h,v 1.5 2001/02/09 02:03:53 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.
+
+*/
+
+/*
+ * Author: Jim Fulton, MIT X Consortium
+ */
+
+#ifndef _XmuWidgetNode_h
+#define _XmuWidgetNode_h
+
+#include <X11/Intrinsic.h>
+#include <X11/Xfuncproto.h>
+
+/*
+ * This is usually initialized by setting the first two fields and letting
+ * rest be implicitly nulled (by genlist.sh, for example)
+ */
+typedef struct _XmuWidgetNode {
+ char *label; /* mixed case name */
+ WidgetClass *widget_class_ptr; /* addr of widget class */
+ struct _XmuWidgetNode *superclass; /* superclass of widget_class */
+ struct _XmuWidgetNode *children, *siblings; /* subclass links */
+ char *lowered_label; /* lowercase version of label */
+ char *lowered_classname; /* lowercase version of class_name */
+ Bool have_resources; /* resources have been fetched */
+ XtResourceList resources; /* extracted resource database */
+ struct _XmuWidgetNode **resourcewn; /* where resources come from */
+ Cardinal nresources; /* number of resources */
+ XtResourceList constraints; /* extracted constraint resources */
+ struct _XmuWidgetNode **constraintwn; /* where constraints come from */
+ Cardinal nconstraints; /* number of constraint resources */
+ XtPointer data; /* extra data */
+} XmuWidgetNode;
+
+#define XmuWnClass(wn) ((wn)->widget_class_ptr[0])
+#define XmuWnClassname(wn) (XmuWnClass(wn)->core_class.class_name)
+#define XmuWnSuperclass(wn) ((XmuWnClass(wn))->core_class.superclass)
+
+ /* external interfaces */
+_XFUNCPROTOBEGIN
+
+extern void XmuWnInitializeNodes (
+#if NeedFunctionPrototypes
+ XmuWidgetNode * /* nodearray */,
+ int /* nnodes */
+#endif
+);
+
+extern void XmuWnFetchResources (
+#if NeedFunctionPrototypes
+ XmuWidgetNode * /* node */,
+ Widget /* toplevel */,
+ XmuWidgetNode * /* topnode */
+#endif
+);
+
+extern int XmuWnCountOwnedResources (
+#if NeedFunctionPrototypes
+ XmuWidgetNode * /* node */,
+ XmuWidgetNode * /* ownernode */,
+ Bool /* constraints */
+#endif
+);
+
+extern XmuWidgetNode *XmuWnNameToNode (
+#if NeedFunctionPrototypes
+ XmuWidgetNode * /* nodelist */,
+ int /* nnodes */,
+ _Xconst char * /* name */
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XmuWidgetNode_h */
+
diff --git a/include/X11/Xmu/WinUtil.h b/include/X11/Xmu/WinUtil.h
new file mode 100644
index 0000000..3e1eb59
--- /dev/null
+++ b/include/X11/Xmu/WinUtil.h
@@ -0,0 +1,66 @@
+/* $Xorg: WinUtil.h,v 1.4 2001/02/09 02:03:53 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.
+
+*/
+
+/*
+ * The interfaces described by this header file are for miscellaneous utilities
+ * and are not part of the Xlib standard.
+ */
+
+#ifndef _XMU_WINDOWUTIL_H_
+#define _XMU_WINDOWUTIL_H_
+
+#include <X11/Xutil.h>
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+extern Window XmuClientWindow(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ Window /* win */
+#endif
+);
+
+extern Bool XmuUpdateMapHints(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ Window /* win */,
+ XSizeHints* /* hints */
+#endif
+);
+
+extern Screen *XmuScreenOfWindow(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ Window /* w */
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XMU_WINDOWUTIL_H_ */
diff --git a/include/X11/Xmu/Xct.h b/include/X11/Xmu/Xct.h
new file mode 100644
index 0000000..cb344b4
--- /dev/null
+++ b/include/X11/Xmu/Xct.h
@@ -0,0 +1,171 @@
+/* $Xorg: Xct.h,v 1.4 2001/02/09 02:03:53 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.
+
+*/
+
+#ifndef _Xct_h
+#define _Xct_h
+
+#include <X11/Xfuncproto.h>
+
+#define XctVersion 1
+
+typedef unsigned char *XctString;
+
+typedef enum {
+ XctUnspecified,
+ XctLeftToRight,
+ XctRightToLeft
+} XctHDirection;
+
+typedef unsigned long XctFlags;
+
+/* These are bits in XctFlags. */
+
+#define XctSingleSetSegments 0x0001
+ /* This means that returned segments should contain characters from only
+ * one set (C0, C1, GL, GR). When this is requested, XctSegment is never
+ * returned, instead XctC0Segment, XctC1Segment, XctGlSegment, and
+ * XctGRSegment are returned. C0 and C1 segments are always returned as
+ * singleton characters.
+ */
+
+#define XctProvideExtensions 0x0002
+ /* This means that if the Compound Text string is from a higher version
+ * than this code is implemented to, then syntactically correct but unknown
+ * control sequences should be returned as XctExtension items. If this
+ * flag is not set, and the Compound Text string version indicates that
+ * extensions cannot be ignored, then each unknown control sequence will be
+ * reported as an XctError.
+ */
+
+#define XctAcceptC0Extensions 0x0004
+ /* This means that if the Compound Text string is from a higher version
+ * than this code is implemented to, then unknown C0 characters should be
+ * treated as if they were legal, and returned as C0 characters (regardless
+ * of how XctProvideExtensions is set). If this flag is not set, then all
+ * unknown C0 characters are treated according to XctProvideExtensions.
+ */
+
+#define XctAcceptC1Extensions 0x0008
+ /* This means that if the Compound Text string is from a higher version
+ * than this code is implemented to, then unknown C0 characters should be
+ * treated as if they were legal, and returned as C0 characters (regardless
+ * of how XctProvideExtensions is set). If this flag is not set, then all
+ * unknown C0 characters are treated according to XctProvideExtensions.
+ */
+
+#define XctHideDirection 0x0010
+ /* This means that horizontal direction changes should be reported as
+ * XctHorizontal items. If this flag is not set, then direction changes are
+ * not returned as items, but the current direction is still maintained and
+ * reported for other items.
+ */
+
+#define XctFreeString 0x0020
+ /* This means that XctFree should free the Compound Text string (that was
+ * passed to XctCreate. If this flag is not set, the string is not freed.
+ */
+
+#define XctShiftMultiGRToGL 0x0040
+ /* Translate GR segments on-the-fly into GL segments for the GR sets:
+ * GB2312.1980-1, JISX0208.1983-1, and KSC5601.1987-1.
+ */
+
+/* This is the return type for XctNextItem. */
+typedef enum {
+ XctSegment, /* used when XctSingleSetSegments is not requested */
+ XctC0Segment, /* used when XctSingleSetSegments is requested */
+ XctGLSegment, /* used when XctSingleSetSegments is requested */
+ XctC1Segment, /* used when XctSingleSetSegments is requested */
+ XctGRSegment, /* used when XctSingleSetSegments is requested */
+ XctExtendedSegment, /* an extended segment */
+ XctExtension, /* used when XctProvideExtensions is requested */
+ XctHorizontal, /* horizontal direction or depth change */
+ XctEndOfText, /* end of text string */
+ XctError /* syntactic or semantic error */
+} XctResult;
+
+typedef struct _XctRec {
+ XctString total_string; /* as given to XctCreate */
+ int total_length; /* as given to XctCreate */
+ XctFlags flags; /* as given to XctCreate */
+ int version; /* indicates the version of the CT spec
+ * the string was produced from */
+ int can_ignore_exts;/* non-zero if ignoring extensions is
+ * acceptable, else zero */
+ XctString item; /* item returned from XctNextItem */
+ int item_length; /* length of item in bytes */
+ int char_size; /* number of bytes per character in
+ * item, with zero meaning variable */
+ char *encoding; /* Encoding name for item */
+ XctHDirection horizontal; /* direction of item */
+ int horz_depth; /* current direction nesting depth */
+ char *GL; /* "{I} F" string for current GL */
+ char *GL_encoding; /* Encoding name for current GL */
+ int GL_set_size; /* 94 or 96 */
+ int GL_char_size; /* number of bytes per GL character */
+ char *GR; /* "{I} F" string for current GR */
+ char *GR_encoding; /* Encoding name for current GR */
+ int GR_set_size; /* 94 or 96 */
+ int GR_char_size; /* number of bytes per GR character */
+ char *GLGR_encoding; /* Encoding name for current GL+GR,
+ * if known */
+ struct _XctPriv *priv; /* private to parser, don't peek */
+} *XctData;
+
+/* these are the external routines */
+_XFUNCPROTOBEGIN
+
+extern XctData XctCreate(
+#if NeedFunctionPrototypes
+ _Xconst unsigned char * /* string */,
+ int /* length */,
+ XctFlags /* flags */
+#endif
+);
+
+extern XctResult XctNextItem(
+#if NeedFunctionPrototypes
+ XctData /* data */
+#endif
+);
+
+extern void XctFree(
+#if NeedFunctionPrototypes
+ XctData /* data */
+#endif
+);
+
+extern void XctReset(
+#if NeedFunctionPrototypes
+ XctData /* data */
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* _Xct_h */
diff --git a/include/X11/Xmu/Xmu.h b/include/X11/Xmu/Xmu.h
new file mode 100644
index 0000000..416d1fa
--- /dev/null
+++ b/include/X11/Xmu/Xmu.h
@@ -0,0 +1,52 @@
+/* $Xorg: Xmu.h,v 1.4 2001/02/09 02:03:53 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.
+
+*/
+
+/*
+ * The interfaces described by this header file are for miscellaneous utilities
+ * and are not part of the Xlib standard.
+ */
+
+#ifndef _XMU_H_
+#define _XMU_H_
+
+/*
+ * This include file is obsolete and is provided only for compatibility with
+ * MIT Release 3 clients. Callers should use the appropriate include file.
+ *
+ * DO NOT ADD ANY NEW INCLUDES OR DEFINITIONS TO THIS FILE!
+ */
+#include <X11/Intrinsic.h>
+#include <X11/Xmu/Atoms.h> /* _XA_... */
+#include <X11/Xmu/CharSet.h> /* CopyISOLatin1Lowered */
+#include <X11/Xmu/Converters.h> /* CvtStringTo... */
+#include <X11/Xmu/Drawing.h> /* DrawRoundedRect, DrawLogo */
+#include <X11/Xmu/Error.h> /* PrintDefaultError */
+#include <X11/Xmu/StdSel.h> /* ConvertStandardSelection */
+
+#endif /* _XMU_H_ */
+
diff --git a/src/AllCmap.c b/src/AllCmap.c
new file mode 100644
index 0000000..4b24ca6
--- /dev/null
+++ b/src/AllCmap.c
@@ -0,0 +1,155 @@
+/* $Xorg: AllCmap.c,v 1.4 2001/02/09 02:03:51 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 <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+#include <X11/Xmu/StdCmap.h>
+
+static XVisualInfo *getDeepestVisual();
+
+/*
+ * To create all of the appropriate standard colormaps for every visual of
+ * every screen on a given display, use XmuAllStandardColormaps.
+ *
+ * Define and retain as permanent resources all standard colormaps which are
+ * meaningful for the visuals of each screen of the display. Return 0 on
+ * failure, non-zero on success. If the property of any standard colormap
+ * is already defined, redefine it.
+ *
+ * This interface is intended to be used by window managers or a client
+ * upon start-up of a session.
+ *
+ * The standard colormaps of a screen are defined by properties associated
+ * with the screen's root window. Each screen has exactly one root window.
+ * The property names of standard colormaps are predefined, and each property
+ * name may describe at most one colormap.
+ *
+ * The standard colormaps are
+ * RGB_BEST_MAP
+ * RGB_RED_MAP
+ * RGB_GREEN_MAP
+ * RGB_BLUE_MAP
+ * RGB_DEFAULT_MAP
+ * RGB_GRAY_MAP
+ *
+ * Therefore a screen may have at most 6 standard colormap properties defined.
+ *
+ * A standard colormap is associated with a particular visual of the screen.
+ * A screen may have multiple visuals defined, including visuals of the same
+ * class at different depths. Note that a visual id might be repeated for
+ * more than one depth, so the visual id and the depth of a visual identify
+ * the visual. The characteristics of the visual will determine which
+ * standard colormaps are meaningful under that visual, and will determine
+ * how the standard colormap is defined. Because a standard colormap is
+ * associated with a specific visual, there must be a method of determining
+ * which visuals take precedence in defining standard colormaps.
+ *
+ * The method used here is: for the visual of greatest depth, define all
+ * standard colormaps meaningful to that visual class, according to this
+ * order of (descending) precedence:
+ * 1. DirectColor
+ * 2. PseudoColor
+ * 3. TrueColor and GrayScale
+ * 4. StaticColor and StaticGray
+ *
+ * Allows partial success by screenful. For example, if a map on screen 1
+ * fails, the maps on screen 0, created earlier, will remain. However,
+ * none on screen 1 will remain. If a map on 0 fails, none will remain.
+ *
+ * See the comments under XmuVisualStandardColormaps() for notes on which
+ * standard colormaps are meaningful under these classes of visuals.
+ */
+
+Status XmuAllStandardColormaps(dpy)
+ Display *dpy; /* Specifies the connection to the X server */
+{
+ int nvisuals, scr;
+ Status status;
+ long vinfo_mask;
+ XVisualInfo template, *vinfo, *v1, *v2;
+
+ /* for each screen, determine all visuals of this server */
+ for (scr=0; scr < ScreenCount(dpy); scr++)
+ {
+ template.screen = scr;
+ vinfo_mask = VisualScreenMask;
+ vinfo = XGetVisualInfo(dpy, vinfo_mask, &template, &nvisuals);
+ if (vinfo == NULL) /* unexpected: a screen with no visuals */
+ continue;
+
+ v1 = getDeepestVisual(DirectColor, vinfo, nvisuals);
+ v2 = getDeepestVisual(PseudoColor, vinfo, nvisuals);
+
+ if (v2 &&
+ (!v1 || (v2->colormap_size >=
+ ((v1->red_mask | v1->green_mask | v1->blue_mask) + 1))))
+ status = XmuVisualStandardColormaps(dpy, scr, v2->visualid,
+ (unsigned) v2->depth, 1, 1);
+ else if (v1)
+ status = XmuVisualStandardColormaps(dpy, scr, v1->visualid,
+ (unsigned) v1->depth, 1, 1);
+
+ else {
+ if (((v1 = getDeepestVisual(TrueColor, vinfo, nvisuals)) != NULL)
+ || ((v1 = getDeepestVisual(StaticColor, vinfo, nvisuals)) !=
+ NULL))
+ status = XmuVisualStandardColormaps(dpy, scr, v1->visualid,
+ (unsigned) v1->depth, 1, 1);
+ if (status &&
+ (((v1 = getDeepestVisual(GrayScale, vinfo, nvisuals)) != NULL)
+ || ((v1 = getDeepestVisual(StaticGray, vinfo, nvisuals)) !=
+ NULL)))
+ status = XmuVisualStandardColormaps(dpy, scr, v1->visualid,
+ (unsigned) v1->depth, 1, 1);
+ }
+ XFree ((char *) vinfo);
+ if (!status) break;
+ }
+ return status;
+}
+
+static XVisualInfo *getDeepestVisual(visual_class, vinfo, nvisuals)
+ int visual_class; /* specifies the visual class */
+ XVisualInfo *vinfo; /* specifies all visuals for a screen */
+ int nvisuals; /* specifies number of visuals in the list */
+{
+ register int i;
+ unsigned int maxdepth = 0;
+ XVisualInfo *v = NULL;
+
+ for (i=0; i < nvisuals; i++, vinfo++)
+ if (vinfo->class == visual_class && vinfo->depth > maxdepth)
+ {
+ maxdepth = vinfo->depth;
+ v = vinfo;
+ }
+ return(v);
+}
+
diff --git a/src/Atoms.c b/src/Atoms.c
new file mode 100644
index 0000000..dda08cc
--- /dev/null
+++ b/src/Atoms.c
@@ -0,0 +1,157 @@
+/* $Xorg: Atoms.c,v 1.4 2001/02/09 02:03:51 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.
+
+*/
+
+/*
+ * This file contains routines to cache atoms, avoiding multiple
+ * server round-trips. Not so useful now that Xlib caches them.
+ *
+ * Public entry points:
+ *
+ * XmuMakeAtom creates & initializes an opaque AtomRec
+ * XmuInternAtom fetches an Atom from cache or Display
+ * XmuInternStrings fetches multiple Atoms as strings
+ * XmuGetAtomName returns name of an Atom
+ * XmuNameOfAtom returns name from an AtomPtr
+ */
+
+#include <X11/Intrinsic.h>
+#include "Atoms.h"
+
+typedef struct _DisplayRec {
+ struct _DisplayRec* next;
+ Display *dpy;
+ Atom atom;
+} DisplayRec;
+
+struct _AtomRec {
+ char *name;
+ DisplayRec* head;
+};
+
+#ifdef SUNSHLIB
+#define STATIC
+#else
+#define STATIC static
+#endif
+
+#if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
+#define DeclareAtom(atom,text) \
+STATIC struct _AtomRec __##atom = { text, NULL }; \
+AtomPtr _##atom = &__##atom;
+#else
+#define DeclareAtom(atom,text) \
+STATIC struct _AtomRec __/**/atom = { text, NULL }; \
+AtomPtr _/**/atom = &__/**/atom;
+#endif
+
+DeclareAtom(XA_ATOM_PAIR, "ATOM_PAIR" )
+DeclareAtom(XA_CHARACTER_POSITION, "CHARACTER_POSITION" )
+DeclareAtom(XA_CLASS, "CLASS" )
+DeclareAtom(XA_CLIENT_WINDOW, "CLIENT_WINDOW" )
+DeclareAtom(XA_CLIPBOARD, "CLIPBOARD" )
+DeclareAtom(XA_COMPOUND_TEXT, "COMPOUND_TEXT" )
+DeclareAtom(XA_DECNET_ADDRESS, "DECNET_ADDRESS" )
+DeclareAtom(XA_DELETE, "DELETE" )
+DeclareAtom(XA_FILENAME, "FILENAME" )
+DeclareAtom(XA_HOSTNAME, "HOSTNAME" )
+DeclareAtom(XA_IP_ADDRESS, "IP_ADDRESS" )
+DeclareAtom(XA_LENGTH, "LENGTH" )
+DeclareAtom(XA_LIST_LENGTH, "LIST_LENGTH" )
+DeclareAtom(XA_NAME, "NAME" )
+DeclareAtom(XA_NET_ADDRESS, "NET_ADDRESS" )
+DeclareAtom(XA_NULL, "NULL" )
+DeclareAtom(XA_OWNER_OS, "OWNER_OS" )
+DeclareAtom(XA_SPAN, "SPAN" )
+DeclareAtom(XA_TARGETS, "TARGETS" )
+DeclareAtom(XA_TEXT, "TEXT" )
+DeclareAtom(XA_TIMESTAMP, "TIMESTAMP" )
+DeclareAtom(XA_USER, "USER" )
+
+/******************************************************************
+
+ Public procedures
+
+ ******************************************************************/
+
+
+#if NeedFunctionPrototypes
+AtomPtr XmuMakeAtom(_Xconst char *name)
+#else
+AtomPtr XmuMakeAtom(name)
+ char* name;
+#endif
+{
+ AtomPtr ptr = XtNew(struct _AtomRec);
+ ptr->name = (char *) name;
+ ptr->head = NULL;
+ return ptr;
+}
+
+char* XmuNameOfAtom(atom_ptr)
+ AtomPtr atom_ptr;
+{
+ return atom_ptr->name;
+}
+
+
+Atom XmuInternAtom(d, atom_ptr)
+ Display *d;
+ AtomPtr atom_ptr;
+{
+ DisplayRec* display_rec;
+ for (display_rec = atom_ptr->head; display_rec != NULL;
+ display_rec = display_rec->next) {
+ if (display_rec->dpy == d)
+ return display_rec->atom;
+ }
+ display_rec = XtNew(DisplayRec);
+ display_rec->next = atom_ptr->head;
+ atom_ptr->head = display_rec;
+ display_rec->dpy = d;
+ display_rec->atom = XInternAtom(d, atom_ptr->name, False);
+ return display_rec->atom;
+}
+
+
+char *XmuGetAtomName(d, atom)
+ Display *d;
+ Atom atom;
+{
+ if (atom == 0) return "(BadAtom)";
+ return XGetAtomName(d, atom);
+}
+
+/* convert (names, count) to a list of atoms. Caller allocates list */
+void XmuInternStrings(d, names, count, atoms)
+ Display *d;
+ register String *names;
+ register Cardinal count;
+ register Atom *atoms; /* return */
+{
+ (void) XInternAtoms(d, (char**)names, (int)count, FALSE, atoms);
+}
diff --git a/src/ClientWin.c b/src/ClientWin.c
new file mode 100644
index 0000000..faf206e
--- /dev/null
+++ b/src/ClientWin.c
@@ -0,0 +1,89 @@
+/* $Xorg: ClientWin.c,v 1.4 2001/02/09 02:03:51 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/Xlib.h>
+#include <X11/Xatom.h>
+
+static Window TryChildren();
+
+/* Find a window with WM_STATE, else return win itself, as per ICCCM */
+
+Window XmuClientWindow (dpy, win)
+ Display *dpy;
+ Window win;
+{
+ Atom WM_STATE;
+ Atom type = None;
+ int format;
+ unsigned long nitems, after;
+ unsigned char *data;
+ Window inf;
+
+ WM_STATE = XInternAtom(dpy, "WM_STATE", True);
+ if (!WM_STATE)
+ return win;
+ XGetWindowProperty(dpy, win, WM_STATE, 0, 0, False, AnyPropertyType,
+ &type, &format, &nitems, &after, &data);
+ if (type)
+ return win;
+ inf = TryChildren(dpy, win, WM_STATE);
+ if (!inf)
+ inf = win;
+ return inf;
+}
+
+static
+Window TryChildren (dpy, win, WM_STATE)
+ Display *dpy;
+ Window win;
+ Atom WM_STATE;
+{
+ Window root, parent;
+ Window *children;
+ unsigned int nchildren;
+ unsigned int i;
+ Atom type = None;
+ int format;
+ unsigned long nitems, after;
+ unsigned char *data;
+ Window inf = 0;
+
+ if (!XQueryTree(dpy, win, &root, &parent, &children, &nchildren))
+ return 0;
+ for (i = 0; !inf && (i < nchildren); i++) {
+ XGetWindowProperty(dpy, children[i], WM_STATE, 0, 0, False,
+ AnyPropertyType, &type, &format, &nitems,
+ &after, &data);
+ if (type)
+ inf = children[i];
+ }
+ for (i = 0; !inf && (i < nchildren); i++)
+ inf = TryChildren(dpy, children[i], WM_STATE);
+ if (children) XFree((char *)children);
+ return inf;
+}
diff --git a/src/CloseHook.c b/src/CloseHook.c
new file mode 100644
index 0000000..cde72fb
--- /dev/null
+++ b/src/CloseHook.c
@@ -0,0 +1,300 @@
+/* $Xorg: CloseHook.c,v 1.4 2001/02/09 02:03:51 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.
+
+*/
+
+/*
+ * CloseDisplayHook package - provide callback on XCloseDisplay
+ *
+ * *
+ * Author: Jim Fulton, MIT X Consortium
+ *
+ *
+ * Public Entry Points
+ *
+ * CloseHook XmuAddCloseDisplayHook (dpy, func, arg)
+ * Display *dpy;
+ * XmuCloseHookProc func;
+ * XPointer arg;
+ *
+ * Bool XmuRemoveCloseDisplayHook (dpy, hook, func, arg)
+ * Display *dpy;
+ * CloseHook hook;
+ * XmuCloseHookProc func;
+ * XPointer arg;
+ *
+ * Bool XmuLookupCloseDisplayHook (dpy, hook, func, arg)
+ * Display *dpy;
+ * CloseHook hook;
+ * XmuCloseHookProc func;
+ * XPointer arg;
+ *
+ */
+
+#include <stdio.h> /* for NULL */
+#include <X11/Xos.h>
+#include <X11/Xlib.h>
+#include <X11/Xmu/CloseHook.h>
+
+extern char *malloc(); /* should be void * */
+
+/*
+ * Private data
+ *
+ * This is a list of display entries, each of which contains a list of callback
+ * records.
+ */
+
+typedef struct _CallbackRec {
+ struct _CallbackRec *next; /* next link in chain */
+ XmuCloseHookProc func; /* function to call */
+ XPointer arg; /* argument to pass with function */
+} CallbackRec;
+
+
+typedef struct _DisplayEntry {
+ struct _DisplayEntry *next; /* next link in chain */
+ Display *dpy; /* the display this represents */
+ int extension; /* from XAddExtension */
+ struct _CallbackRec *start, *end; /* linked list of callbacks */
+ struct _CallbackRec *calling; /* currently being called back */
+} DisplayEntry;
+
+
+static DisplayEntry *elist = NULL;
+static Bool _MakeExtension();
+static DisplayEntry *_FindDisplayEntry();
+
+
+/*
+ *****************************************************************************
+ * Public Entry Points *
+ *****************************************************************************
+ */
+
+/*
+ * Add - add a callback for the given display. When the display is closed,
+ * the given function will be called as:
+ *
+ * (*func) (dpy, arg)
+ *
+ * This function is declared to return an int even though the value is ignored
+ * because some compilers have problems with functions returning void.
+ *
+ * This routine returns NULL if it was unable to add the callback, otherwise
+ * it returns an untyped pointer that can be used with Remove or Lookup, but
+ * not dereferenced.
+ */
+CloseHook XmuAddCloseDisplayHook (dpy, func, arg)
+ Display *dpy;
+ XmuCloseHookProc func; /* function to call on close display */
+ XPointer arg; /* arg to pass */
+{
+ DisplayEntry *de;
+ CallbackRec *cb;
+
+ /* allocate ahead of time so that we can fail atomically */
+ cb = (CallbackRec *) malloc (sizeof (CallbackRec));
+ if (!cb) return ((XPointer) NULL);
+
+ de = _FindDisplayEntry (dpy, NULL);
+ if (!de) {
+ if ((de = (DisplayEntry *) malloc (sizeof (DisplayEntry))) == NULL ||
+ !_MakeExtension (dpy, &de->extension)) {
+ free ((char *) cb);
+ if (de) free ((char *) de);
+ return ((CloseHook) NULL);
+ }
+ de->dpy = dpy;
+ de->start = de->end = NULL;
+ de->calling = NULL;
+ de->next = elist;
+ elist = de;
+ }
+
+ /* add to end of list of callback recordss */
+ cb->func = func;
+ cb->arg = arg;
+ cb->next = NULL;
+ if (de->end) {
+ de->end->next = cb;
+ } else {
+ de->start = cb;
+ }
+ de->end = cb;
+
+ return ((CloseHook) cb);
+}
+
+
+/*
+ * Remove - get rid of a callback. If handle is non-null, use that to compare
+ * entries. Otherwise, remove first instance of the function/argument pair.
+ */
+Bool XmuRemoveCloseDisplayHook (dpy, handle, func, arg)
+ Display *dpy;
+ CloseHook handle; /* value from XmuAddCloseDisplayHook */
+ XmuCloseHookProc func; /* function to call on close display */
+ XPointer arg; /* arg to pass */
+{
+ DisplayEntry *de = _FindDisplayEntry (dpy, NULL);
+ register CallbackRec *h, *prev;
+
+ if (!de) return False;
+
+ /* look for handle or function/argument pair */
+ for (h = de->start, prev = NULL; h; h = h->next) {
+ if (handle) {
+ if (h == (CallbackRec *) handle) break;
+ } else {
+ if (h->func == func && h->arg == arg) break;
+ }
+ prev = h;
+ }
+ if (!h) return False;
+
+
+ /* remove from list, watch head and tail */
+ if (de->start == h) {
+ de->start = h->next;
+ } else {
+ prev->next = h->next;
+ }
+ if (de->end == h) de->end = prev;
+ if (de->calling != h) free ((char *) h);
+ return True;
+}
+
+
+/*
+ * Lookup - see whether or not a handle has been installed. If handle is
+ * non-NULL, look for an entry that matches it; otherwise look for an entry
+ * with the same function/argument pair.
+ */
+Bool XmuLookupCloseDisplayHook (dpy, handle, func, arg)
+ Display *dpy;
+ CloseHook handle; /* value from XmuAddCloseDisplayHook */
+ XmuCloseHookProc func; /* function to call on close display */
+ XPointer arg; /* arg to pass */
+{
+ DisplayEntry *de = _FindDisplayEntry (dpy, NULL);
+ register CallbackRec *h;
+
+ if (!de) return False;
+
+ for (h = de->start; h; h = h->next) {
+ if (handle) {
+ if (h == (CallbackRec *) handle) break;
+ } else {
+ if (h->func == func && h->arg == arg) break;
+ }
+ }
+ return (h ? True : False);
+}
+
+
+/*
+ *****************************************************************************
+ * internal routines *
+ *****************************************************************************
+ */
+
+
+/*
+ * Find the specified display on the linked list of displays. Also return
+ * the preceeding link so that the display can be unlinked without having
+ * back pointers.
+ */
+static DisplayEntry *_FindDisplayEntry (dpy, prevp)
+ register Display *dpy;
+ DisplayEntry **prevp;
+{
+ register DisplayEntry *d, *prev;
+
+ for (d = elist, prev = NULL; d; d = d->next) {
+ if (d->dpy == dpy) {
+ if (prevp) *prevp = prev;
+ return d;
+ }
+ prev = d;
+ }
+ return NULL;
+}
+
+
+
+/*
+ * _DoCallbacks - process all of the callbacks for this display and free
+ * the associated callback data (callback records and display entries).
+ */
+/* ARGSUSED */
+static int _DoCallbacks (dpy, codes)
+ Display *dpy;
+ XExtCodes *codes;
+{
+ register CallbackRec *h;
+ DisplayEntry *prev;
+ DisplayEntry *de = _FindDisplayEntry (dpy, &prev);
+
+ if (!de) return 0;
+
+ /* walk the list doing the callbacks and freeing callback record */
+ for (h = de->start; h;) {
+ register CallbackRec *nexth = h->next;
+ de->calling = h; /* let remove know we'll free it */
+ (*(h->func)) (dpy, h->arg);
+ de->calling = NULL;
+ free ((char *) h);
+ h = nexth;
+ }
+
+ /* unlink this display from chain */
+ if (elist == de) {
+ elist = de->next;
+ } else {
+ prev->next = de->next;
+ }
+ free ((char *) de);
+ return 1;
+}
+
+
+/*
+ * _MakeExtension - create an extension for this display; done once per display
+ */
+static Bool _MakeExtension (dpy, extensionp)
+ Display *dpy;
+ int *extensionp;
+{
+ XExtCodes *codes;
+
+ codes = XAddExtension (dpy);
+ if (!codes) return False;
+
+ (void) XESetCloseDisplay (dpy, codes->extension, _DoCallbacks);
+
+ *extensionp = codes->extension;
+ return True;
+}
diff --git a/src/CmapAlloc.c b/src/CmapAlloc.c
new file mode 100644
index 0000000..fde2bf8
--- /dev/null
+++ b/src/CmapAlloc.c
@@ -0,0 +1,334 @@
+/* $Xorg: CmapAlloc.c,v 1.4 2001/02/09 02:03:51 xorgcvs Exp $ */
+
+/*
+
+Copyright 1989, 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.
+
+*/
+
+/*
+ * Author: Donna Converse, MIT X Consortium
+ */
+
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+#include <stdio.h>
+
+#define lowbit(x) ((x) & (~(x) + 1))
+
+static int default_allocation();
+static void best_allocation();
+static void gray_allocation();
+static int icbrt();
+static int icbrt_with_bits();
+static int icbrt_with_guess();
+
+/* To determine the best allocation of reds, greens, and blues in a
+ * standard colormap, use XmuGetColormapAllocation.
+ * vinfo specifies visual information for a chosen visual
+ * property specifies one of the standard colormap property names
+ * red_max returns maximum red value
+ * green_max returns maximum green value
+ * blue_max returns maximum blue value
+ *
+ * XmuGetColormapAllocation returns 0 on failure, non-zero on success.
+ * It is assumed that the visual is appropriate for the colormap property.
+ */
+
+Status XmuGetColormapAllocation(vinfo, property, red_max, green_max, blue_max)
+ XVisualInfo *vinfo;
+ Atom property;
+ unsigned long *red_max, *green_max, *blue_max;
+{
+ Status status = 1;
+
+ if (vinfo->colormap_size <= 2)
+ return 0;
+
+ switch (property)
+ {
+ case XA_RGB_DEFAULT_MAP:
+ status = default_allocation(vinfo, red_max, green_max, blue_max);
+ break;
+ case XA_RGB_BEST_MAP:
+ best_allocation(vinfo, red_max, green_max, blue_max);
+ break;
+ case XA_RGB_GRAY_MAP:
+ gray_allocation(vinfo->colormap_size, red_max, green_max, blue_max);
+ break;
+ case XA_RGB_RED_MAP:
+ *red_max = vinfo->colormap_size - 1;
+ *green_max = *blue_max = 0;
+ break;
+ case XA_RGB_GREEN_MAP:
+ *green_max = vinfo->colormap_size - 1;
+ *red_max = *blue_max = 0;
+ break;
+ case XA_RGB_BLUE_MAP:
+ *blue_max = vinfo->colormap_size - 1;
+ *red_max = *green_max = 0;
+ break;
+ default:
+ status = 0;
+ }
+ return status;
+}
+
+/****************************************************************************/
+/* Determine the appropriate color allocations of a gray scale.
+ *
+ * Keith Packard, MIT X Consortium
+ */
+
+static void gray_allocation(n, red_max, green_max, blue_max)
+ int n; /* the number of cells of the gray scale */
+ unsigned long *red_max, *green_max, *blue_max;
+{
+ *red_max = (n * 30) / 100;
+ *green_max = (n * 59) / 100;
+ *blue_max = (n * 11) / 100;
+ *green_max += ((n - 1) - (*red_max + *green_max + *blue_max));
+}
+
+/****************************************************************************/
+/* Determine an appropriate color allocation for the RGB_DEFAULT_MAP.
+ * If a map has less than a minimum number of definable entries, we do not
+ * produce an allocation for an RGB_DEFAULT_MAP.
+ *
+ * For 16 planes, the default colormap will have 27 each RGB; for 12 planes,
+ * 12 each. For 8 planes, let n = the number of colormap entries, which may
+ * be 256 or 254. Then, maximum red value = floor(cube_root(n - 125)) - 1.
+ * Maximum green and maximum blue values are identical to maximum red.
+ * This leaves at least 125 cells which clients can allocate.
+ *
+ * Return 0 if an allocation has been determined, non-zero otherwise.
+ */
+
+static int default_allocation(vinfo, red, green, blue)
+ XVisualInfo *vinfo;
+ unsigned long *red, *green, *blue;
+{
+ int ngrays; /* number of gray cells */
+
+ switch (vinfo->class) {
+ case PseudoColor:
+
+ if (vinfo->colormap_size > 65000)
+ /* intended for displays with 16 planes */
+ *red = *green = *blue = (unsigned long) 27;
+ else if (vinfo->colormap_size > 4000)
+ /* intended for displays with 12 planes */
+ *red = *green = *blue = (unsigned long) 12;
+ else if (vinfo->colormap_size < 250)
+ return 0;
+ else
+ /* intended for displays with 8 planes */
+ *red = *green = *blue = (unsigned long)
+ (icbrt(vinfo->colormap_size - 125) - 1);
+ break;
+
+ case DirectColor:
+
+ if (vinfo->colormap_size < 10)
+ return 0;
+ *red = *green = *blue = vinfo->colormap_size / 2 - 1;
+ break;
+
+ case TrueColor:
+
+ *red = vinfo->red_mask / lowbit(vinfo->red_mask);
+ *green = vinfo->green_mask / lowbit(vinfo->green_mask);
+ *blue = vinfo->blue_mask / lowbit(vinfo->blue_mask);
+ break;
+
+ case GrayScale:
+
+ if (vinfo->colormap_size > 65000)
+ ngrays = 4096;
+ else if (vinfo->colormap_size > 4000)
+ ngrays = 512;
+ else if (vinfo->colormap_size < 250)
+ return 0;
+ else
+ ngrays = 12;
+ gray_allocation(ngrays, red, green, blue);
+ break;
+
+ default:
+ return 0;
+ }
+ return 1;
+}
+
+/****************************************************************************/
+/* Determine an appropriate color allocation for the RGB_BEST_MAP.
+ *
+ * For a DirectColor or TrueColor visual, the allocation is determined
+ * by the red_mask, green_mask, and blue_mask members of the visual info.
+ *
+ * Otherwise, if the colormap size is an integral power of 2, determine
+ * the allocation according to the number of bits given to each color,
+ * with green getting more than red, and red more than blue, if there
+ * are to be inequities in the distribution. If the colormap size is
+ * not an integral power of 2, let n = the number of colormap entries.
+ * Then maximum red value = floor(cube_root(n)) - 1;
+ * maximum blue value = floor(cube_root(n)) - 1;
+ * maximum green value = n / ((# red values) * (# blue values)) - 1;
+ * Which, on a GPX, allows for 252 entries in the best map, out of 254
+ * defineable colormap entries.
+ */
+
+static void best_allocation(vinfo, red, green, blue)
+ XVisualInfo *vinfo;
+ unsigned long *red, *green, *blue;
+{
+
+ if (vinfo->class == DirectColor || vinfo->class == TrueColor)
+ {
+ *red = vinfo->red_mask;
+ while ((*red & 01) == 0)
+ *red >>= 1;
+ *green = vinfo->green_mask;
+ while ((*green & 01) == 0)
+ *green >>=1;
+ *blue = vinfo->blue_mask;
+ while ((*blue & 01) == 0)
+ *blue >>= 1;
+ }
+ else
+ {
+ register int bits, n;
+
+ /* Determine n such that n is the least integral power of 2 which is
+ * greater than or equal to the number of entries in the colormap.
+ */
+ n = 1;
+ bits = 0;
+ while (vinfo->colormap_size > n)
+ {
+ n = n << 1;
+ bits++;
+ }
+
+ /* If the number of entries in the colormap is a power of 2, determine
+ * the allocation by "dealing" the bits, first to green, then red, then
+ * blue. If not, find the maximum integral red, green, and blue values
+ * which, when multiplied together, do not exceed the number of
+
+ * colormap entries.
+ */
+ if (n == vinfo->colormap_size)
+ {
+ register int r, g, b;
+ b = bits / 3;
+ g = b + ((bits % 3) ? 1 : 0);
+ r = b + (((bits % 3) == 2) ? 1 : 0);
+ *red = 1 << r;
+ *green = 1 << g;
+ *blue = 1 << b;
+ }
+ else
+ {
+ *red = icbrt_with_bits(vinfo->colormap_size, bits);
+ *blue = *red;
+ *green = (vinfo->colormap_size / ((*red) * (*blue)));
+ }
+ (*red)--;
+ (*green)--;
+ (*blue)--;
+ }
+ return;
+}
+
+/*
+ * integer cube roots by Newton's method
+ *
+ * Stephen Gildea, MIT X Consortium, July 1991
+ */
+
+static int icbrt(a) /* integer cube root */
+ int a;
+{
+ register int bits = 0;
+ register unsigned n = a;
+
+ while (n)
+ {
+ bits++;
+ n >>= 1;
+ }
+ return icbrt_with_bits(a, bits);
+}
+
+
+static int icbrt_with_bits(a, bits)
+ int a;
+ int bits; /* log 2 of a */
+{
+ return icbrt_with_guess(a, a>>2*bits/3);
+}
+
+#ifdef _X_ROOT_STATS
+int icbrt_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) */
+
+/*
+ * Quick and dirty cube roots. Nothing fancy here, just Newton's method.
+ * Only works for positive integers (since that's all we need).
+ * We actually return floor(cbrt(a)) because that's what we need here, too.
+ */
+
+static int icbrt_with_guess(a, guess)
+ int a, guess;
+{
+ register int delta;
+
+#ifdef _X_ROOT_STATS
+ icbrt_loopcount = 0;
+#endif
+ if (a <= 0)
+ return 0;
+ if (guess < 1)
+ guess = 1;
+
+ do {
+#ifdef _X_ROOT_STATS
+ icbrt_loopcount++;
+#endif
+ delta = (guess - a/(guess*guess))/3;
+#ifdef DEBUG
+ printf("pass %d: guess=%d, delta=%d\n", icbrt_loopcount, guess, delta);
+#endif
+ guess -= delta;
+ } while (delta != 0);
+
+ if (guess*guess*guess > a)
+ guess--;
+
+ return guess;
+}
diff --git a/src/CrCmap.c b/src/CrCmap.c
new file mode 100644
index 0000000..ab3d0a6
--- /dev/null
+++ b/src/CrCmap.c
@@ -0,0 +1,523 @@
+/* $Xorg: CrCmap.c,v 1.4 2001/02/09 02:03:51 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.
+
+*/
+
+/*
+ * Author: Donna Converse, MIT X Consortium
+ */
+
+/*
+ * CreateCmap.c - given a standard colormap description, make the map.
+ */
+
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+extern char *calloc();
+
+static int ROmap(); /* allocate entire map Read Only */
+static Status ROorRWcell(); /* allocate a cell, prefer Read Only */
+static Status RWcell(); /* allocate a cell Read Write */
+static int compare(); /* for quicksort */
+static Status contiguous(); /* find contiguous sequence of cells */
+static void free_cells(); /* frees resources before quitting */
+static Status readonly_map(); /* create a map in a RO visual type */
+static Status readwrite_map(); /* create a map in a RW visual type */
+
+#define lowbit(x) ((x) & (~(x) + 1))
+#define TRUEMATCH(mult,max,mask) \
+ (colormap->max * colormap->mult <= vinfo->mask && \
+ lowbit(vinfo->mask) == colormap->mult)
+
+/*
+ * To create any one colormap which is described by an XStandardColormap
+ * structure, use XmuCreateColormap().
+ *
+ * Return 0 on failure, non-zero on success.
+ * Resources created by this function are not made permanent.
+ * No argument error checking is provided. Use at your own risk.
+ *
+ * All colormaps are created with read only allocations, with the exception
+ * of read only allocations of colors in the default map or otherwise
+ * which fail to return the expected pixel value, and these are individually
+ * defined as read/write allocations. This is done so that all the cells
+ * defined in the default map are contiguous, for use in image processing.
+ * This typically happens with White and Black in the default map.
+ *
+ * Colormaps of static visuals are considered to be successfully created if
+ * the map of the static visual matches the definition given in the
+ * standard colormap structure.
+ */
+
+Status XmuCreateColormap(dpy, colormap)
+ Display *dpy; /* specifies the connection under
+ * which the map is created */
+ XStandardColormap *colormap; /* specifies the map to be created,
+ * and returns, particularly if the
+ * map is created as a subset of the
+ * default colormap of the screen,
+ * the base_pixel of the map.
+ */
+{
+ XVisualInfo vinfo_template; /* template visual information */
+ XVisualInfo *vinfo; /* matching visual information */
+ XVisualInfo *vpointer; /* for freeing the entire list */
+ long vinfo_mask; /* specifies the visual mask value */
+ int n; /* number of matching visuals */
+ int status;
+
+ vinfo_template.visualid = colormap->visualid;
+ vinfo_mask = VisualIDMask;
+ if ((vinfo = XGetVisualInfo(dpy, vinfo_mask, &vinfo_template, &n)) == NULL)
+ return 0;
+
+ /* A visual id may be valid on multiple screens. Also, there may
+ * be multiple visuals with identical visual ids at different depths.
+ * If the colormap is the Default Colormap, use the Default Visual.
+ * Otherwise, arbitrarily, use the deepest visual.
+ */
+ vpointer = vinfo;
+ if (n > 1)
+ {
+ register int i;
+ register int screen_number;
+ Bool def_cmap;
+
+ def_cmap = False;
+ for (screen_number = ScreenCount(dpy); --screen_number >= 0; )
+ if (colormap->colormap == DefaultColormap(dpy, screen_number)) {
+ def_cmap = True;
+ break;
+ }
+
+ if (def_cmap) {
+ for (i=0; i < n; i++, vinfo++) {
+ if (vinfo->visual == DefaultVisual(dpy, screen_number))
+ break;
+ }
+ } else {
+ unsigned int maxdepth = 0;
+ XVisualInfo *v;
+
+ for (i=0; i < n; i++, vinfo++)
+ if (vinfo->depth > maxdepth) {
+ maxdepth = vinfo->depth;
+ v = vinfo;
+ }
+ vinfo = v;
+ }
+ }
+
+ if (vinfo->class == PseudoColor || vinfo->class == DirectColor ||
+ vinfo->class == GrayScale)
+ status = readwrite_map(dpy, vinfo, colormap);
+ else if (vinfo->class == TrueColor)
+ status = TRUEMATCH(red_mult, red_max, red_mask) &&
+ TRUEMATCH(green_mult, green_max, green_mask) &&
+ TRUEMATCH(blue_mult, blue_max, blue_mask);
+ else
+ status = readonly_map(dpy, vinfo, colormap);
+
+ XFree((char *) vpointer);
+ return status;
+}
+
+/****************************************************************************/
+static Status readwrite_map(dpy, vinfo, colormap)
+ Display *dpy;
+ XVisualInfo *vinfo;
+ XStandardColormap *colormap;
+{
+ register unsigned long i, n; /* index counters */
+ int ncolors; /* number of colors to be defined */
+ int npixels; /* number of pixels allocated R/W */
+ int first_index; /* first index of pixels to use */
+ int remainder; /* first index of remainder */
+ XColor color; /* the definition of a color */
+ unsigned long *pixels; /* array of colormap pixels */
+ unsigned long delta;
+
+
+ /* Determine ncolors, the number of colors to be defined.
+ * Insure that 1 < ncolors <= the colormap size.
+ */
+ if (vinfo->class == DirectColor) {
+ ncolors = colormap->red_max;
+ if (colormap->green_max > ncolors)
+ ncolors = colormap->green_max;
+ if (colormap->blue_max > ncolors)
+ ncolors = colormap->blue_max;
+ ncolors++;
+ delta = lowbit(vinfo->red_mask) +
+ lowbit(vinfo->green_mask) +
+ lowbit(vinfo->blue_mask);
+ } else {
+ ncolors = colormap->red_max * colormap->red_mult +
+ colormap->green_max * colormap->green_mult +
+ colormap->blue_max * colormap->blue_mult + 1;
+ delta = 1;
+ }
+ if (ncolors <= 1 || ncolors > vinfo->colormap_size) return 0;
+
+ /* Allocate Read/Write as much of the colormap as we can possibly get.
+ * Then insure that the pixels we were allocated are given in
+ * monotonically increasing order, using a quicksort. Next, insure
+ * that our allocation includes a subset of contiguous pixels at least
+ * as long as the number of colors to be defined. Now we know that
+ * these conditions are met:
+ * 1) There are no free cells in the colormap.
+ * 2) We have a contiguous sequence of pixels, monotonically
+ * increasing, of length >= the number of colors requested.
+ *
+ * One cell at a time, we will free, compute the next color value,
+ * then allocate read only. This takes a long time.
+ * This is done to insure that cells are allocated read only in the
+ * contiguous order which we prefer. If the server has a choice of
+ * cells to grant to an allocation request, the server may give us any
+ * cell, so that is why we do these slow gymnastics.
+ */
+
+ if ((pixels = (unsigned long *) calloc((unsigned) vinfo->colormap_size,
+ sizeof(unsigned long))) == NULL)
+ return 0;
+
+ if ((npixels = ROmap(dpy, colormap->colormap, pixels,
+ vinfo->colormap_size, ncolors)) == 0) {
+ free((char *) pixels);
+ return 0;
+ }
+
+ qsort((char *) pixels, npixels, sizeof(unsigned long), compare);
+
+ if (!contiguous(pixels, npixels, ncolors, delta, &first_index, &remainder))
+ {
+ /* can't find enough contiguous cells, give up */
+ XFreeColors(dpy, colormap->colormap, pixels, npixels,
+ (unsigned long) 0);
+ free((char *) pixels);
+ return 0;
+ }
+ colormap->base_pixel = pixels[first_index];
+
+ /* construct a gray map */
+ if (colormap->red_mult == 1 && colormap->green_mult == 1 &&
+ colormap->blue_mult == 1)
+ for (n=colormap->base_pixel, i=0; i < ncolors; i++, n += delta)
+ {
+ color.pixel = n;
+ color.blue = color.green = color.red =
+ (unsigned short) ((i * 65535) / (colormap->red_max +
+ colormap->green_max +
+ colormap->blue_max));
+
+ if (! ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color,
+ first_index + i))
+ return 0;
+ }
+
+ /* construct a red ramp map */
+ else if (colormap->green_max == 0 && colormap->blue_max == 0)
+ for (n=colormap->base_pixel, i=0; i < ncolors; i++, n += delta)
+ {
+ color.pixel = n;
+ color.red = (unsigned short) ((i * 65535) / colormap->red_max);
+ color.green = color.blue = 0;
+
+ if (! ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color,
+ first_index + i))
+ return 0;
+ }
+
+ /* construct a green ramp map */
+ else if (colormap->red_max == 0 && colormap->blue_max == 0)
+ for (n=colormap->base_pixel, i=0; i < ncolors; i++, n += delta)
+ {
+ color.pixel = n;
+ color.green = (unsigned short) ((i * 65535) / colormap->green_max);
+ color.red = color.blue = 0;
+
+ if (! ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color,
+ first_index + i))
+ return 0;
+ }
+
+ /* construct a blue ramp map */
+ else if (colormap->red_max == 0 && colormap->green_max == 0)
+ for (n=colormap->base_pixel, i=0; i < ncolors; i++, n += delta)
+ {
+ color.pixel = n;
+ color.blue = (unsigned short) ((i * 65535) / colormap->blue_max);
+ color.red = color.green = 0;
+
+ if (! ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color,
+ first_index + i))
+ return 0;
+ }
+
+ /* construct a standard red green blue cube map */
+ else
+ {
+#define calc(max,mult) (((n / colormap->mult) % \
+ (colormap->max + 1)) * 65535) / colormap->max
+
+ for (n=0, i=0; i < ncolors; i++, n += delta)
+ {
+ color.pixel = n + colormap->base_pixel;
+ color.red = calc(red_max, red_mult);
+ color.green = calc(green_max, green_mult);
+ color.blue = calc(blue_max, blue_mult);
+ if (! ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color,
+ first_index + i))
+ return 0;
+ }
+#undef calc
+ }
+ /* We have a read-only map defined. Now free unused cells,
+ * first those occuring before the contiguous sequence begins,
+ * then any following the contiguous sequence.
+ */
+
+ if (first_index)
+ XFreeColors(dpy, colormap->colormap, pixels, first_index,
+ (unsigned long) 0);
+ if (remainder)
+ XFreeColors(dpy, colormap->colormap,
+ &(pixels[first_index + ncolors]), remainder,
+ (unsigned long) 0);
+
+ free((char *) pixels);
+ return 1;
+}
+
+
+/****************************************************************************/
+static int ROmap(dpy, cmap, pixels, m, n)
+ Display *dpy; /* the X server connection */
+ Colormap cmap; /* specifies colormap ID */
+ unsigned long pixels[]; /* returns pixel allocations */
+ int m; /* specifies colormap size */
+ int n; /* specifies number of colors */
+{
+ register int p;
+
+ /* first try to allocate the entire colormap */
+ if (XAllocColorCells(dpy, cmap, 1, (unsigned long *) NULL,
+ (unsigned) 0, pixels, (unsigned) m))
+ return m;
+
+ /* Allocate all available cells in the colormap, using a binary
+ * algorithm to discover how many cells we can allocate in the colormap.
+ */
+ m--;
+ while (n <= m) {
+ p = n + ((m - n + 1) / 2);
+ if (XAllocColorCells(dpy, cmap, 1, (unsigned long *) NULL,
+ (unsigned) 0, pixels, (unsigned) p)) {
+ if (p == m)
+ return p;
+ else {
+ XFreeColors(dpy, cmap, pixels, p, (unsigned long) 0);
+ n = p;
+ }
+ }
+ else
+ m = p - 1;
+ }
+ return 0;
+}
+
+
+/****************************************************************************/
+static Status contiguous(pixels, npixels, ncolors, delta, first, rem)
+ unsigned long pixels[]; /* specifies allocated pixels */
+ int npixels; /* specifies count of alloc'd pixels */
+ int ncolors; /* specifies needed sequence length */
+ unsigned long delta; /* between pixels */
+ int *first; /* returns first index of sequence */
+ int *rem; /* returns first index after sequence,
+ * or 0, if none follow */
+{
+ register int i = 1; /* walking index into the pixel array */
+ register int count = 1; /* length of sequence discovered so far */
+
+ *first = 0;
+ if (npixels == ncolors) {
+ *rem = 0;
+ return 1;
+ }
+ *rem = npixels - 1;
+ while (count < ncolors && ncolors - count <= *rem)
+ {
+ if (pixels[i-1] + delta == pixels[i])
+ count++;
+ else {
+ count = 1;
+ *first = i;
+ }
+ i++;
+ (*rem)--;
+ }
+ if (count != ncolors)
+ return 0;
+ return 1;
+}
+
+
+/****************************************************************************/
+static Status ROorRWcell(dpy, cmap, pixels, npixels, color, p)
+ Display *dpy;
+ Colormap cmap;
+ unsigned long pixels[];
+ int npixels;
+ XColor *color;
+ unsigned long p;
+{
+ unsigned long pixel;
+ XColor request;
+
+ /* Free the read/write allocation of one cell in the colormap.
+ * Request a read only allocation of one cell in the colormap.
+ * If the read only allocation cannot be granted, give up, because
+ * there must be no free cells in the colormap.
+ * If the read only allocation is granted, but gives us a cell which
+ * is not the one that we just freed, it is probably the case that
+ * we are trying allocate White or Black or some other color which
+ * already has a read-only allocation in the map. So we try to
+ * allocate the previously freed cell with a read/write allocation,
+ * because we want contiguous cells for image processing algorithms.
+ */
+
+ pixel = color->pixel;
+ request.red = color->red;
+ request.green = color->green;
+ request.blue = color->blue;
+
+ XFreeColors(dpy, cmap, &pixel, 1, (unsigned long) 0);
+ if (! XAllocColor(dpy, cmap, color)
+ || (color->pixel != pixel &&
+ (!RWcell(dpy, cmap, color, &request, &pixel))))
+ {
+ free_cells(dpy, cmap, pixels, npixels, (int)p);
+ return 0;
+ }
+ return 1;
+}
+
+
+/****************************************************************************/
+static void free_cells(dpy, cmap, pixels, npixels, p)
+ Display *dpy;
+ Colormap cmap;
+ unsigned long pixels[]; /* to be freed */
+ int npixels; /* original number allocated */
+ int p;
+{
+ /* One of the npixels allocated has already been freed.
+ * p is the index of the freed pixel.
+ * First free the pixels preceeding p, and there are p of them;
+ * then free the pixels following p, there are npixels - p - 1 of them.
+ */
+ XFreeColors(dpy, cmap, pixels, p, (unsigned long) 0);
+ XFreeColors(dpy, cmap, &(pixels[p+1]), npixels - p - 1, (unsigned long) 0);
+ free((char *) pixels);
+}
+
+
+/****************************************************************************/
+static Status RWcell(dpy, cmap, color, request, pixel)
+ Display *dpy;
+ Colormap cmap;
+ XColor *color;
+ XColor *request;
+ unsigned long *pixel;
+{
+ unsigned long n = *pixel;
+
+ XFreeColors(dpy, cmap, &(color->pixel), 1, (unsigned long)0);
+ if (! XAllocColorCells(dpy, cmap, (Bool) 0, (unsigned long *) NULL,
+ (unsigned) 0, pixel, (unsigned) 1))
+ return 0;
+ if (*pixel != n)
+ {
+ XFreeColors(dpy, cmap, pixel, 1, (unsigned long) 0);
+ return 0;
+ }
+ color->pixel = *pixel;
+ color->flags = DoRed | DoGreen | DoBlue;
+ color->red = request->red;
+ color->green = request->green;
+ color->blue = request->blue;
+ XStoreColors(dpy, cmap, color, 1);
+ return 1;
+}
+
+
+/****************************************************************************/
+static int compare(e1, e2)
+ unsigned long *e1, *e2;
+{
+ if (*e1 < *e2) return -1;
+ if (*e1 > *e2) return 1;
+ return 0;
+}
+
+
+/****************************************************************************/
+static Status readonly_map(dpy, vinfo, colormap)
+ Display *dpy;
+ XVisualInfo *vinfo;
+ XStandardColormap *colormap;
+{
+ int i, last_pixel;
+ XColor color;
+
+ last_pixel = (colormap->red_max + 1) * (colormap->green_max + 1) *
+ (colormap->blue_max + 1) + colormap->base_pixel - 1;
+
+ for(i=colormap->base_pixel; i <= last_pixel; i++) {
+
+ color.pixel = (unsigned long) i;
+ color.red = (unsigned short)
+ (((i/colormap->red_mult) * 65535) / colormap->red_max);
+
+ if (vinfo->class == StaticColor) {
+ color.green = (unsigned short)
+ ((((i/colormap->green_mult) % (colormap->green_max + 1)) *
+ 65535) / colormap->green_max);
+ color.blue = (unsigned short)
+ (((i%colormap->green_mult) * 65535) / colormap->blue_max);
+ }
+ else /* vinfo->class == GrayScale, old style allocation XXX */
+ color.green = color.blue = color.red;
+
+ XAllocColor(dpy, colormap->colormap, &color);
+ if (color.pixel != (unsigned long) i)
+ return 0;
+ }
+ return 1;
+}
diff --git a/src/CrPixFBit.c b/src/CrPixFBit.c
new file mode 100644
index 0000000..ac736b1
--- /dev/null
+++ b/src/CrPixFBit.c
@@ -0,0 +1,75 @@
+/* $Xorg: CrPixFBit.c,v 1.4 2001/02/09 02:03:51 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.
+
+*/
+
+/*
+ * This file contains miscellaneous utility routines and is not part of the
+ * Xlib standard.
+ */
+
+/*
+ * Public entry points:
+ *
+ * XmuCreatePixmapFromBitmap make a pixmap from a bitmap
+ */
+
+#include <X11/Xos.h>
+#include <X11/Xlib.h>
+
+Pixmap XmuCreatePixmapFromBitmap (dpy, d, bitmap, width, height, depth,
+ fore, back)
+ Display *dpy; /* connection to X server */
+ Drawable d; /* drawable indicating screen */
+ Pixmap bitmap; /* single plane pixmap */
+ unsigned int width, height; /* dimensions of bitmap and pixmap */
+ unsigned int depth; /* depth of pixmap to create */
+ unsigned long fore, back; /* colors to use */
+{
+ Pixmap pixmap;
+
+ pixmap = XCreatePixmap (dpy, d, width, height, depth);
+ if (pixmap != None) {
+ GC gc;
+ XGCValues xgcv;
+
+ xgcv.foreground = fore;
+ xgcv.background = back;
+ xgcv.graphics_exposures = False;
+
+ gc = XCreateGC (dpy, d,
+ (GCForeground | GCBackground | GCGraphicsExposures),
+ &xgcv);
+ if (gc) {
+ XCopyPlane (dpy, bitmap, pixmap, gc, 0, 0, width, height, 0, 0, 1);
+ XFreeGC (dpy, gc);
+ } else {
+ XFreePixmap (dpy, pixmap);
+ pixmap = None;
+ }
+ }
+ return pixmap;
+}
diff --git a/src/CursorName.c b/src/CursorName.c
new file mode 100644
index 0000000..34449fc
--- /dev/null
+++ b/src/CursorName.c
@@ -0,0 +1,146 @@
+/* $Xorg: CursorName.c,v 1.4 2001/02/09 02:03:51 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/Intrinsic.h>
+#include <X11/Xmu/CharSet.h>
+#include <X11/Xmu/CurUtil.h>
+#include <X11/cursorfont.h>
+
+#ifdef __STDC__
+#define Const const
+#else
+#define Const /**/
+#endif
+
+#if NeedFunctionPrototypes
+int XmuCursorNameToIndex (_Xconst char *name)
+#else
+int XmuCursorNameToIndex (name)
+ char *name;
+#endif
+{
+ static Const struct _CursorName {
+ Const char *name;
+ unsigned int shape;
+ } cursor_names[] = {
+ {"x_cursor", XC_X_cursor},
+ {"arrow", XC_arrow},
+ {"based_arrow_down", XC_based_arrow_down},
+ {"based_arrow_up", XC_based_arrow_up},
+ {"boat", XC_boat},
+ {"bogosity", XC_bogosity},
+ {"bottom_left_corner", XC_bottom_left_corner},
+ {"bottom_right_corner", XC_bottom_right_corner},
+ {"bottom_side", XC_bottom_side},
+ {"bottom_tee", XC_bottom_tee},
+ {"box_spiral", XC_box_spiral},
+ {"center_ptr", XC_center_ptr},
+ {"circle", XC_circle},
+ {"clock", XC_clock},
+ {"coffee_mug", XC_coffee_mug},
+ {"cross", XC_cross},
+ {"cross_reverse", XC_cross_reverse},
+ {"crosshair", XC_crosshair},
+ {"diamond_cross", XC_diamond_cross},
+ {"dot", XC_dot},
+ {"dotbox", XC_dotbox},
+ {"double_arrow", XC_double_arrow},
+ {"draft_large", XC_draft_large},
+ {"draft_small", XC_draft_small},
+ {"draped_box", XC_draped_box},
+ {"exchange", XC_exchange},
+ {"fleur", XC_fleur},
+ {"gobbler", XC_gobbler},
+ {"gumby", XC_gumby},
+ {"hand1", XC_hand1},
+ {"hand2", XC_hand2},
+ {"heart", XC_heart},
+ {"icon", XC_icon},
+ {"iron_cross", XC_iron_cross},
+ {"left_ptr", XC_left_ptr},
+ {"left_side", XC_left_side},
+ {"left_tee", XC_left_tee},
+ {"leftbutton", XC_leftbutton},
+ {"ll_angle", XC_ll_angle},
+ {"lr_angle", XC_lr_angle},
+ {"man", XC_man},
+ {"middlebutton", XC_middlebutton},
+ {"mouse", XC_mouse},
+ {"pencil", XC_pencil},
+ {"pirate", XC_pirate},
+ {"plus", XC_plus},
+ {"question_arrow", XC_question_arrow},
+ {"right_ptr", XC_right_ptr},
+ {"right_side", XC_right_side},
+ {"right_tee", XC_right_tee},
+ {"rightbutton", XC_rightbutton},
+ {"rtl_logo", XC_rtl_logo},
+ {"sailboat", XC_sailboat},
+ {"sb_down_arrow", XC_sb_down_arrow},
+ {"sb_h_double_arrow", XC_sb_h_double_arrow},
+ {"sb_left_arrow", XC_sb_left_arrow},
+ {"sb_right_arrow", XC_sb_right_arrow},
+ {"sb_up_arrow", XC_sb_up_arrow},
+ {"sb_v_double_arrow", XC_sb_v_double_arrow},
+ {"shuttle", XC_shuttle},
+ {"sizing", XC_sizing},
+ {"spider", XC_spider},
+ {"spraycan", XC_spraycan},
+ {"star", XC_star},
+ {"target", XC_target},
+ {"tcross", XC_tcross},
+ {"top_left_arrow", XC_top_left_arrow},
+ {"top_left_corner", XC_top_left_corner},
+ {"top_right_corner", XC_top_right_corner},
+ {"top_side", XC_top_side},
+ {"top_tee", XC_top_tee},
+ {"trek", XC_trek},
+ {"ul_angle", XC_ul_angle},
+ {"umbrella", XC_umbrella},
+ {"ur_angle", XC_ur_angle},
+ {"watch", XC_watch},
+ {"xterm", XC_xterm},
+ };
+ register Const struct _CursorName *table;
+ register int i;
+ char tmp[40];
+
+ if (strlen (name) >= sizeof tmp) return -1;
+ XmuCopyISOLatin1Lowered (tmp, name);
+
+ for (i=0, table=cursor_names; i < XtNumber(cursor_names); i++, table++ ) {
+ if (strcmp(tmp, table->name) == 0) return table->shape;
+ }
+
+ return -1;
+}
+
+
+
+
+
diff --git a/src/CvtCache.c b/src/CvtCache.c
new file mode 100644
index 0000000..0239b3e
--- /dev/null
+++ b/src/CvtCache.c
@@ -0,0 +1,128 @@
+/* $Xorg: CvtCache.c,v 1.5 2001/02/09 02:03:52 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.
+
+*/
+
+/*
+ * Author: Jim Fulton, MIT X Consortium
+ */
+
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/Xos.h>
+#include <X11/Xmu/CvtCache.h>
+
+extern char *malloc();
+
+static XmuDisplayQueue *dq = NULL;
+static int _CloseDisplay(), _FreeCCDQ();
+
+
+
+/*
+ * internal utility callbacks
+ */
+
+_FreeCCDQ (q)
+ XmuDisplayQueue *q;
+{
+ XmuDQDestroy (dq, False);
+ dq = NULL;
+}
+
+
+static int _CloseDisplay (q, e)
+ XmuDisplayQueue *q;
+ XmuDisplayQueueEntry *e;
+{
+ XmuCvtCache *c;
+ extern void _XmuStringToBitmapFreeCache();
+
+ if (e && (c = (XmuCvtCache *)(e->data))) {
+ _XmuStringToBitmapFreeCache (c);
+ /* insert calls to free any cached memory */
+
+ }
+ return 0;
+}
+
+static void _InitializeCvtCache (c)
+ register XmuCvtCache *c;
+{
+ extern void _XmuStringToBitmapInitCache();
+
+ _XmuStringToBitmapInitCache (c);
+ /* insert calls to init any cached memory */
+}
+
+
+/*
+ * XmuCCLookupDisplay - return the cache entry for the indicated display;
+ * initialize the cache if necessary
+ */
+XmuCvtCache *_XmuCCLookupDisplay (dpy)
+ Display *dpy;
+{
+ XmuDisplayQueueEntry *e;
+
+ /*
+ * If no displays have been added before this, create the display queue.
+ */
+ if (!dq) {
+ dq = XmuDQCreate (_CloseDisplay, _FreeCCDQ, NULL);
+ if (!dq) return NULL;
+ }
+
+ /*
+ * See if the display is already there
+ */
+ e = XmuDQLookupDisplay (dq, dpy); /* see if it's there */
+ if (!e) { /* else create it */
+ XmuCvtCache *c = (XmuCvtCache *) malloc (sizeof (XmuCvtCache));
+ if (!c) return NULL;
+
+ /*
+ * Add the display to the queue
+ */
+ e = XmuDQAddDisplay (dq, dpy, (XPointer) c);
+ if (!e) {
+ free ((char *) c);
+ return NULL;
+ }
+
+ /*
+ * initialize fields in cache
+ */
+ _InitializeCvtCache (c);
+ }
+
+ /*
+ * got it
+ */
+ return (XmuCvtCache *)(e->data);
+}
+
+
diff --git a/src/CvtStdSel.c b/src/CvtStdSel.c
new file mode 100644
index 0000000..9c2eb07
--- /dev/null
+++ b/src/CvtStdSel.c
@@ -0,0 +1,329 @@
+/* $Xorg: CvtStdSel.c,v 1.4 2001/02/09 02:03:52 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.
+
+*/
+
+/*
+ * This file contains routines to handle common selection targets.
+ *
+ * Public entry points:
+ *
+ * XmuConvertStandardSelection() return a known selection
+ */
+
+#ifdef SYSVNET
+#include <interlan/il_types.h>
+#define __TYPES__ /* prevent #include <sys/types.h> in Xlib.h */
+#include <interlan/netdb.h>
+#include <interlan/socket.h>
+#endif /* SYSVNET */
+
+#include <X11/IntrinsicP.h>
+#include <X11/Xatom.h>
+#include <X11/ShellP.h>
+#ifdef XTHREADS
+#include <X11/Xthreads.h>
+#endif
+#include <stdio.h>
+
+#ifndef SYSVNET
+#ifdef WIN32
+#include <X11/Xwinsock.h>
+#define XOS_USE_MTSAFE_NETDBAPI
+#else
+#include <sys/socket.h>
+#define XOS_USE_XT_LOCKING
+#endif
+#define X_INCLUDE_NETDB_H
+#include <X11/Xos_r.h>
+#endif
+
+#include <X11/Xos.h>
+#include "Atoms.h"
+#include "StdSel.h"
+#include "SysUtil.h"
+#include <X11/Xfuncs.h>
+
+#ifndef OS_NAME
+#ifndef X_OS_FILE
+#ifdef SYSV /* keep separate until makedepend fixed */
+#define USE_UNAME
+#endif
+#ifdef SVR4
+#define USE_UNAME
+#endif
+#ifdef ultrix
+#define USE_UNAME
+#endif
+#endif /*X_OS_FILE*/
+#ifdef USE_UNAME
+#ifdef ultrix
+#ifndef __STDC__
+#include <limits.h> /* fixed in Ultrix 3.0 */
+#endif
+#endif
+#include <sys/utsname.h>
+#endif
+#endif
+
+static char *get_os_name ()
+{
+#ifdef OS_NAME
+ return XtNewString(OS_NAME);
+#else
+ FILE *f = NULL;
+
+#ifdef USE_UNAME
+ struct utsname utss;
+
+ if (uname (&utss) == 0) {
+ char *os_name;
+ int len = strlen(utss.sysname);
+#ifndef hpux /* because of hostname length crock */
+ len += 1 + strlen(utss.release);
+#endif
+ os_name = XtMalloc (len);
+ strcpy (os_name, utss.sysname);
+#ifndef hpux
+ strcat (os_name, " ");
+ strcat (os_name, utss.release);
+#endif
+ return os_name;
+ }
+#endif
+
+#ifdef X_OS_FILE
+ f = fopen(X_OS_FILE, "r");
+ if (!f)
+#endif
+#ifdef MOTD_FILE
+ f = fopen(MOTD_FILE, "r");
+#endif
+ if (f) {
+ char motd[512];
+ motd[0] = '\0';
+ (void) fgets(motd, 511, f);
+ fclose(f);
+ motd[511] = '\0';
+ if (motd[0] != '\0') {
+ int len = strlen(motd);
+ if (motd[len - 1] == '\n')
+ motd[len - 1] = '\0';
+ return XtNewString(motd);
+ }
+ }
+
+#ifdef sun
+ return XtNewString("SunOS");
+#else
+# if !defined(SYSV) && defined(unix)
+ return XtNewString("BSD");
+# else
+ return NULL;
+# endif
+#endif
+
+#endif /*OS_NAME*/
+}
+
+/* This is a trick/kludge. To make shared libraries happier (linking
+ * against Xmu but not linking against Xt, and apparently even work
+ * as we desire on SVR4, we need to avoid an explicit data reference
+ * to applicationShellWidgetClass. XtIsTopLevelShell is known
+ * (implementation dependent assumption!) to use a bit flag. So we
+ * go that far. Then, we test whether it is an applicationShellWidget
+ * class by looking for an explicit class name. Seems pretty safe.
+ */
+static Bool isApplicationShell(w)
+ Widget w;
+{
+ register WidgetClass c;
+
+ if (!XtIsTopLevelShell(w))
+ return False;
+ for (c = XtClass(w); c; c = c->core_class.superclass) {
+ if (!strcmp(c->core_class.class_name, "ApplicationShell"))
+ return True;
+ }
+ return False;
+}
+
+Boolean XmuConvertStandardSelection(w, time, selection, target,
+ type, value, length, format)
+ Widget w;
+ Time time;
+ Atom *selection, *target, *type;
+ XPointer *value;
+ unsigned long *length;
+ int *format;
+{
+ Display *d = XtDisplay(w);
+ if (*target == XA_TIMESTAMP(d)) {
+ *value = XtMalloc(4);
+ if (sizeof(long) == 4)
+ *(long*)*value = time;
+ else {
+ long temp = time;
+ (void) memmove((char*)*value, ((char*)&temp)+sizeof(long)-4, 4);
+ }
+ *type = XA_INTEGER;
+ *length = 1;
+ *format = 32;
+ return True;
+ }
+ if (*target == XA_HOSTNAME(d)) {
+ char hostname[1024];
+ hostname[0] = '\0';
+ *length = XmuGetHostname (hostname, sizeof hostname);
+ *value = XtNewString(hostname);
+ *type = XA_STRING;
+ *format = 8;
+ return True;
+ }
+#ifdef TCPCONN
+ if (*target == XA_IP_ADDRESS(d)) {
+ char hostname[1024];
+ _Xgethostbynameparams hparams;
+ struct hostent *hostp;
+
+ hostname[0] = '\0';
+ (void) XmuGetHostname (hostname, sizeof hostname);
+
+ if ((hostp = _XGethostbyname (hostname,hparams)) == NULL)
+ return False;
+
+ if (hostp->h_addrtype != AF_INET) return False;
+ *length = hostp->h_length;
+ *value = XtMalloc(*length);
+ (void) memmove (*value, hostp->h_addr, *length);
+ *type = XA_NET_ADDRESS(d);
+ *format = 8;
+ return True;
+ }
+#endif
+#ifdef DNETCONN
+ if (*target == XA_DECNET_ADDRESS(d)) {
+ return False; /* XXX niy */
+ }
+#endif
+ if (*target == XA_USER(d)) {
+ char *name = (char*)getenv("USER");
+ if (name == NULL) return False;
+ *value = XtNewString(name);
+ *type = XA_STRING;
+ *length = strlen(name);
+ *format = 8;
+ return True;
+ }
+ if (*target == XA_CLASS(d)) {
+ Widget parent = XtParent(w);
+ char *class;
+ int len;
+ while (parent != NULL && !isApplicationShell(w)) {
+ w = parent;
+ parent = XtParent(w);
+ }
+ if (isApplicationShell(w))
+ class = ((ApplicationShellWidget) w)->application.class;
+ else
+ class = XtClass(w)->core_class.class_name;
+ *length = (len=strlen(w->core.name)) + strlen(class) + 2;
+ *value = XtMalloc(*length);
+ strcpy( (char*)*value, w->core.name );
+ strcpy( (char*)*value+len+1, class );
+ *type = XA_STRING;
+ *format = 8;
+ return True;
+ }
+ if (*target == XA_NAME(d)) {
+ Widget parent = XtParent(w);
+
+ while (parent != NULL && !XtIsWMShell(w)) {
+ w = parent;
+ parent = XtParent(w);
+ }
+ if (!XtIsWMShell(w)) return False;
+ *value = XtNewString( ((WMShellWidget) w)->wm.title );
+ *length = strlen(*value);
+ *type = XA_STRING;
+ *format = 8;
+ return True;
+ }
+ if (*target == XA_CLIENT_WINDOW(d)) {
+ Widget parent = XtParent(w);
+ while (parent != NULL) {
+ w = parent;
+ parent = XtParent(w);
+ }
+ *value = XtMalloc(sizeof(Window));
+ *(Window*)*value = w->core.window;
+ *type = XA_WINDOW;
+ *length = 1;
+ *format = 32;
+ return True;
+ }
+ if (*target == XA_OWNER_OS(d)) {
+ *value = get_os_name();
+ if (*value == NULL) return False;
+ *type = XA_STRING;
+ *length = strlen(*value);
+ *format = 8;
+ return True;
+ }
+ if (*target == XA_TARGETS(d)) {
+#if defined(unix) && defined(DNETCONN)
+# define NUM_TARGETS 9
+#else
+# if defined(unix) || defined(DNETCONN)
+# define NUM_TARGETS 8
+# else
+# define NUM_TARGETS 7
+# endif
+#endif
+ Atom* std_targets = (Atom*)XtMalloc(NUM_TARGETS*sizeof(Atom));
+ int i = 0;
+ std_targets[i++] = XA_TIMESTAMP(d);
+ std_targets[i++] = XA_HOSTNAME(d);
+ std_targets[i++] = XA_IP_ADDRESS(d);
+ std_targets[i++] = XA_USER(d);
+ std_targets[i++] = XA_CLASS(d);
+ std_targets[i++] = XA_NAME(d);
+ std_targets[i++] = XA_CLIENT_WINDOW(d);
+#ifdef unix
+ std_targets[i++] = XA_OWNER_OS(d);
+#endif
+#ifdef DNETCONN
+ std_targets[i++] = XA_DECNET_ADDRESS(d);
+#endif
+ *value = (XPointer)std_targets;
+ *type = XA_ATOM;
+ *length = NUM_TARGETS;
+ *format = 32;
+ return True;
+ }
+ /* else */
+ return False;
+}
diff --git a/src/DefErrMsg.c b/src/DefErrMsg.c
new file mode 100644
index 0000000..98d4392
--- /dev/null
+++ b/src/DefErrMsg.c
@@ -0,0 +1,169 @@
+/* $Xorg: DefErrMsg.c,v 1.4 2001/02/09 02:03:52 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 <stdio.h>
+#define NEED_EVENTS
+#include <X11/Xlibint.h>
+#include <X11/Xproto.h>
+
+/*
+ * XmuPrintDefaultErrorMessage - print a nice error that looks like the usual
+ * message. Returns 1 if the caller should consider exitting else 0.
+ */
+int XmuPrintDefaultErrorMessage (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 {
+ /* XXX this is non-portable */
+ 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)", buffer);
+ fputs("\n ", fp);
+ if (event->request_code >= 128) {
+ XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d",
+ mesg, BUFSIZ);
+ (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 < 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);
+ (void) fprintf(fp, mesg, event->resourceid);
+ fputs("\n ", fp);
+ }
+ XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d",
+ mesg, BUFSIZ);
+ (void) fprintf(fp, mesg, event->serial);
+ fputs("\n ", fp);
+ XGetErrorDatabaseText(dpy, mtype, "CurrentSerial", "Current Serial #%d",
+ mesg, BUFSIZ);
+ (void) fprintf(fp, mesg, NextRequest(dpy)-1);
+ fputs("\n", fp);
+ if (event->error_code == BadImplementation) return 0;
+ return 1;
+}
+
+
+/*
+ * XmuSimpleErrorHandler - ignore errors for XQueryTree, XGetWindowAttributes,
+ * and XGetGeometry; print a message for everything else. In all case, do
+ * not exit.
+ */
+int XmuSimpleErrorHandler (dpy, errorp)
+ Display *dpy;
+ XErrorEvent *errorp;
+{
+ switch (errorp->request_code) {
+ case X_QueryTree:
+ case X_GetWindowAttributes:
+ if (errorp->error_code == BadWindow) return 0;
+ break;
+ case X_GetGeometry:
+ if (errorp->error_code == BadDrawable) return 0;
+ break;
+ }
+ /* got a "real" X error */
+ return XmuPrintDefaultErrorMessage (dpy, errorp, stderr);
+}
diff --git a/src/DelCmap.c b/src/DelCmap.c
new file mode 100644
index 0000000..9ab7717
--- /dev/null
+++ b/src/DelCmap.c
@@ -0,0 +1,66 @@
+/* $Xorg: DelCmap.c,v 1.4 2001/02/09 02:03:52 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.
+
+*/
+
+/*
+ * Author: Donna Converse, MIT X Consortium
+ */
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+/* To remove any standard colormap property, use XmuDeleteStandardColormap().
+ * XmuDeleteStandardColormap() will remove the specified property from the
+ * specified screen, releasing any resources used by the colormap(s) of the
+ * property if possible.
+ */
+
+void XmuDeleteStandardColormap(dpy, screen, property)
+ Display *dpy; /* specifies the X server to connect to */
+ int screen; /* specifies the screen of the display */
+ Atom property; /* specifies the standard colormap property */
+{
+ XStandardColormap *stdcmaps, *s;
+ int count = 0;
+
+ if (XGetRGBColormaps(dpy, RootWindow(dpy, screen), &stdcmaps, &count,
+ property))
+ {
+ for (s=stdcmaps; count > 0; count--, s++) {
+ if ((s->killid == ReleaseByFreeingColormap) &&
+ (s->colormap != None) &&
+ (s->colormap != DefaultColormap(dpy, screen)))
+ XFreeColormap(dpy, s->colormap);
+ else if (s->killid != None)
+ XKillClient(dpy, s->killid);
+ }
+ XDeleteProperty(dpy, RootWindow(dpy, screen), property);
+ XFree((char *) stdcmaps);
+ XSync(dpy, False);
+ }
+}
+
diff --git a/src/DisplayQue.c b/src/DisplayQue.c
new file mode 100644
index 0000000..c96223b
--- /dev/null
+++ b/src/DisplayQue.c
@@ -0,0 +1,193 @@
+/* $Xorg: DisplayQue.c,v 1.4 2001/02/09 02:03:52 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.
+
+*/
+
+/*
+ * Author: Jim Fulton, MIT X Consortium
+ */
+
+#include <stdio.h>
+#include <X11/Xos.h>
+#include <X11/Xlib.h>
+#include <X11/Xmu/DisplayQue.h>
+
+static int _DQCloseDisplay();
+
+#define CallCloseCallback(q,e) (void) (*((q)->closefunc)) ((q), (e))
+#define CallFreeCallback(q) (void) (*((q)->freefunc)) ((q))
+
+/*
+ * XmuDQCreate - create a display queue
+ */
+XmuDisplayQueue *XmuDQCreate (closefunc, freefunc, data)
+ XmuCloseDisplayQueueProc closefunc;
+ XmuFreeDisplayQueueProc freefunc;
+ XPointer data;
+{
+ XmuDisplayQueue *q = (XmuDisplayQueue *) malloc (sizeof (XmuDisplayQueue));
+ if (q) {
+ q->nentries = 0;
+ q->head = q->tail = NULL;
+ q->closefunc = closefunc;
+ q->freefunc = freefunc;
+ q->data = data;
+ }
+ return q;
+}
+
+
+/*
+ * XmuDQDestroy - free all storage associated with this display queue,
+ * optionally invoking the close callbacks.
+ */
+
+Bool XmuDQDestroy (q, docallbacks)
+ XmuDisplayQueue *q;
+ Bool docallbacks;
+{
+ XmuDisplayQueueEntry *e = q->head;
+
+ while (e) {
+ XmuDisplayQueueEntry *nexte = e->next;
+ if (docallbacks && q->closefunc) CallCloseCallback (q, e);
+ free ((char *) e);
+ e = nexte;
+ }
+ free ((char *) q);
+ return True;
+}
+
+
+/*
+ * XmuDQLookupDisplay - finds the indicated display on the given queue
+ */
+XmuDisplayQueueEntry *XmuDQLookupDisplay (q, dpy)
+ XmuDisplayQueue *q;
+ Display *dpy;
+{
+ XmuDisplayQueueEntry *e;
+
+ for (e = q->head; e; e = e->next) {
+ if (e->display == dpy) return e;
+ }
+ return NULL;
+}
+
+
+/*
+ * XmuDQAddDisplay - add the specified display to the queue; set data as a
+ * convenience. Does not ensure that dpy hasn't already been added.
+ */
+XmuDisplayQueueEntry *XmuDQAddDisplay (q, dpy, data)
+ XmuDisplayQueue *q;
+ Display *dpy;
+ XPointer data;
+{
+ XmuDisplayQueueEntry *e;
+
+ if (!(e = (XmuDisplayQueueEntry *) malloc (sizeof (XmuDisplayQueueEntry)))) {
+ return NULL;
+ }
+ if (!(e->closehook = XmuAddCloseDisplayHook (dpy, _DQCloseDisplay,
+ (XPointer) q))) {
+ free ((char *) e);
+ return NULL;
+ }
+
+ e->display = dpy;
+ e->next = NULL;
+ e->data = data;
+
+ if (q->tail) {
+ q->tail->next = e;
+ e->prev = q->tail;
+ } else {
+ q->head = e;
+ e->prev = NULL;
+ }
+ q->tail = e;
+ q->nentries++;
+ return e;
+}
+
+
+/*
+ * XmuDQRemoveDisplay - remove the specified display from the queue
+ */
+Bool XmuDQRemoveDisplay (q, dpy)
+ XmuDisplayQueue *q;
+ Display *dpy;
+{
+ XmuDisplayQueueEntry *e;
+
+ for (e = q->head; e; e = e->next) {
+ if (e->display == dpy) {
+ if (q->head == e)
+ q->head = e->next; /* if at head, then bump head */
+ else
+ e->prev->next = e->next; /* else splice out */
+ if (q->tail == e)
+ q->tail = e->prev; /* if at tail, then bump tail */
+ else
+ e->next->prev = e->prev; /* else splice out */
+ (void) XmuRemoveCloseDisplayHook (dpy, e->closehook,
+ _DQCloseDisplay, (XPointer) q);
+ free ((char *) e);
+ q->nentries--;
+ return True;
+ }
+ }
+ return False;
+}
+
+
+/*****************************************************************************
+ * private functions *
+ *****************************************************************************/
+
+/*
+ * _DQCloseDisplay - upcalled from CloseHook to notify this queue; remove the
+ * display when finished
+ */
+static int _DQCloseDisplay (dpy, arg)
+ Display *dpy;
+ XPointer arg;
+{
+ XmuDisplayQueue *q = (XmuDisplayQueue *) arg;
+ XmuDisplayQueueEntry *e;
+
+ for (e = q->head; e; e = e->next) {
+ if (e->display == dpy) {
+ if (q->closefunc) CallCloseCallback (q, e);
+ (void) XmuDQRemoveDisplay (q, dpy);
+ if (q->nentries == 0 && q->freefunc) CallFreeCallback (q);
+ return 1;
+ }
+ }
+
+ return 0;
+}
diff --git a/src/Distinct.c b/src/Distinct.c
new file mode 100644
index 0000000..1cf3c45
--- /dev/null
+++ b/src/Distinct.c
@@ -0,0 +1,90 @@
+/* $Xorg: Distinct.c,v 1.4 2001/02/09 02:03:52 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.
+
+*/
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+# include <X11/Xlib.h>
+
+/*
+ * Distinguishable colors routine. Determines if two colors are
+ * distinguishable or not. Somewhat arbitrary meaning.
+ */
+
+#define MIN_DISTINGUISH 10000.0
+
+Bool
+XmuDistinguishableColors (colors, count)
+XColor *colors;
+int count;
+{
+ double deltaRed, deltaGreen, deltaBlue;
+ double dist;
+ int i, j;
+
+ for (i = 0; i < count - 1; i++)
+ for (j = i + 1; j < count; j++)
+ {
+ deltaRed = (double)colors[i].red - (double)colors[j].red;
+ deltaGreen = (double)colors[i].green - (double)colors[j].green;
+ deltaBlue = (double)colors[i].blue - (double)colors[j].blue;
+ dist = deltaRed * deltaRed +
+ deltaGreen * deltaGreen +
+ deltaBlue * deltaBlue;
+ if (dist <= MIN_DISTINGUISH * MIN_DISTINGUISH)
+ return False;
+ }
+ return True;
+}
+
+Bool
+XmuDistinguishablePixels (dpy, cmap, pixels, count)
+ Display *dpy;
+ Colormap cmap;
+ unsigned long *pixels;
+ int count;
+{
+ XColor *defs;
+ int i, j;
+ Bool ret;
+
+ for (i = 0; i < count - 1; i++)
+ for (j = i + 1; j < count; j++)
+ if (pixels[i] == pixels[j])
+ return False;
+ defs = (XColor *) malloc (count * sizeof (XColor));
+ if (!defs)
+ return False;
+ for (i = 0; i < count; i++)
+ defs[i].pixel = pixels[i];
+ XQueryColors (dpy, cmap, defs, count);
+ ret = XmuDistinguishableColors (defs, count);
+ free ((char *) defs);
+ return ret;
+}
diff --git a/src/DrRndRect.c b/src/DrRndRect.c
new file mode 100644
index 0000000..35aa9d7
--- /dev/null
+++ b/src/DrRndRect.c
@@ -0,0 +1,180 @@
+/* $Xorg: DrRndRect.c,v 1.4 2001/02/09 02:03:52 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.
+
+*/
+
+/*
+ * XmuDrawRoundedRectangle, XmuFillRoundedRectangle
+ *
+ * Draw/Fill a rounded rectangle, where x, y, w, h are the dimensions of
+ * the overall rectangle, and ew and eh are the sizes of a bounding box
+ * that the corners are drawn inside of.
+ */
+
+#include <X11/Xlib.h>
+
+void
+XmuDrawRoundedRectangle (dpy, draw, gc, x, y, w, h, ew, eh)
+ Display *dpy;
+ Drawable draw;
+ GC gc;
+ int x, y, w, h, ew, eh;
+{
+ XArc arcs[8];
+
+ if (ew*2 > w)
+ ew = 0;
+ if (eh*2 > h)
+ eh = 0;
+
+ arcs[0].x = x;
+ arcs[0].y = y;
+ arcs[0].width = ew*2;
+ arcs[0].height = eh*2;
+ arcs[0].angle1 = 180*64;
+ arcs[0].angle2 = -90*64;
+
+ arcs[1].x = x + ew;
+ arcs[1].y = y;
+ arcs[1].width = w - ew*2;
+ arcs[1].height = 0;
+ arcs[1].angle1 = 180*64;
+ arcs[1].angle2 = -180*64;
+
+ arcs[2].x = x + w - ew*2;
+ arcs[2].y = y;
+ arcs[2].width = ew*2;
+ arcs[2].height = eh*2;
+ arcs[2].angle1 = 90*64;
+ arcs[2].angle2 = -90*64;
+
+ arcs[3].x = x + w;
+ arcs[3].y = y + eh;
+ arcs[3].width = 0;
+ arcs[3].height = h - eh*2;
+ arcs[3].angle1 = 90 * 64;
+ arcs[3].angle2 = -180*64;
+
+ arcs[4].x = x + w - ew*2;
+ arcs[4].y = y + h - eh*2;
+ arcs[4].width = ew * 2;
+ arcs[4].height = eh * 2;
+ arcs[4].angle1 = 0;
+ arcs[4].angle2 = -90*64;
+
+ arcs[5].x = x + ew;
+ arcs[5].y = y + h;
+ arcs[5].width = w - ew*2;
+ arcs[5].height = 0;
+ arcs[5].angle1 = 0;
+ arcs[5].angle2 = -180*64;
+
+ arcs[6].x = x;
+ arcs[6].y = y + h - eh*2;
+ arcs[6].width = ew*2;
+ arcs[6].height = eh*2;
+ arcs[6].angle1 = 270*64;
+ arcs[6].angle2 = -90*64;
+
+ arcs[7].x = x;
+ arcs[7].y = y + eh;
+ arcs[7].width = 0;
+ arcs[7].height = h - eh*2;
+ arcs[7].angle1 = 270*64;
+ arcs[7].angle2 = -180*64;
+ XDrawArcs (dpy, draw, gc, arcs, 8);
+}
+
+void
+XmuFillRoundedRectangle (dpy, draw, gc, x, y, w, h, ew, eh)
+ Display *dpy;
+ Drawable draw;
+ GC gc;
+ int x, y, w, h, ew, eh;
+{
+ XArc arcs[4];
+ XRectangle rects[3];
+ XGCValues vals;
+
+ XGetGCValues(dpy, gc, GCArcMode, &vals);
+ if (vals.arc_mode != ArcPieSlice)
+ XSetArcMode(dpy, gc, ArcPieSlice);
+
+ if (ew*2 > w)
+ ew = 0;
+ if (eh*2 > h)
+ eh = 0;
+
+ arcs[0].x = x;
+ arcs[0].y = y;
+ arcs[0].width = ew*2;
+ arcs[0].height = eh*2;
+ arcs[0].angle1 = 180*64;
+ arcs[0].angle2 = -90*64;
+
+ arcs[1].x = x + w - ew*2;
+ arcs[1].y = y;
+ arcs[1].width = ew*2;
+ arcs[1].height = eh*2;
+ arcs[1].angle1 = 90*64;
+ arcs[1].angle2 = -90*64;
+
+ arcs[2].x = x + w - ew*2;
+ arcs[2].y = y + h - eh*2;
+ arcs[2].width = ew*2;
+ arcs[2].height = eh*2;
+ arcs[2].angle1 = 0;
+ arcs[2].angle2 = -90*64;
+
+ arcs[3].x = x;
+ arcs[3].y = y + h - eh*2;
+ arcs[3].width = ew*2;
+ arcs[3].height = eh*2;
+ arcs[3].angle1 = 270*64;
+ arcs[3].angle2 = -90*64;
+
+ XFillArcs (dpy, draw, gc, arcs, 4);
+
+ rects[0].x = x + ew;
+ rects[0].y = y;
+ rects[0].width = w - ew*2;
+ rects[0].height = h;
+
+ rects[1].x = x;
+ rects[1].y = y + eh;
+ rects[1].width = ew;
+ rects[1].height = h - eh*2;
+
+ rects[2].x = x + w - ew;
+ rects[2].y = y + eh;
+ rects[2].width = ew;
+ rects[2].height = h - eh*2;
+
+ XFillRectangles (dpy, draw, gc, rects, 3);
+
+ if (vals.arc_mode != ArcPieSlice)
+ XSetArcMode(dpy, gc, vals.arc_mode);
+}
diff --git a/src/DrawLogo.c b/src/DrawLogo.c
new file mode 100644
index 0000000..4c093c5
--- /dev/null
+++ b/src/DrawLogo.c
@@ -0,0 +1,154 @@
+/* $Xorg: DrawLogo.c,v 1.4 2001/02/09 02:03:52 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 <X11/Xlib.h>
+
+/*
+ * Draw the "official" X Window System Logo, designed by Danny Chong
+ *
+ * Written by Ollie Jones, Apollo Computer
+ *
+ * Does some fancy stuff to make the logo look acceptable even
+ * if it is tiny. Also makes the various linear elements of
+ * the logo line up as well as possible considering rasterization.
+ */
+
+XmuDrawLogo(dpy, drawable, gcFore, gcBack, x, y, width, height)
+ Display *dpy;
+ Drawable drawable;
+ GC gcFore, gcBack;
+ int x, y;
+ unsigned int width, height;
+{
+ unsigned int size;
+ int thin, gap, d31;
+ XPoint poly[4];
+
+ XFillRectangle(dpy, drawable, gcBack, x, y, width, height);
+
+ /* for now, do a centered even-sized square, at least for now */
+ size = width;
+ if (height < width)
+ size = height;
+ size &= ~1;
+ x += (width - size) >> 1;
+ y += (height - size) >> 1;
+
+/*
+ * Draw what will be the thin strokes.
+ *
+ * -----
+ * / /
+ * / /
+ * / /
+ * / /
+ * /____/
+ * d
+ *
+ * Point d is 9/44 (~1/5) of the way across.
+ */
+
+ thin = (size / 11);
+ if (thin < 1) thin = 1;
+ gap = (thin+3) / 4;
+ d31 = thin + thin + gap;
+ poly[0].x = x + size; poly[0].y = y;
+ poly[1].x = x + size-d31; poly[1].y = y;
+ poly[2].x = x + 0; poly[2].y = y + size;
+ poly[3].x = x + d31; poly[3].y = y + size;
+ XFillPolygon(dpy, drawable, gcFore, poly, 4, Convex, CoordModeOrigin);
+
+/*
+ * Erase area not needed for lower thin stroke.
+ *
+ * ------
+ * / /
+ * / __ /
+ * / / /
+ * / / /
+ * /__/__/
+ */
+
+ poly[0].x = x + d31/2; poly[0].y = y + size;
+ poly[1].x = x + size / 2; poly[1].y = y + size/2;
+ poly[2].x = x + (size/2)+(d31-(d31/2)); poly[2].y = y + size/2;
+ poly[3].x = x + d31; poly[3].y = y + size;
+ XFillPolygon(dpy, drawable, gcBack, poly, 4, Convex, CoordModeOrigin);
+
+/*
+ * Erase area not needed for upper thin stroke.
+ *
+ * ------
+ * / / /
+ * /--/ /
+ * / /
+ * / /
+ * /_____/
+ */
+
+ poly[0].x = x + size - d31/2; poly[0].y = y;
+ poly[1].x = x + size / 2; poly[1].y = y + size/2;
+ poly[2].x = x + (size/2)-(d31-(d31/2)); poly[2].y = y + size/2;
+ poly[3].x = x + size - d31; poly[3].y = y;
+ XFillPolygon(dpy, drawable, gcBack, poly, 4, Convex, CoordModeOrigin);
+
+/*
+ * Draw thick stroke.
+ * Point b is 1/4 of the way across.
+ *
+ * b
+ * -----
+ * \ \
+ * \ \
+ * \ \
+ * \ \
+ * \____\
+ */
+
+ poly[0].x = x; poly[0].y = y;
+ poly[1].x = x + size/4; poly[1].y = y;
+ poly[2].x = x + size; poly[2].y = y + size;
+ poly[3].x = x + size - size/4; poly[3].y = y + size;
+ XFillPolygon(dpy, drawable, gcFore, poly, 4, Convex, CoordModeOrigin);
+
+/*
+ * Erase to create gap.
+ *
+ * /
+ * /
+ * /
+ * /
+ * /
+ */
+
+ poly[0].x = x + size- thin; poly[0].y = y;
+ poly[1].x = x + size-( thin+gap); poly[1].y = y;
+ poly[2].x = x + thin; poly[2].y = y + size;
+ poly[3].x = x + thin + gap; poly[3].y = y + size;
+ XFillPolygon(dpy, drawable, gcBack, poly, 4, Convex, CoordModeOrigin);
+}
diff --git a/src/EditresCom.c b/src/EditresCom.c
new file mode 100644
index 0000000..b4677f1
--- /dev/null
+++ b/src/EditresCom.c
@@ -0,0 +1,1886 @@
+/* $Xorg: EditresCom.c,v 1.4 2001/02/09 02:03:52 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.
+
+*/
+
+/*
+ * Author: Chris D. Peterson, Dave Sternlicht, MIT X Consortium
+ */
+
+#include <X11/IntrinsicP.h> /* To get into the composite and core widget
+ structures. */
+#include <X11/ObjectP.h> /* For XtIs<Classname> macros. */
+#include <X11/StringDefs.h> /* for XtRString. */
+#include <X11/ShellP.h> /* for Application Shell Widget class. */
+
+#include <X11/Xatom.h>
+#include <X11/Xos.h> /* for strcpy declaration */
+#include <X11/Xaw/Cardinals.h>
+#include <X11/Xmu/EditresP.h>
+#include <X11/Xmd.h>
+
+#include <stdio.h>
+
+#define _XEditResPutBool _XEditResPut8
+#define _XEditResPutResourceType _XEditResPut8
+
+/************************************************************
+ *
+ * Local structure definitions.
+ *
+ ************************************************************/
+
+typedef enum { BlockNone, BlockSetValues, BlockAll } EditresBlock;
+
+typedef struct _SetValuesEvent {
+ EditresCommand type; /* first field must be type. */
+ WidgetInfo * widgets;
+ unsigned short num_entries; /* number of set values requests. */
+ char * name;
+ char * res_type;
+ XtPointer value;
+ unsigned short value_len;
+} SetValuesEvent;
+
+typedef struct _SVErrorInfo {
+ SetValuesEvent * event;
+ ProtocolStream * stream;
+ unsigned short * count;
+ WidgetInfo * entry;
+} SVErrorInfo;
+
+typedef struct _GetValuesEvent {
+ EditresCommand type; /* first field must be type */
+ WidgetInfo * widgets;
+ unsigned short num_entries; /* number of get values requests */
+ char * name;
+} GetValuesEvent;
+
+typedef struct _FindChildEvent {
+ EditresCommand type; /* first field must be type. */
+ WidgetInfo * widgets;
+ short x, y;
+} FindChildEvent;
+
+typedef struct _GenericGetEvent {
+ EditresCommand type; /* first field must be type. */
+ WidgetInfo * widgets;
+ unsigned short num_entries; /* number of set values requests. */
+} GenericGetEvent, GetResEvent, GetGeomEvent;
+
+/*
+ * Things that are common to all events.
+ */
+
+typedef struct _AnyEvent {
+ EditresCommand type; /* first field must be type. */
+ WidgetInfo * widgets;
+} AnyEvent;
+
+/*
+ * The event union.
+ */
+
+typedef union _EditresEvent {
+ AnyEvent any_event;
+ SetValuesEvent set_values_event;
+ GetResEvent get_resources_event;
+ GetGeomEvent get_geometry_event;
+ FindChildEvent find_child_event;
+} EditresEvent;
+
+typedef struct _Globals {
+ EditresBlock block;
+ SVErrorInfo error_info;
+ ProtocolStream stream;
+ ProtocolStream * command_stream; /* command stream. */
+#if defined(LONG64) || defined(WORD64)
+ unsigned long base_address;
+#endif
+} Globals;
+
+#define CURRENT_PROTOCOL_VERSION 5L
+
+#define streq(a,b) (strcmp( (a), (b) ) == 0)
+
+static Atom res_editor_command, res_editor_protocol, client_value;
+
+static Globals globals;
+
+static void SendFailure(), SendCommand(), InsertWidget(), ExecuteCommand();
+static void FreeEvent(), ExecuteSetValues(), ExecuteGetGeometry();
+static void ExecuteGetResources();
+
+static void GetCommand();
+static void LoadResources();
+static Boolean IsChild();
+static void DumpChildren();
+static char *DumpWidgets(), *DoSetValues(), *DoFindChild();
+static char *DoGetGeometry(), *DoGetResources(), *DumpValues();
+
+/************************************************************
+ *
+ * Resource Editor Communication Code
+ *
+ ************************************************************/
+
+/* Function Name: _XEditResCheckMessages
+ * Description: This callback routine is set on all shell widgets,
+ * and checks to see if a client message event
+ * has come from the resource editor.
+ * Arguments: w - the shell widget.
+ * data - *** UNUSED ***
+ * event - The X Event that triggered this handler.
+ * cont - *** UNUSED ***.
+ * Returns: none.
+ */
+
+/* ARGSUSED */
+void
+_XEditResCheckMessages(w, data, event, cont)
+Widget w;
+XtPointer data;
+XEvent *event;
+Boolean *cont;
+{
+ Time time;
+ ResIdent ident;
+ static Boolean first_time = FALSE;
+ static Atom res_editor, res_comm;
+ Display * dpy;
+
+ if (event->type == ClientMessage) {
+ XClientMessageEvent * c_event = (XClientMessageEvent *) event;
+ dpy = XtDisplay(w);
+
+ if (!first_time) {
+ Atom atoms[4];
+ static char* names[] = {
+ EDITRES_NAME, EDITRES_COMMAND_ATOM,
+ EDITRES_PROTOCOL_ATOM, EDITRES_CLIENT_VALUE };
+
+ first_time = TRUE;
+ XInternAtoms(dpy, names, 4, FALSE, atoms);
+ res_editor = atoms[0];
+ res_editor_command = atoms[1];
+ res_editor_protocol = atoms[2];
+ /* Used in later procedures. */
+ client_value = atoms[3];
+ LoadResources(w);
+ }
+
+ if ((c_event->message_type != res_editor) ||
+ (c_event->format != EDITRES_SEND_EVENT_FORMAT))
+ return;
+
+ time = c_event->data.l[0];
+ res_comm = c_event->data.l[1];
+ ident = (ResIdent) c_event->data.l[2];
+ if (c_event->data.l[3] != CURRENT_PROTOCOL_VERSION) {
+ _XEditResResetStream(&globals.stream);
+ _XEditResPut8(&globals.stream, CURRENT_PROTOCOL_VERSION);
+ SendCommand(w, res_comm, ident, ProtocolMismatch, &globals.stream);
+ return;
+ }
+
+ XtGetSelectionValue(w, res_comm, res_editor_command,
+ GetCommand, (XtPointer)(long) ident, time);
+ }
+}
+
+/* Function Name: BuildEvent
+ * Description: Takes the info out the protocol stream an constructs
+ * the proper event structure.
+ * Arguments: w - widget to own selection, in case of error.
+ * sel - selection to send error message beck in.
+ * data - the data for the request.
+ * ident - the id number we are looking for.
+ * length - length of request.
+ * Returns: the event, or NULL.
+ */
+
+#define ERROR_MESSAGE ("Client: Improperly formatted protocol request")
+
+static EditresEvent *
+BuildEvent(w, sel, data, ident, length)
+Widget w;
+Atom sel;
+XtPointer data;
+ResIdent ident;
+unsigned long length;
+{
+ EditresEvent * event;
+ ProtocolStream alloc_stream, *stream;
+ unsigned char temp;
+ register unsigned int i;
+
+ stream = &alloc_stream; /* easier to think of it this way... */
+
+ stream->current = stream->top = (unsigned char *) data;
+ stream->size = HEADER_SIZE; /* size of header. */
+
+ /*
+ * Retrieve the Header.
+ */
+
+ if (length < HEADER_SIZE) {
+ SendFailure(w, sel, ident, Failure, ERROR_MESSAGE);
+ return(NULL);
+ }
+
+ (void) _XEditResGet8(stream, &temp);
+ if (temp != ident) /* Id's don't match, ignore request. */
+ return(NULL);
+
+ event = (EditresEvent *) XtCalloc(sizeof(EditresEvent), 1);
+
+ (void) _XEditResGet8(stream, &temp);
+ event->any_event.type = (EditresCommand) temp;
+ (void) _XEditResGet32(stream, &(stream->size));
+ stream->top = stream->current; /* reset stream to top of value.*/
+
+ /*
+ * Now retrieve the data segment.
+ */
+
+ switch(event->any_event.type) {
+ case SendWidgetTree:
+ break; /* no additional info */
+ case SetValues:
+ {
+ SetValuesEvent * sv_event = (SetValuesEvent *) event;
+
+ if ( !(_XEditResGetString8(stream, &(sv_event->name)) &&
+ _XEditResGetString8(stream, &(sv_event->res_type))))
+ {
+ goto done;
+ }
+
+ /*
+ * Since we need the value length, we have to pull the
+ * value out by hand.
+ */
+
+ if (!_XEditResGet16(stream, &(sv_event->value_len)))
+ goto done;
+
+ sv_event->value = XtMalloc(sizeof(char) *
+ (sv_event->value_len + 1));
+
+ for (i = 0; i < sv_event->value_len; i++) {
+ if (!_XEditResGet8(stream,
+ (unsigned char *) sv_event->value + i))
+ {
+ goto done;
+ }
+ }
+ ((char*)sv_event->value)[i] = '\0'; /* NULL terminate that sucker. */
+
+ if (!_XEditResGet16(stream, &(sv_event->num_entries)))
+ goto done;
+
+ sv_event->widgets = (WidgetInfo *)
+ XtCalloc(sizeof(WidgetInfo), sv_event->num_entries);
+
+ for (i = 0; i < sv_event->num_entries; i++) {
+ if (!_XEditResGetWidgetInfo(stream, sv_event->widgets + i))
+ goto done;
+ }
+ }
+ break;
+ case FindChild:
+ {
+ FindChildEvent * find_event = (FindChildEvent *) event;
+
+ find_event->widgets = (WidgetInfo *)
+ XtCalloc(sizeof(WidgetInfo), 1);
+
+ if (!(_XEditResGetWidgetInfo(stream, find_event->widgets) &&
+ _XEditResGetSigned16(stream, &(find_event->x)) &&
+ _XEditResGetSigned16(stream, &(find_event->y))))
+ {
+ goto done;
+ }
+
+ }
+ break;
+ case GetGeometry:
+ case GetResources:
+ {
+ GenericGetEvent * get_event = (GenericGetEvent *) event;
+
+ if (!_XEditResGet16(stream, &(get_event->num_entries)))
+ goto done;
+
+ get_event->widgets = (WidgetInfo *)
+ XtCalloc(sizeof(WidgetInfo), get_event->num_entries);
+ for (i = 0; i < get_event->num_entries; i++) {
+ if (!_XEditResGetWidgetInfo(stream, get_event->widgets + i))
+ goto done;
+ }
+ }
+ break;
+
+ case GetValues:
+ {
+ GetValuesEvent * gv_event = (GetValuesEvent *) event;
+ _XEditResGetString8(stream, &(gv_event->name));
+ _XEditResGet16(stream, &(gv_event->num_entries));
+ gv_event->widgets = (WidgetInfo *)
+ XtCalloc(sizeof(WidgetInfo), gv_event->num_entries);
+ _XEditResGetWidgetInfo(stream, gv_event->widgets);
+ }
+ break;
+
+ default:
+ {
+ char buf[BUFSIZ];
+
+ sprintf(buf, "Unknown Protocol request %d.",event->any_event.type);
+ SendFailure(w, sel, ident, buf);
+ return(NULL);
+ }
+ }
+ return(event);
+
+ done:
+
+ SendFailure(w, sel, ident, ERROR_MESSAGE);
+ FreeEvent(event);
+ return(NULL);
+}
+
+/* Function Name: FreeEvent
+ * Description: Frees the event structure and any other pieces
+ * in it that need freeing.
+ * Arguments: event - the event to free.
+ * Returns: none.
+ */
+
+static void
+FreeEvent(event)
+EditresEvent * event;
+{
+ if (event->any_event.widgets != NULL) {
+ XtFree((char *)event->any_event.widgets->ids);
+ XtFree((char *)event->any_event.widgets);
+ }
+
+ if (event->any_event.type == SetValues) {
+ XtFree(event->set_values_event.name); /* XtFree does not free if */
+ XtFree(event->set_values_event.res_type); /* value is NULL. */
+ }
+
+ XtFree((char *)event);
+}
+
+/* Function Name: GetCommand
+ * Description: Gets the Command out of the selection asserted by the
+ * resource manager.
+ * Arguments: (See Xt XtConvertSelectionProc)
+ * data - contains the ident number for the command.
+ * Returns: none.
+ */
+
+/* ARGSUSED */
+static void
+GetCommand(w, data, selection, type, value, length, format)
+Widget w;
+XtPointer data, value;
+Atom *selection, *type;
+unsigned long *length;
+int * format;
+{
+ ResIdent ident = (ResIdent)(long) data;
+ EditresEvent * event;
+
+ if ( (*type != res_editor_protocol) || (*format != EDITRES_FORMAT) )
+ return;
+
+ if ((event = BuildEvent(w, *selection, value, ident, *length)) != NULL) {
+ ExecuteCommand(w, *selection, ident, event);
+ FreeEvent(event);
+ }
+}
+
+/* Function Name: ExecuteCommand
+ * Description: Executes a command string received from the
+ * resource editor.
+ * Arguments: w - a widget.
+ * command - the command to execute.
+ * value - the associated with the command.
+ * Returns: none.
+ *
+ * NOTES: munges str
+ */
+
+/* ARGSUSED */
+static void
+ExecuteCommand(w, sel, ident, event)
+Widget w;
+Atom sel;
+ResIdent ident;
+EditresEvent * event;
+{
+ char * (*func)();
+ char * str;
+
+ if (globals.block == BlockAll) {
+ SendFailure(w, sel, ident,
+ "This client has blocked all Editres commands.");
+ return;
+ }
+ else if ((globals.block == BlockSetValues) &&
+ (event->any_event.type == SetValues)) {
+ SendFailure(w, sel, ident,
+ "This client has blocked all SetValues requests.");
+ return;
+ }
+
+ switch(event->any_event.type) {
+ case SendWidgetTree:
+#if defined(LONG64) || defined(WORD64)
+ globals.base_address = (unsigned long)w & 0xFFFFFFFF00000000;
+#endif
+ func = DumpWidgets;
+ break;
+ case SetValues:
+ func = DoSetValues;
+ break;
+ case FindChild:
+ func = DoFindChild;
+ break;
+ case GetGeometry:
+ func = DoGetGeometry;
+ break;
+ case GetResources:
+ func = DoGetResources;
+ break;
+ case GetValues:
+ func = DumpValues;
+ break;
+ default:
+ {
+ char buf[BUFSIZ];
+ sprintf(buf,"Unknown Protocol request %d.",event->any_event.type);
+ SendFailure(w, sel, ident, buf);
+ return;
+ }
+ }
+
+ _XEditResResetStream(&globals.stream);
+ if ((str = (*func)(w, event, &globals.stream)) == NULL)
+ SendCommand(w, sel, ident, PartialSuccess, &globals.stream);
+ else {
+ SendFailure(w, sel, ident, str);
+ XtFree(str);
+ }
+}
+
+/* Function Name: ConvertReturnCommand
+ * Description: Converts a selection.
+ * Arguments: w - the widget that owns the selection.
+ * selection - selection to convert.
+ * target - target type for this selection.
+ * type_ret - type of the selection.
+ * value_ret - selection value;
+ * length_ret - lenght of this selection.
+ * format_ret - the format the selection is in.
+ * Returns: True if conversion was sucessful.
+ */
+
+/* ARGSUSED */
+static Boolean
+ConvertReturnCommand(w, selection, target,
+ type_ret, value_ret, length_ret, format_ret)
+Widget w;
+Atom * selection, * target, * type_ret;
+XtPointer *value_ret;
+unsigned long * length_ret;
+int * format_ret;
+{
+ /*
+ * I assume the intrinsics give me the correct selection back.
+ */
+
+ if ((*target != client_value))
+ return(FALSE);
+
+ *type_ret = res_editor_protocol;
+ *value_ret = (XtPointer) globals.command_stream->real_top;
+ *length_ret = globals.command_stream->size + HEADER_SIZE;
+ *format_ret = EDITRES_FORMAT;
+
+ return(TRUE);
+}
+
+/* Function Name: CommandDone
+ * Description: done with the selection.
+ * Arguments: *** UNUSED ***
+ * Returns: none.
+ */
+
+/* ARGSUSED */
+static void
+CommandDone(widget, selection, target)
+Widget widget;
+Atom *selection;
+Atom *target;
+{
+ /* Keep the toolkit from automaticaly freeing the selection value */
+}
+
+/* Function Name: SendFailure
+ * Description: Sends a failure message.
+ * Arguments: w - the widget to own the selection.
+ * sel - the selection to assert.
+ * ident - the identifier.
+ * str - the error message.
+ * Returns: none.
+ */
+
+static void
+SendFailure(w, sel, ident, str)
+Widget w;
+Atom sel;
+ResIdent ident;
+char * str;
+{
+ _XEditResResetStream(&globals.stream);
+ _XEditResPutString8(&globals.stream, str);
+ SendCommand(w, sel, ident, Failure, &globals.stream);
+}
+
+/* Function Name: BuildReturnPacket
+ * Description: Builds a return packet, given the data to send.
+ * Arguments: ident - the identifier.
+ * command - the command code.
+ * stream - the protocol stream.
+ * Returns: packet - the packet to send.
+ */
+
+static XtPointer
+BuildReturnPacket(ident, command, stream)
+ResIdent ident;
+EditresCommand command;
+ProtocolStream * stream;
+{
+ long old_alloc, old_size;
+ unsigned char * old_current;
+
+ /*
+ * We have cleverly keep enough space at the top of the header
+ * for the return protocol stream, so all we have to do is
+ * fill in the space.
+ */
+
+ /*
+ * Fool the insert routines into putting the header in the right
+ * place while being damn sure not to realloc (that would be very bad.
+ */
+
+ old_current = stream->current;
+ old_alloc = stream->alloc;
+ old_size = stream->size;
+
+ stream->current = stream->real_top;
+ stream->alloc = stream->size + (2 * HEADER_SIZE);
+
+ _XEditResPut8(stream, ident);
+ _XEditResPut8(stream, (unsigned char) command);
+ _XEditResPut32(stream, old_size);
+
+ stream->alloc = old_alloc;
+ stream->current = old_current;
+ stream->size = old_size;
+
+ return((XtPointer) stream->real_top);
+}
+
+/* Function Name: SendCommand
+ * Description: Builds a return command line.
+ * Arguments: w - the widget to own the selection.
+ * sel - the selection to assert.
+ * ident - the identifier.
+ * command - the command code.
+ * stream - the protocol stream.
+ * Returns: none.
+ */
+
+static void
+SendCommand(w, sel, ident, command, stream)
+Widget w;
+Atom sel;
+ResIdent ident;
+EditresCommand command;
+ProtocolStream * stream;
+{
+ BuildReturnPacket(ident, command, stream);
+ globals.command_stream = stream;
+
+/*
+ * I REALLY want to own the selection. Since this was not triggered
+ * by a user action, and I am the only one using this atom it is safe to
+ * use CurrentTime.
+ */
+
+ XtOwnSelection(w, sel, CurrentTime,
+ ConvertReturnCommand, NULL, CommandDone);
+}
+
+/************************************************************
+ *
+ * Generic Utility Functions.
+ *
+ ************************************************************/
+
+/* Function Name: FindChildren
+ * Description: Retuns all children (popup, normal and otherwise)
+ * of this widget
+ * Arguments: parent - the parent widget.
+ * children - the list of children.
+ * normal - return normal children.
+ * popup - return popup children.
+ * Returns: the number of children.
+ */
+
+static int
+FindChildren(parent, children, normal, popup)
+Widget parent, **children;
+Boolean normal, popup;
+{
+ CompositeWidget cw = (CompositeWidget) parent;
+ int i, num_children, current = 0;
+
+ num_children = 0;
+
+ if (XtIsWidget(parent) && popup)
+ num_children += parent->core.num_popups;
+
+ if (XtIsComposite(parent) && normal)
+ num_children += cw->composite.num_children;
+
+ if (num_children == 0) {
+ *children = NULL;
+ return(0);
+ }
+
+ *children =(Widget*) XtMalloc((Cardinal) sizeof(Widget) * num_children);
+
+ if (XtIsComposite(parent) && normal)
+ for (i = 0; i < cw->composite.num_children; i++,current++)
+ (*children)[current] = cw->composite.children[i];
+
+ if (XtIsWidget(parent) && popup)
+ for ( i = 0; i < parent->core.num_popups; i++, current++)
+ (*children)[current] = parent->core.popup_list[i];
+
+ return(num_children);
+}
+
+/* Function Name: IsChild
+ * Description: check to see of child is a child of parent.
+ * Arguments: top - the top of the tree.
+ * parent - the parent widget.
+ * child - the child.
+ * Returns: none.
+ */
+
+static Boolean
+IsChild(top, parent, child)
+Widget top, parent, child;
+{
+ int i, num_children;
+ Widget * children;
+
+ if (parent == NULL)
+ return(top == child);
+
+ num_children = FindChildren(parent, &children, TRUE, TRUE);
+
+ for (i = 0; i < num_children; i++) {
+ if (children[i] == child) {
+ XtFree((char *)children);
+ return(TRUE);
+ }
+ }
+
+ XtFree((char *)children);
+ return(FALSE);
+}
+
+/* Function Name: VerifyWidget
+ * Description: Makes sure all the widgets still exist.
+ * Arguments: w - any widget in the tree.
+ * info - the info about the widget to verify.
+ * Returns: an error message or NULL.
+ */
+
+static char *
+VerifyWidget(w, info)
+Widget w;
+WidgetInfo *info;
+{
+ Widget top;
+
+ register int count;
+ register Widget parent;
+ register unsigned long * child;
+
+ for (top = w; XtParent(top) != NULL; top = XtParent(top)) {}
+
+ parent = NULL;
+ child = info->ids;
+ count = 0;
+
+ while (TRUE) {
+ if (!IsChild(top, parent, (Widget) *child))
+ return(XtNewString("This widget no longer exists in the client."));
+
+ if (++count == info->num_widgets)
+ break;
+
+ parent = (Widget) *child++;
+ }
+
+ info->real_widget = (Widget) *child;
+ return(NULL);
+}
+
+/************************************************************
+ *
+ * Code to Perform SetValues operations.
+ *
+ ************************************************************/
+
+
+/* Function Name: DoSetValues
+ * Description: performs the setvalues requested.
+ * Arguments: w - a widget in the tree.
+ * event - the event that caused this action.
+ * stream - the protocol stream to add.
+ * Returns: NULL.
+ */
+
+static char *
+DoSetValues(w, event, stream)
+Widget w;
+EditresEvent * event;
+ProtocolStream * stream;
+{
+ char * str;
+ register unsigned i;
+ unsigned short count = 0;
+ SetValuesEvent * sv_event = (SetValuesEvent *) event;
+
+ _XEditResPut16(stream, count); /* insert 0, will be overwritten later. */
+
+ for (i = 0 ; i < sv_event->num_entries; i++) {
+ if ((str = VerifyWidget(w, &(sv_event->widgets[i]))) != NULL) {
+ _XEditResPutWidgetInfo(stream, &(sv_event->widgets[i]));
+ _XEditResPutString8(stream, str);
+ XtFree(str);
+ count++;
+ }
+ else
+ ExecuteSetValues(sv_event->widgets[i].real_widget,
+ sv_event, sv_event->widgets + i, stream, &count);
+ }
+
+ /*
+ * Overwrite the first 2 bytes with the real count.
+ */
+
+ *(stream->top) = count >> XER_NBBY;
+ *(stream->top + 1) = count;
+ return(NULL);
+}
+
+/* Function Name: HandleToolkitErrors
+ * Description: Handles X Toolkit Errors.
+ * Arguments: name - name of the error.
+ * type - type of the error.
+ * class - class of the error.
+ * msg - the default message.
+ * params, num_params - the extra parameters for this message.
+ * Returns: none.
+ */
+
+/* ARGSUSED */
+static void
+HandleToolkitErrors(name, type, class, msg, params, num_params)
+String name, type, class, msg, *params;
+Cardinal * num_params;
+{
+ SVErrorInfo * info = &globals.error_info;
+ int len;
+ char buf[BUFSIZ];
+ char* bufp;
+ char* fmt1 = "The `%s' resource is not used by this widget.";
+
+ if ( streq(name, "unknownType") ) {
+ if ((len = strlen (fmt1) + strlen (info->event->name)) < sizeof buf)
+ bufp = buf;
+ else
+ bufp = XtMalloc (len + 1);
+ if (bufp == NULL) {
+ bufp = buf;
+ strcpy (bufp, "Resource is not used by this widget.");
+ } else
+ sprintf(bufp, fmt1, info->event->name);
+ } else if ( streq(name, "noColormap") ) {
+ if ((len = strlen (msg) + strlen (params[0])) < sizeof buf)
+ bufp = buf;
+ else
+ bufp = XtMalloc (len + 1);
+ if (bufp == NULL) {
+ bufp = buf;
+ strcpy (bufp, "Message too long.");
+ } else
+ sprintf(bufp, msg, params[0]);
+ } else if (streq(name, "conversionFailed") || streq(name, "conversionError")) {
+ char* fmt2 = "Could not convert the string '%s' for the `%s' resource.";
+ char* fmt3 = "Could not convert the `%s' resource.";
+ if (streq(info->event->value, XtRString)) {
+ if ((len = strlen (fmt2) + strlen (info->event->value) + strlen (info->event->name)) < sizeof buf)
+ bufp = buf;
+ else
+ bufp = XtMalloc (len + 1);
+ if (bufp == NULL) {
+ bufp = buf;
+ strcpy (bufp, "Could not convert the string for the resource.");
+ } else
+ sprintf(bufp, fmt2, info->event->value, info->event->name);
+ } else {
+ if ((len = strlen (fmt3) + strlen (info->event->name)) < sizeof buf)
+ bufp = buf;
+ else
+ bufp = XtMalloc (len + 1);
+ if (bufp == NULL) {
+ bufp = buf;
+ strcpy (bufp, "Could not convert the resource.");
+ } else
+ sprintf(bufp, fmt3, info->event->name);
+ }
+ } else {
+ char* fmt4 = "Name: %s, Type: %s, Class: %s, Msg: %s";
+
+ if ((len = strlen (fmt4) + strlen (name) + strlen (type) + strlen (class) + strlen (msg)) < sizeof buf)
+ bufp = buf;
+ else
+ bufp = XtMalloc (len + 1);
+ if (bufp == NULL) {
+ bufp = buf;
+ strcpy (bufp, "Message too long.");
+ } else
+ sprintf(bufp, fmt4, name, type, class, msg);
+ }
+
+ /*
+ * Insert this info into the protocol stream, and update the count.
+ */
+
+ (*(info->count))++;
+ _XEditResPutWidgetInfo(info->stream, info->entry);
+ _XEditResPutString8(info->stream, bufp);
+ if (bufp != buf) XtFree (bufp);
+}
+
+/* Function Name: ExecuteSetValues
+ * Description: Performs a setvalues for a given command.
+ * Arguments: w - the widget to perform the set_values on.
+ * sv_event - the set values event.
+ * sv_info - the set_value info.
+ * Returns: none.
+ */
+
+static void
+ExecuteSetValues(w, sv_event, entry, stream, count)
+Widget w;
+SetValuesEvent * sv_event;
+WidgetInfo * entry;
+ProtocolStream * stream;
+unsigned short * count;
+{
+ XtErrorMsgHandler old;
+
+ SVErrorInfo * info = &globals.error_info;
+ info->event = sv_event; /* No data can be passed to */
+ info->stream = stream; /* an error handler, so we */
+ info->count = count; /* have to use a global, YUCK... */
+ info->entry = entry;
+
+ old = XtAppSetWarningMsgHandler(XtWidgetToApplicationContext(w),
+ HandleToolkitErrors);
+
+ XtVaSetValues(w, XtVaTypedArg,
+ sv_event->name, sv_event->res_type,
+ sv_event->value, sv_event->value_len,
+ NULL);
+
+ (void)XtAppSetWarningMsgHandler(XtWidgetToApplicationContext(w), old);
+}
+
+
+/************************************************************
+ *
+ * Code for Creating and dumping widget tree.
+ *
+ ************************************************************/
+
+/* Function Name: DumpWidgets
+ * Description: Given a widget it builds a protocol packet
+ * containing the entire widget heirarchy.
+ * Arguments: w - a widget in the tree.
+ * event - the event that caused this action.
+ * stream - the protocol stream to add.
+ * Returns: NULL
+ */
+
+#define TOOLKIT_TYPE ("Xt")
+
+/* ARGSUSED */
+static char *
+DumpWidgets(w, event, stream)
+Widget w;
+EditresEvent * event; /* UNUSED */
+ProtocolStream * stream;
+{
+ unsigned short count = 0;
+
+ /* Find Tree's root. */
+ for ( ; XtParent(w) != NULL; w = XtParent(w)) {}
+
+ /*
+ * hold space for count, overwritten later.
+ */
+
+ _XEditResPut16(stream, (unsigned int) 0);
+
+ DumpChildren(w, stream, &count);
+
+ /*
+ * write out toolkit type (Xt, of course...).
+ */
+
+ _XEditResPutString8(stream, TOOLKIT_TYPE);
+
+ /*
+ * Overwrite the first 2 bytes with the real count.
+ */
+
+ *(stream->top) = count >> XER_NBBY;
+ *(stream->top + 1) = count;
+ return(NULL);
+}
+
+/* Function Name: DumpChildren
+ * Description: Adds a child's name to the list.
+ * Arguments: w - the widget to dump.
+ * stream - the stream to dump to.
+ * count - number of dumps we have performed.
+ * Returns: none.
+ */
+
+/* This is a trick/kludge. To make shared libraries happier (linking
+ * against Xmu but not linking against Xt, and apparently even work
+ * as we desire on SVR4, we need to avoid an explicit data reference
+ * to applicationShellWidgetClass. XtIsTopLevelShell is known
+ * (implementation dependent assumption!) to use a bit flag. So we
+ * go that far. Then, we test whether it is an applicationShellWidget
+ * class by looking for an explicit class name. Seems pretty safe.
+ */
+static Bool isApplicationShell(w)
+ Widget w;
+{
+ register WidgetClass c;
+
+ if (!XtIsTopLevelShell(w))
+ return False;
+ for (c = XtClass(w); c; c = c->core_class.superclass) {
+ if (!strcmp(c->core_class.class_name, "ApplicationShell"))
+ return True;
+ }
+ return False;
+}
+
+static void
+DumpChildren(w, stream, count)
+Widget w;
+ProtocolStream * stream;
+unsigned short *count;
+{
+ int i, num_children;
+ Widget *children;
+ unsigned long window;
+ char * class;
+
+ (*count)++;
+
+ InsertWidget(stream, w); /* Insert the widget into the stream. */
+
+ _XEditResPutString8(stream, XtName(w)); /* Insert name */
+
+ if (isApplicationShell(w))
+ class = ((ApplicationShellWidget) w)->application.class;
+ else
+ class = XtClass(w)->core_class.class_name;
+
+ _XEditResPutString8(stream, class); /* Insert class */
+
+ if (XtIsWidget(w))
+ if (XtIsRealized(w))
+ window = XtWindow(w);
+ else
+ window = EDITRES_IS_UNREALIZED;
+ else
+ window = EDITRES_IS_OBJECT;
+
+ _XEditResPut32(stream, window); /* Insert window id. */
+
+ /*
+ * Find children and recurse.
+ */
+
+ num_children = FindChildren(w, &children, TRUE, TRUE);
+ for (i = 0; i < num_children; i++)
+ DumpChildren(children[i], stream, count);
+
+ XtFree((char *)children);
+}
+
+/************************************************************
+ *
+ * Code for getting the geometry of widgets.
+ *
+ ************************************************************/
+
+/* Function Name: DoGetGeometry
+ * Description: retrieves the Geometry of each specified widget.
+ * Arguments: w - a widget in the tree.
+ * event - the event that caused this action.
+ * stream - the protocol stream to add.
+ * Returns: NULL
+ */
+
+static char *
+DoGetGeometry(w, event, stream)
+Widget w;
+EditresEvent * event;
+ProtocolStream * stream;
+{
+ unsigned i;
+ char * str;
+ GetGeomEvent * geom_event = (GetGeomEvent *) event;
+
+ _XEditResPut16(stream, geom_event->num_entries);
+
+ for (i = 0 ; i < geom_event->num_entries; i++) {
+
+ /*
+ * Send out the widget id.
+ */
+
+ _XEditResPutWidgetInfo(stream, &(geom_event->widgets[i]));
+ if ((str = VerifyWidget(w, &(geom_event->widgets[i]))) != NULL) {
+ _XEditResPutBool(stream, True); /* an error occured. */
+ _XEditResPutString8(stream, str); /* set message. */
+ XtFree(str);
+ }
+ else
+ ExecuteGetGeometry(geom_event->widgets[i].real_widget, stream);
+ }
+ return(NULL);
+}
+
+/* Function Name: ExecuteGetGeometry
+ * Description: Gets the geometry for each widget specified.
+ * Arguments: w - the widget to get geom on.
+ * stream - stream to append to.
+ * Returns: True if no error occured.
+ */
+
+static void
+ExecuteGetGeometry(w, stream)
+Widget w;
+ProtocolStream * stream;
+{
+ int i;
+ Boolean mapped_when_man;
+ Dimension width, height, border_width;
+ Arg args[8];
+ Cardinal num_args = 0;
+ Position x, y;
+
+ if ( !XtIsRectObj(w) || (XtIsWidget(w) && !XtIsRealized(w)) ) {
+ _XEditResPutBool(stream, False); /* no error. */
+ _XEditResPutBool(stream, False); /* not visable. */
+ for (i = 0; i < 5; i++) /* fill in extra space with 0's. */
+ _XEditResPut16(stream, 0);
+ return;
+ }
+
+ XtSetArg(args[num_args], XtNwidth, &width); num_args++;
+ XtSetArg(args[num_args], XtNheight, &height); num_args++;
+ XtSetArg(args[num_args], XtNborderWidth, &border_width); num_args++;
+ XtSetArg(args[num_args], XtNmappedWhenManaged, &mapped_when_man);
+ num_args++;
+ XtGetValues(w, args, num_args);
+
+ if (!(XtIsManaged(w) && mapped_when_man) && XtIsWidget(w)) {
+ XWindowAttributes attrs;
+
+ /*
+ * The toolkit does not maintain mapping state, we have
+ * to go to the server.
+ */
+
+ if (XGetWindowAttributes(XtDisplay(w), XtWindow(w), &attrs) != 0) {
+ if (attrs.map_state != IsViewable) {
+ _XEditResPutBool(stream, False); /* no error. */
+ _XEditResPutBool(stream, False); /* not visable. */
+ for (i = 0; i < 5; i++) /* fill in extra space with 0's. */
+ _XEditResPut16(stream, 0);
+ return;
+ }
+ }
+ else {
+ _XEditResPut8(stream, True); /* Error occured. */
+ _XEditResPutString8(stream, "XGetWindowAttributes failed.");
+ return;
+ }
+ }
+
+ XtTranslateCoords(w, -((int) border_width), -((int) border_width), &x, &y);
+
+ _XEditResPutBool(stream, False); /* no error. */
+ _XEditResPutBool(stream, True); /* Visable. */
+ _XEditResPut16(stream, x);
+ _XEditResPut16(stream, y);
+ _XEditResPut16(stream, width);
+ _XEditResPut16(stream, height);
+ _XEditResPut16(stream, border_width);
+}
+
+/************************************************************
+ *
+ * Code for executing FindChild.
+ *
+ ************************************************************/
+
+/* Function Name: PositionInChild
+ * Description: returns true if this location is in the child.
+ * Arguments: child - the child widget to check.
+ * x, y - location of point to check in the parent's
+ * coord space.
+ * Returns: TRUE if the position is in this child.
+ */
+
+static Boolean
+PositionInChild(child, x, y)
+Widget child;
+int x, y;
+{
+ Arg args[6];
+ Cardinal num;
+ Dimension width, height, border_width;
+ Position child_x, child_y;
+ Boolean mapped_when_managed;
+
+ if (!XtIsRectObj(child)) /* we must at least be a rect obj. */
+ return(FALSE);
+
+ num = 0;
+ XtSetArg(args[num], XtNmappedWhenManaged, &mapped_when_managed); num++;
+ XtSetArg(args[num], XtNwidth, &width); num++;
+ XtSetArg(args[num], XtNheight, &height); num++;
+ XtSetArg(args[num], XtNx, &child_x); num++;
+ XtSetArg(args[num], XtNy, &child_y); num++;
+ XtSetArg(args[num], XtNborderWidth, &border_width); num++;
+ XtGetValues(child, args, num);
+
+ /*
+ * The only way we will know of the widget is mapped is to see if
+ * mapped when managed is True and this is a managed child. Otherwise
+ * we will have to ask the server if this window is mapped.
+ */
+
+ if (XtIsWidget(child) && !(mapped_when_managed && XtIsManaged(child)) ) {
+ XWindowAttributes attrs;
+
+ if (XGetWindowAttributes(XtDisplay(child),
+ XtWindow(child), &attrs) != 0) {
+ /* oops */
+ }
+ else if (attrs.map_state != IsViewable)
+ return(FALSE);
+ }
+
+ return (x >= child_x) &&
+ (x <= (child_x + (Position)width + 2 * (Position)border_width)) &&
+ (y >= child_y) &&
+ (y <= (child_y + (Position)height + 2 * (Position)border_width));
+}
+
+/* Function Name: _FindChild
+ * Description: Finds the child that actually contatians the point shown.
+ * Arguments: parent - a widget that is known to contain the point
+ * specified.
+ * x, y - The point in coordinates relative to the
+ * widget specified.
+ * Returns: none.
+ */
+
+static Widget
+_FindChild(parent, x, y)
+Widget parent;
+int x, y;
+{
+ Widget * children;
+ int i = FindChildren(parent, &children, TRUE, FALSE);
+
+ while (i > 0) {
+ i--;
+
+ if (PositionInChild(children[i], x, y)) {
+ Widget child = children[i];
+
+ XtFree((char *)children);
+ return(_FindChild(child, x - child->core.x, y - child->core.y));
+ }
+ }
+
+ XtFree((char *)children);
+ return(parent);
+}
+
+/* Function Name: DoFindChild
+ * Description: finds the child that contains the location specified.
+ * Arguments: w - a widget in the tree.
+ * event - the event that caused this action.
+ * stream - the protocol stream to add.
+ * Returns: an allocated error message if something went horribly
+ * wrong and no set values were performed, else NULL.
+ */
+
+static char *
+DoFindChild(w, event, stream)
+Widget w;
+EditresEvent * event;
+ProtocolStream * stream;
+{
+ char * str;
+ Widget parent, child;
+ Position parent_x, parent_y;
+ FindChildEvent * find_event = (FindChildEvent *) event;
+
+ if ((str = VerifyWidget(w, find_event->widgets)) != NULL)
+ return(str);
+
+ parent = find_event->widgets->real_widget;
+
+ XtTranslateCoords(parent, (Position) 0, (Position) 0,
+ &parent_x, &parent_y);
+
+ child = _FindChild(parent, find_event->x - (int) parent_x,
+ find_event->y - (int) parent_y);
+
+ InsertWidget(stream, child);
+ return(NULL);
+}
+
+/************************************************************
+ *
+ * Procedures for performing GetResources.
+ *
+ ************************************************************/
+
+/* Function Name: DoGetResources
+ * Description: Gets the Resources associated with the widgets passed.
+ * Arguments: w - a widget in the tree.
+ * event - the event that caused this action.
+ * stream - the protocol stream to add.
+ * Returns: NULL
+ */
+
+static char *
+DoGetResources(w, event, stream)
+Widget w;
+EditresEvent * event;
+ProtocolStream * stream;
+{
+ unsigned int i;
+ char * str;
+ GetResEvent * res_event = (GetResEvent *) event;
+
+ _XEditResPut16(stream, res_event->num_entries); /* number of replys */
+
+ for (i = 0 ; i < res_event->num_entries; i++) {
+ /*
+ * Send out the widget id.
+ */
+ _XEditResPutWidgetInfo(stream, &(res_event->widgets[i]));
+ if ((str = VerifyWidget(w, &(res_event->widgets[i]))) != NULL) {
+ _XEditResPutBool(stream, True); /* an error occured. */
+ _XEditResPutString8(stream, str); /* set message. */
+ XtFree(str);
+ }
+ else {
+ _XEditResPutBool(stream, False); /* no error occured. */
+ ExecuteGetResources(res_event->widgets[i].real_widget,
+ stream);
+ }
+ }
+ return(NULL);
+}
+
+/* Function Name: ExecuteGetResources.
+ * Description: Gets the resources for any individual widget.
+ * Arguments: w - the widget to get resources on.
+ * stream - the protocol stream.
+ * Returns: none.
+ */
+
+static void
+ExecuteGetResources(w, stream)
+Widget w;
+ProtocolStream * stream;
+{
+ XtResourceList norm_list, cons_list;
+ Cardinal num_norm, num_cons;
+ register int i;
+
+ /*
+ * Get Normal Resources.
+ */
+
+ XtGetResourceList(XtClass(w), &norm_list, &num_norm);
+
+ if (XtParent(w) != NULL)
+ XtGetConstraintResourceList(XtClass(XtParent(w)),&cons_list,&num_cons);
+ else
+ num_cons = 0;
+
+ _XEditResPut16(stream, num_norm + num_cons); /* how many resources. */
+
+ /*
+ * Insert all the normal resources.
+ */
+
+ for ( i = 0; i < (int) num_norm; i++) {
+ _XEditResPutResourceType(stream, NormalResource);
+ _XEditResPutString8(stream, norm_list[i].resource_name);
+ _XEditResPutString8(stream, norm_list[i].resource_class);
+ _XEditResPutString8(stream, norm_list[i].resource_type);
+ }
+ XtFree((char *) norm_list);
+
+ /*
+ * Insert all the constraint resources.
+ */
+
+ if (num_cons > 0) {
+ for ( i = 0; i < (int) num_cons; i++) {
+ _XEditResPutResourceType(stream, ConstraintResource);
+ _XEditResPutString8(stream, cons_list[i].resource_name);
+ _XEditResPutString8(stream, cons_list[i].resource_class);
+ _XEditResPutString8(stream, cons_list[i].resource_type);
+ }
+ XtFree((char *) cons_list);
+ }
+}
+
+/*
+ * Function Name: DumpValues
+ * Description: Returns resource values to the resource editor.
+ * Arguments: event - the event that caused this action.
+ * stream - the protocol stream to add.
+ * Returns: NULL
+ */
+
+static char*
+DumpValues(w, event, stream) /* ARGSUSED */
+Widget w;
+EditresEvent* event;
+ProtocolStream* stream;
+{
+ Arg warg[1];
+ String res_value = NULL;
+ GetValuesEvent * gv_event = (GetValuesEvent *)event;
+
+ /* put the count in the stream. */
+
+ _XEditResPut16(stream, (unsigned int) 1);
+
+ /* get the resource of the widget asked for by the */
+ /* resource editor and insert it into the stream */
+ XtSetArg(warg[0], gv_event->name, &res_value);
+ /*_XtGetStringValues(gv_event->widgets[0].ids[0], warg, 1);*/
+ if (!res_value) res_value = "NoValue";
+ _XEditResPutString8(stream, res_value);
+ return(NULL);
+}
+
+/************************************************************
+ *
+ * Code for inserting values into the protocol stream.
+ *
+ ************************************************************/
+
+/* Function Name: InsertWidget
+ * Description: Inserts the full parent heirarchy of this
+ * widget into the protocol stream as a widget list.
+ * Arguments: stream - the protocol stream.
+ * w - the widget to insert.
+ * Returns: none
+ */
+
+static void
+InsertWidget(stream, w)
+ProtocolStream * stream;
+Widget w;
+{
+ Widget temp;
+ unsigned long * widget_list;
+ register int i, num_widgets;
+
+ for (temp = w, i = 0; temp != 0; temp = XtParent(temp), i++) {}
+
+ num_widgets = i;
+ widget_list = (unsigned long *)
+ XtMalloc(sizeof(unsigned long) * num_widgets);
+
+ /*
+ * Put the widgets into the list.
+ * make sure that they are inserted in the list from parent -> child.
+ */
+
+ for (i--, temp = w; temp != NULL; temp = XtParent(temp), i--)
+ widget_list[i] = (unsigned long) temp;
+
+ _XEditResPut16(stream, num_widgets); /* insert number of widgets. */
+ for (i = 0; i < num_widgets; i++) /* insert Widgets themselves. */
+ _XEditResPut32(stream, widget_list[i]);
+
+ XtFree((char *)widget_list);
+}
+
+/************************************************************
+ *
+ * All of the following routines are public.
+ *
+ ************************************************************/
+
+/* Function Name: _XEditResPutString8
+ * Description: Inserts a string into the protocol stream.
+ * Arguments: stream - stream to insert string into.
+ * str - string to insert.
+ * Returns: none.
+ */
+
+void
+_XEditResPutString8(stream, str)
+ProtocolStream * stream;
+char * str;
+{
+ int i, len = strlen(str);
+
+ _XEditResPut16(stream, len);
+ for (i = 0 ; i < len ; i++, str++)
+ _XEditResPut8(stream, *str);
+}
+
+/* Function Name: _XEditResPut8
+ * Description: Inserts an 8 bit integer into the protocol stream.
+ * Arguments: stream - stream to insert string into.
+ * value - value to insert.
+ * Returns: none
+ */
+
+void
+_XEditResPut8(stream, value)
+ProtocolStream * stream;
+unsigned int value;
+{
+ unsigned char temp;
+
+ if (stream->size >= stream->alloc) {
+ stream->alloc += 100;
+ stream->real_top = (unsigned char *) XtRealloc(
+ (char *)stream->real_top,
+ stream->alloc + HEADER_SIZE);
+ stream->top = stream->real_top + HEADER_SIZE;
+ stream->current = stream->top + stream->size;
+ }
+
+ temp = (unsigned char) (value & BYTE_MASK);
+ *((stream->current)++) = temp;
+ (stream->size)++;
+}
+
+/* Function Name: _XEditResPut16
+ * Description: Inserts a 16 bit integer into the protocol stream.
+ * Arguments: stream - stream to insert string into.
+ * value - value to insert.
+ * Returns: void
+ */
+
+void
+_XEditResPut16(stream, value)
+ProtocolStream * stream;
+unsigned int value;
+{
+ _XEditResPut8(stream, (value >> XER_NBBY) & BYTE_MASK);
+ _XEditResPut8(stream, value & BYTE_MASK);
+}
+
+/* Function Name: _XEditResPut32
+ * Description: Inserts a 32 bit integer into the protocol stream.
+ * Arguments: stream - stream to insert string into.
+ * value - value to insert.
+ * Returns: void
+ */
+
+void
+_XEditResPut32(stream, value)
+ProtocolStream * stream;
+unsigned long value;
+{
+ int i;
+
+ for (i = 3; i >= 0; i--)
+ _XEditResPut8(stream, (value >> (XER_NBBY*i)) & BYTE_MASK);
+}
+
+/* Function Name: _XEditResPutWidgetInfo
+ * Description: Inserts the widget info into the protocol stream.
+ * Arguments: stream - stream to insert widget info into.
+ * info - info to insert.
+ * Returns: none
+ */
+
+void
+_XEditResPutWidgetInfo(stream, info)
+ProtocolStream * stream;
+WidgetInfo * info;
+{
+ unsigned int i;
+
+ _XEditResPut16(stream, info->num_widgets);
+ for (i = 0; i < info->num_widgets; i++)
+ _XEditResPut32(stream, info->ids[i]);
+}
+
+/************************************************************
+ *
+ * Code for retrieving values from the protocol stream.
+ *
+ ************************************************************/
+
+/* Function Name: _XEditResResetStream
+ * Description: resets the protocol stream
+ * Arguments: stream - the stream to reset.
+ * Returns: none.
+ */
+
+void
+_XEditResResetStream(stream)
+ProtocolStream * stream;
+{
+ stream->current = stream->top;
+ stream->size = 0;
+ if (stream->real_top == NULL) {
+ stream->real_top = (unsigned char *) XtRealloc(
+ (char *)stream->real_top,
+ stream->alloc + HEADER_SIZE);
+ stream->top = stream->real_top + HEADER_SIZE;
+ stream->current = stream->top + stream->size;
+ }
+}
+
+/*
+ * NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE
+ *
+ * The only modified field if the "current" field.
+ *
+ * The only fields that must be set correctly are the "current", "top"
+ * and "size" fields.
+ */
+
+/* Function Name: _XEditResGetg8
+ * Description: Retrieves an unsigned 8 bit value
+ * from the protocol stream.
+ * Arguments: stream.
+ * val - a pointer to value to return.
+ * Returns: TRUE if sucessful.
+ */
+
+Boolean
+_XEditResGet8(stream, val)
+ProtocolStream * stream;
+unsigned char * val;
+{
+ if (stream->size < (stream->current - stream->top))
+ return(FALSE);
+
+ *val = *((stream->current)++);
+ return(TRUE);
+}
+
+/* Function Name: _XEditResGet16
+ * Description: Retrieves an unsigned 16 bit value
+ * from the protocol stream.
+ * Arguments: stream.
+ * val - a pointer to value to return.
+ * Returns: TRUE if sucessful.
+ */
+
+Boolean
+_XEditResGet16(stream, val)
+ProtocolStream * stream;
+unsigned short * val;
+{
+ unsigned char temp1, temp2;
+
+ if ( !(_XEditResGet8(stream, &temp1) && _XEditResGet8(stream, &temp2)) )
+ return(FALSE);
+
+ *val = (((unsigned short) temp1 << XER_NBBY) + ((unsigned short) temp2));
+ return(TRUE);
+}
+
+/* Function Name: _XEditResGetSigned16
+ * Description: Retrieves an signed 16 bit value from the protocol stream.
+ * Arguments: stream.
+ * val - a pointer to value to return.
+ * Returns: TRUE if sucessful.
+ */
+
+Boolean
+_XEditResGetSigned16(stream, val)
+ProtocolStream * stream;
+short * val;
+{
+ unsigned char temp1, temp2;
+
+ if ( !(_XEditResGet8(stream, &temp1) && _XEditResGet8(stream, &temp2)) )
+ return(FALSE);
+
+ if (temp1 & (1 << (XER_NBBY - 1))) { /* If the sign bit is active. */
+ *val = -1; /* store all 1's */
+ *val &= (temp1 << XER_NBBY); /* Now and in the MSB */
+ *val &= temp2; /* and LSB */
+ }
+ else
+ *val = (((unsigned short) temp1 << XER_NBBY) + ((unsigned short) temp2));
+
+ return(TRUE);
+}
+
+/* Function Name: _XEditResGet32
+ * Description: Retrieves an unsigned 32 bit value
+ * from the protocol stream.
+ * Arguments: stream.
+ * val - a pointer to value to return.
+ * Returns: TRUE if sucessful.
+ */
+
+Boolean
+_XEditResGet32(stream, val)
+ProtocolStream * stream;
+unsigned long * val;
+{
+ unsigned short temp1, temp2;
+
+ if ( !(_XEditResGet16(stream, &temp1) && _XEditResGet16(stream, &temp2)) )
+ return(FALSE);
+
+ *val = (((unsigned short) temp1 << (XER_NBBY * 2)) +
+ ((unsigned short) temp2));
+ return(TRUE);
+}
+
+/* Function Name: _XEditResGetString8
+ * Description: Retrieves an 8 bit string value from the protocol stream.
+ * Arguments: stream - the protocol stream
+ * str - the string to retrieve.
+ * Returns: True if retrieval was successful.
+ */
+
+Boolean
+_XEditResGetString8(stream, str)
+ProtocolStream * stream;
+char ** str;
+{
+ unsigned short len;
+ register unsigned i;
+
+ if (!_XEditResGet16(stream, &len)) {
+ return(FALSE);
+ }
+
+ *str = XtMalloc(sizeof(char) * (len + 1));
+
+ for (i = 0; i < len; i++) {
+ if (!_XEditResGet8(stream, (unsigned char *) *str + i)) {
+ XtFree(*str);
+ *str = NULL;
+ return(FALSE);
+ }
+ }
+ (*str)[i] = '\0'; /* NULL terminate that sucker. */
+ return(TRUE);
+}
+
+/* Function Name: _XEditResGetWidgetInfo
+ * Description: Retrieves the list of widgets that follow and stores
+ * them in the widget info structure provided.
+ * Arguments: stream - the protocol stream
+ * info - the widget info struct to store into.
+ * Returns: True if retrieval was successful.
+ */
+
+Boolean
+_XEditResGetWidgetInfo(stream, info)
+ProtocolStream * stream;
+WidgetInfo * info;
+{
+ unsigned int i;
+
+ if (!_XEditResGet16(stream, &(info->num_widgets)))
+ return(FALSE);
+
+ info->ids = (unsigned long *) XtMalloc(sizeof(long) * (info->num_widgets));
+
+ for (i = 0; i < info->num_widgets; i++) {
+ if (!_XEditResGet32(stream, info->ids + i)) {
+ XtFree((char *)info->ids);
+ info->ids = NULL;
+ return(FALSE);
+ }
+#if defined(LONG64) || defined(WORD64)
+ info->ids[i] |= globals.base_address;
+#endif
+ }
+ return(TRUE);
+}
+
+/************************************************************
+ *
+ * Code for Loading the EditresBlock resource.
+ *
+ ************************************************************/
+
+/* Function Name: CvStringToBlock
+ * Description: Converts a string to an editres block value.
+ * Arguments: dpy - the display.
+ * args, num_args - **UNUSED **
+ * from_val, to_val - value to convert, and where to put result
+ * converter_data - ** UNUSED **
+ * Returns: TRUE if conversion was sucessful.
+ */
+
+/* ARGSUSED */
+static Boolean
+CvtStringToBlock(dpy, args, num_args, from_val, to_val, converter_data)
+Display * dpy;
+XrmValue * args;
+Cardinal * num_args;
+XrmValue * from_val, * to_val;
+XtPointer * converter_data;
+{
+ char ptr[40];
+ static EditresBlock block;
+
+ if (strlen ((char*)from_val->addr) >= sizeof ptr) {
+ to_val->size = 0;
+ to_val->addr = NULL;
+ return FALSE;
+ }
+
+ XmuCopyISOLatin1Lowered(ptr, from_val->addr);
+
+ if (streq(ptr, "none"))
+ block = BlockNone;
+ else if (streq(ptr, "setvalues"))
+ block = BlockSetValues;
+ else if (streq(ptr, "all"))
+ block = BlockAll;
+ else {
+ Cardinal num_params = 1;
+ String params[1];
+
+ params[0] = from_val->addr;
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ "CvtStringToBlock", "unknownValue", "EditresError",
+ "Could not convert string \"%s\" to EditresBlock.",
+ params, &num_params);
+ return FALSE;
+ }
+
+ if (to_val->addr != NULL) {
+ if (to_val->size < sizeof(EditresBlock)) {
+ to_val->size = sizeof(EditresBlock);
+ return FALSE;
+ }
+ *(EditresBlock *)(to_val->addr) = block;
+ }
+ else
+ to_val->addr = (XtPointer) block;
+
+ to_val->size = sizeof block;
+ return TRUE;
+}
+
+#define XtREditresBlock ("EditresBlock")
+
+/* Function Name: LoadResources
+ * Description: Loads a global resource the determines of this
+ * application should allow Editres requests.
+ * Arguments: w - any widget in the tree.
+ * Returns: none.
+ */
+
+static void
+LoadResources(w)
+Widget w;
+{
+ static XtResource resources[] = {
+ {"editresBlock", "EditresBlock", XtREditresBlock, sizeof(EditresBlock),
+ XtOffsetOf(Globals, block), XtRImmediate, (XtPointer) BlockNone}
+ };
+
+ for (; XtParent(w) != NULL; w = XtParent(w)) {}
+
+ XtAppSetTypeConverter(XtWidgetToApplicationContext(w),
+ XtRString, XtREditresBlock, CvtStringToBlock,
+ NULL, (Cardinal) 0, XtCacheAll, NULL);
+
+ XtGetApplicationResources( w, (XtPointer) &globals, resources,
+ XtNumber(resources), NULL, (Cardinal) 0);
+}
+
+
diff --git a/src/ExtAgent.c b/src/ExtAgent.c
new file mode 100644
index 0000000..ab9532d
--- /dev/null
+++ b/src/ExtAgent.c
@@ -0,0 +1,44 @@
+/* $Xorg: ExtAgent.c,v 1.4 2001/02/09 02:03:52 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 <X11/Intrinsic.h>
+
+/* ARGSUSED */
+void
+XmuRegisterExternalAgent(w, data, event, cont)
+ Widget w;
+ XtPointer data;
+ XEvent *event;
+ Boolean *cont;
+{
+/*
+* This is a stub. Writers of protocol libraries
+* that want to add protocol to Xaw, such as RAP, will reimplement this
+* procedure in their own libraries.
+*/
+}
diff --git a/src/FToCback.c b/src/FToCback.c
new file mode 100644
index 0000000..68e7ac2
--- /dev/null
+++ b/src/FToCback.c
@@ -0,0 +1,46 @@
+/* $Xorg: FToCback.c,v 1.4 2001/02/09 02:03:52 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 <X11/Intrinsic.h>
+
+/* ARGSUSED */
+void
+XmuCvtFunctionToCallback(args, num_args, fromVal, toVal)
+ XrmValue *args; /* unused */
+ Cardinal *num_args; /* unused */
+ XrmValuePtr fromVal;
+ XrmValuePtr toVal;
+{
+ static XtCallbackRec callback[2]; /* K&R: initialized to NULL */
+ static XtCallbackList callback_list = callback;
+
+ callback[0].callback = *(XtCallbackProc *)fromVal->addr;
+
+ toVal->size = sizeof(XtCallbackList);
+ toVal->addr = (XPointer)&callback_list;
+}
diff --git a/src/GetHost.c b/src/GetHost.c
new file mode 100644
index 0000000..cdad709
--- /dev/null
+++ b/src/GetHost.c
@@ -0,0 +1,77 @@
+/* $Xorg: GetHost.c,v 1.4 2001/02/09 02:03:52 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.
+
+*/
+
+/*
+ * Author: Jim Fulton, MIT X Consortium
+ *
+ * _XGetHostname - similar to gethostname but allows special processing.
+ */
+
+#ifdef WIN32
+#include <X11/Xwinsock.h>
+#endif
+
+#ifdef USG
+#define NEED_UTSNAME
+#endif
+
+#ifdef NEED_UTSNAME
+#include <sys/utsname.h>
+#endif
+
+int XmuGetHostname (buf, maxlen)
+ char *buf;
+ int maxlen;
+{
+ int len;
+#ifdef WIN32
+ static WSADATA wsadata;
+
+ if (!wsadata.wVersion && WSAStartup(MAKEWORD(1,1), &wsadata))
+ return -1;
+#endif
+
+#ifdef NEED_UTSNAME
+ /*
+ * same host name crock as in server and xinit.
+ */
+ struct utsname name;
+
+ uname (&name);
+ len = strlen (name.nodename);
+ if (len >= maxlen) len = maxlen - 1;
+ strncpy (buf, name.nodename, len);
+ buf[len] = '\0';
+#else
+ buf[0] = '\0';
+ (void) gethostname (buf, maxlen);
+ buf [maxlen - 1] = '\0';
+ len = strlen(buf);
+#endif /* hpux */
+ return len;
+}
diff --git a/src/GrayPixmap.c b/src/GrayPixmap.c
new file mode 100644
index 0000000..22c0c44
--- /dev/null
+++ b/src/GrayPixmap.c
@@ -0,0 +1,137 @@
+/* $Xorg: GrayPixmap.c,v 1.4 2001/02/09 02:03:52 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 <stdio.h>
+#include <X11/Intrinsic.h>
+#include <X11/Xmu/Drawing.h>
+
+typedef struct _PixmapCache {
+ Screen *screen;
+ Pixmap pixmap;
+ Pixel foreground, background;
+ unsigned int depth;
+ int ref_count;
+ struct _PixmapCache *next;
+ } CacheEntry;
+
+static CacheEntry *pixmapCache = NULL;
+
+
+
+Pixmap XmuCreateStippledPixmap(screen, fore, back, depth)
+ Screen *screen;
+ Pixel fore, back;
+ unsigned int depth;
+/*
+ * Creates a stippled pixmap of specified depth
+ * caches these so that multiple requests share the pixmap
+ */
+{
+ register Display *display = DisplayOfScreen(screen);
+ CacheEntry *cachePtr;
+ Pixmap stippled_pixmap;
+ static unsigned char pixmap_bits[] = {
+ 0x02, 0x01,
+ };
+
+/*
+ * Creates a stippled pixmap of depth DefaultDepth(screen)
+ * caches these so that multiple requests share the pixmap
+ */
+
+#define pixmap_width 2
+#define pixmap_height 2
+
+ /* see if we already have a pixmap suitable for this screen */
+ for (cachePtr = pixmapCache; cachePtr; cachePtr = cachePtr->next) {
+ if (cachePtr->screen == screen && cachePtr->foreground == fore &&
+ cachePtr->background == back && cachePtr->depth == depth)
+ return( cachePtr->ref_count++, cachePtr->pixmap );
+ }
+
+ stippled_pixmap = XCreatePixmapFromBitmapData (display,
+ RootWindowOfScreen(screen), (char *)pixmap_bits,
+ pixmap_width, pixmap_height, fore, back, depth);
+
+ /* and insert it at the head of the cache */
+ cachePtr = XtNew(CacheEntry);
+ cachePtr->screen = screen;
+ cachePtr->foreground = fore;
+ cachePtr->background = back;
+ cachePtr->depth = depth;
+ cachePtr->pixmap = stippled_pixmap;
+ cachePtr->ref_count = 1;
+ cachePtr->next = pixmapCache;
+ pixmapCache = cachePtr;
+
+ return( stippled_pixmap );
+}
+
+void XmuReleaseStippledPixmap(screen, pixmap)
+ Screen *screen;
+ Pixmap pixmap;
+{
+ register Display *display = DisplayOfScreen(screen);
+ CacheEntry *cachePtr, **prevP;
+ for (prevP = &pixmapCache, cachePtr = pixmapCache; cachePtr;) {
+ if (cachePtr->screen == screen && cachePtr->pixmap == pixmap) {
+ if (--cachePtr->ref_count == 0) {
+ XFreePixmap( display, pixmap );
+ *prevP = cachePtr->next;
+ XtFree( (char*)cachePtr );
+ break;
+ }
+ }
+ prevP = &cachePtr->next;
+ cachePtr = *prevP;
+ }
+}
diff --git a/src/Initer.c b/src/Initer.c
new file mode 100644
index 0000000..bcf612d
--- /dev/null
+++ b/src/Initer.c
@@ -0,0 +1,106 @@
+/* $Xorg: Initer.c,v 1.4 2001/02/09 02:03:52 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.
+
+*/
+
+/* Created By: Chris D. Peterson
+ * MIT X Consortium
+ * Date: May 8, 1989
+ */
+
+#include <X11/Intrinsic.h>
+#include <X11/Xmu/Initer.h>
+
+struct InitializerList {
+ XmuInitializerProc function; /* function to call */
+ XPointer data; /* Data to pass the function. */
+ XtAppContext * app_con_list; /* a null terminated list of app_contexts. */
+};
+
+static struct InitializerList * init_list = NULL;
+static Cardinal init_list_length = 0;
+
+static Boolean AddToAppconList();
+
+void
+XmuAddInitializer(func, data)
+XmuInitializerProc func;
+XPointer data;
+{
+ init_list_length++;
+ init_list = (struct InitializerList *) XtRealloc( (char *) init_list,
+ (sizeof(struct InitializerList) *
+ init_list_length) );
+
+ init_list[init_list_length - 1].function = func;
+ init_list[init_list_length - 1].data = data;
+ init_list[init_list_length - 1].app_con_list = NULL;
+}
+
+void
+XmuCallInitializers(app_con)
+XtAppContext app_con;
+{
+ int i;
+
+ for (i = 0 ; i < init_list_length ; i++) {
+ if (AddToAppconList(&(init_list[i].app_con_list), app_con))
+ (init_list[i].function) (app_con, init_list[i].data);
+ }
+}
+
+/* Function Name: AddToAppconList
+ * Description: Adds an action to the application context list and
+ * returns TRUE, if this app_con is already on the list then
+ * it is NOT added and FALSE is returned.
+ * Arguments: app_list - a NULL terminated list of application contexts.
+ * app_con - an application context to test.
+ * Returns: TRUE if not found, FALSE if found.
+ */
+
+static Boolean
+AddToAppconList(app_list, app_con)
+XtAppContext **app_list, app_con;
+{
+ int i;
+ XtAppContext *local_list;
+
+ i = 0;
+ local_list = *app_list;
+ if (*app_list != NULL) {
+ for ( ; *local_list != NULL ; i++, local_list++) {
+ if (*local_list == app_con)
+ return(FALSE);
+ }
+ }
+
+ *app_list = (XtAppContext *) XtRealloc((char *)(*app_list),
+ sizeof(XtAppContext *) * (i + 2) );
+ (*app_list)[i++] = app_con;
+ (*app_list)[i] = NULL;
+ return(TRUE);
+}
+
diff --git a/src/LocBitmap.c b/src/LocBitmap.c
new file mode 100644
index 0000000..30efcaa
--- /dev/null
+++ b/src/LocBitmap.c
@@ -0,0 +1,294 @@
+/* $Xorg: LocBitmap.c,v 1.7 2001/02/09 02:03:52 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.
+
+*/
+
+/*
+ * Author: Jim Fulton, MIT X Consortium
+ */
+
+#include <X11/Xlib.h>
+#include <X11/Xresource.h>
+#include <X11/Xutil.h>
+#include <X11/Xmu/CvtCache.h>
+#include <X11/Xmu/Drawing.h>
+#ifndef X_NOT_STDC_ENV
+#include <stdlib.h>
+#else
+extern char* malloc();
+extern void free();
+#endif
+
+#ifndef X_NOT_POSIX
+#ifdef _POSIX_SOURCE
+#include <limits.h>
+#else
+#define _POSIX_SOURCE
+#include <limits.h>
+#undef _POSIX_SOURCE
+#endif
+#endif /* X_NOT_POSIX */
+#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 /* PATH_MAX */
+
+static char **split_path_string();
+
+
+/*
+ * XmuLocateBitmapFile - read a bitmap file using the normal defaults
+ */
+
+#if NeedFunctionPrototypes
+Pixmap XmuLocateBitmapFile (Screen *screen, _Xconst char *name, char *srcname,
+ int srcnamelen, int *widthp, int *heightp,
+ int *xhotp, int *yhotp)
+#else
+Pixmap XmuLocateBitmapFile (screen, name, srcname, srcnamelen,
+ widthp, heightp, xhotp, yhotp)
+ Screen *screen;
+ char *name;
+ char *srcname; /* RETURN */
+ int srcnamelen;
+ int *widthp, *heightp, *xhotp, *yhotp; /* RETURN */
+#endif
+{
+ return XmuLocatePixmapFile (screen, name,
+ (unsigned long) 1, (unsigned long) 0,
+ (unsigned int) 1, srcname, srcnamelen,
+ widthp, heightp, xhotp, yhotp);
+}
+
+
+/*
+ * version that reads pixmap data as well as bitmap data
+ */
+#if NeedFunctionPrototypes
+Pixmap XmuLocatePixmapFile (Screen *screen, _Xconst char *name,
+ unsigned long fore, unsigned long back,
+ unsigned int depth,
+ char *srcname, int srcnamelen,
+ int *widthp, int *heightp, int *xhotp, int *yhotp)
+#else
+Pixmap XmuLocatePixmapFile (screen, name, fore, back, depth,
+ srcname, srcnamelen,
+ widthp, heightp, xhotp, yhotp)
+ Screen *screen;
+ char *name;
+ unsigned long fore, back;
+ unsigned int depth;
+ char *srcname; /* RETURN */
+ int srcnamelen;
+ int *widthp, *heightp, *xhotp, *yhotp; /* RETURN */
+#endif
+{
+
+#ifndef BITMAPDIR
+#define BITMAPDIR "/usr/include/X11/bitmaps"
+#endif
+
+ Display *dpy = DisplayOfScreen (screen);
+ Window root = RootWindowOfScreen (screen);
+ Bool try_plain_name = True;
+ XmuCvtCache *cache = _XmuCCLookupDisplay (dpy);
+ char **file_paths = (char **) NULL;
+ char filenamebuf[PATH_MAX];
+ char* filename = NULL;
+ char* bitmapdir = BITMAPDIR;
+ unsigned int width, height;
+ int xhot, yhot;
+ int i, tmp;
+
+ /*
+ * look in cache for bitmap path
+ */
+ if (cache) {
+ if (!cache->string_to_bitmap.bitmapFilePath) {
+ XrmName xrm_name[2];
+ XrmClass xrm_class[2];
+ XrmRepresentation rep_type;
+ XrmValue value;
+
+ xrm_name[0] = XrmPermStringToQuark ("bitmapFilePath");
+ xrm_name[1] = NULLQUARK;
+ xrm_class[0] = XrmPermStringToQuark ("BitmapFilePath");
+ xrm_class[1] = NULLQUARK;
+ if (!XrmGetDatabase(dpy)) {
+ /* what a hack; need to initialize it */
+ (void) XGetDefault (dpy, "", "");
+ }
+ if (XrmQGetResource (XrmGetDatabase(dpy), xrm_name, xrm_class,
+ &rep_type, &value) &&
+ rep_type == XrmPermStringToQuark("String")) {
+ cache->string_to_bitmap.bitmapFilePath =
+ split_path_string (value.addr);
+ }
+ }
+ file_paths = cache->string_to_bitmap.bitmapFilePath;
+ }
+
+ /*
+ * Search order:
+ * 1. name if it begins with / or ./
+ * 2. "each prefix in file_paths"/name
+ * 3. BITMAPDIR/name
+ * 4. name if didn't begin with / or .
+ */
+
+ for (i = 1; i <= 4; i++) {
+ char *fn = NULL;
+ Pixmap pixmap;
+ unsigned char *data;
+
+ switch (i) {
+ case 1:
+ if (!(name[0] == '/' || (name[0] == '.') && name[1] == '/'))
+ continue;
+ fn = (char *) name;
+ try_plain_name = False;
+ break;
+ case 2:
+ if (file_paths && *file_paths) {
+ tmp = strlen (*file_paths) + strlen (name) + 1;
+ if (tmp < sizeof filenamebuf) filename = filenamebuf;
+ else filename = malloc (tmp + 1);
+ sprintf (filename, "%s/%s", *file_paths, name);
+ fn = filename;
+ file_paths++;
+ i--;
+ break;
+ }
+ continue;
+ case 3:
+ tmp = strlen (bitmapdir) + strlen (name) + 1;
+ if (tmp < sizeof filenamebuf) filename = filenamebuf;
+ else filename = malloc (tmp + 1);
+ sprintf (filename, "%s/%s", bitmapdir, name);
+ fn = filename;
+ break;
+ case 4:
+ if (!try_plain_name) continue;
+ fn = (char *) name;
+ break;
+ }
+
+ data = NULL;
+ pixmap = None;
+ if (fn == NULL)
+ continue;
+ if (XmuReadBitmapDataFromFile (fn, &width, &height, &data,
+ &xhot, &yhot) == BitmapSuccess) {
+ pixmap = XCreatePixmapFromBitmapData (dpy, root, (char *) data,
+ width, height,
+ fore, back, depth);
+ XFree ((char *)data);
+ }
+ if (filename && filename != filenamebuf) {
+ free (filename);
+ filename = NULL;
+ }
+
+ if (pixmap) {
+ if (widthp) *widthp = (int)width;
+ if (heightp) *heightp = (int)height;
+ if (xhotp) *xhotp = xhot;
+ if (yhotp) *yhotp = yhot;
+ if (srcname && srcnamelen > 0) {
+ strncpy (srcname, fn, srcnamelen - 1);
+ srcname[srcnamelen - 1] = '\0';
+ }
+ return pixmap;
+ }
+ }
+
+ return None;
+}
+
+
+/*
+ * split_path_string - split a colon-separated list into its constituent
+ * parts; to release, free list[0] and list.
+ */
+static char **split_path_string (src)
+ register char *src;
+{
+ int nelems = 1;
+ register char *dst;
+ char **elemlist, **elem;
+
+ /* count the number of elements */
+ for (dst = src; *dst; dst++) if (*dst == ':') nelems++;
+
+ /* get memory for everything */
+ dst = (char *) malloc (dst - src + 1);
+ if (!dst) return NULL;
+ elemlist = (char **) calloc ((nelems + 1), sizeof (char *));
+ if (!elemlist) {
+ free (dst);
+ return NULL;
+ }
+
+ /* copy to new list and walk up nulling colons and setting list pointers */
+ strcpy (dst, src);
+ for (elem = elemlist, src = dst; *src; src++) {
+ if (*src == ':') {
+ *elem++ = dst;
+ *src = '\0';
+ dst = src + 1;
+ }
+ }
+ *elem = dst;
+
+ return elemlist;
+}
+
+
+void _XmuStringToBitmapInitCache (c)
+ register XmuCvtCache *c;
+{
+ c->string_to_bitmap.bitmapFilePath = NULL;
+}
+
+void _XmuStringToBitmapFreeCache (c)
+ register XmuCvtCache *c;
+{
+ if (c->string_to_bitmap.bitmapFilePath) {
+ if (c->string_to_bitmap.bitmapFilePath[0])
+ free (c->string_to_bitmap.bitmapFilePath[0]);
+ free ((char *) (c->string_to_bitmap.bitmapFilePath));
+ }
+}
diff --git a/src/Lookup.c b/src/Lookup.c
new file mode 100644
index 0000000..66bf42a
--- /dev/null
+++ b/src/Lookup.c
@@ -0,0 +1,317 @@
+/* $Xorg: Lookup.c,v 1.4 2001/02/09 02:03:53 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 <X11/Xlib.h>
+#include <X11/Xutil.h>
+#define XK_LATIN1
+#define XK_PUBLISHING
+#include <X11/keysymdef.h>
+
+#ifdef __STDC__
+#define Const const
+#else
+#define Const /**/
+#endif
+
+/* bit (1<<i) means character is in codeset i */
+static unsigned short Const latin1[128] =
+ {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x10ee, 0x0000, 0x1000, 0x1084, 0x102e, 0x1000, 0x1080, 0x108e, /* 10 */
+ 0x108e, 0x1080, 0x0000, 0x1080, 0x1080, 0x10ee, 0x1000, 0x1008,
+ 0x108e, 0x1080, 0x1084, 0x1084, 0x108e, 0x1004, 0x1000, 0x1084, /* 11 */
+ 0x100e, 0x1000, 0x0000, 0x1080, 0x1000, 0x1084, 0x1000, 0x0000,
+ 0x0004, 0x000e, 0x000e, 0x0008, 0x000e, 0x0008, 0x0008, 0x0006, /* 12 */
+ 0x0004, 0x000e, 0x0004, 0x000e, 0x0004, 0x000e, 0x000e, 0x0004,
+ 0x0000, 0x0004, 0x0004, 0x0006, 0x000e, 0x0008, 0x000e, 0x000e, /* 13 */
+ 0x0008, 0x0004, 0x000e, 0x000c, 0x000e, 0x0002, 0x0000, 0x000e,
+ 0x0004, 0x000e, 0x000e, 0x0008, 0x000e, 0x0008, 0x0008, 0x0006, /* 14 */
+ 0x0004, 0x000e, 0x0004, 0x000e, 0x0004, 0x000e, 0x000e, 0x0004,
+ 0x0000, 0x0004, 0x0004, 0x0006, 0x000e, 0x0008, 0x000e, 0x000e, /* 15 */
+ 0x0008, 0x0004, 0x000e, 0x000c, 0x000e, 0x0002, 0x0000, 0x0000};
+
+/* bit (1<<i) means character is in codeset i */
+static unsigned short Const latin2[128] =
+ {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0008, 0x0004, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 10 */
+ 0x0000, 0x0008, 0x0004, 0x0000, 0x0000, 0x0000, 0x0008, 0x0004,
+ 0x0000, 0x0008, 0x0008, 0x0000, 0x0000, 0x0000, 0x0000, 0x0008, /* 11 */
+ 0x0000, 0x0008, 0x0004, 0x0000, 0x0000, 0x0000, 0x0008, 0x0004,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 12 */
+ 0x0008, 0x0000, 0x0008, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0008, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 13 */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 14 */
+ 0x0008, 0x0000, 0x0008, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0008, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 15 */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x000c};
+
+/* maps Cyrillic keysyms to 8859-5 */
+static unsigned char Const cyrillic[128] =
+ {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, 0xf2, 0xf3, 0xf1, 0xf4, 0xf5, 0xf6, 0xf7, /* 10 */
+ 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0x00, 0xfe, 0xff,
+ 0xf0, 0xa2, 0xa3, 0xa1, 0xa4, 0xa5, 0xa6, 0xa7, /* 11 */
+ 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0x00, 0xae, 0xaf,
+ 0xee, 0xd0, 0xd1, 0xe6, 0xd4, 0xd5, 0xe4, 0xd3, /* 12 */
+ 0xe5, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde,
+ 0xdf, 0xef, 0xe0, 0xe1, 0xe2, 0xe3, 0xd6, 0xd2, /* 13 */
+ 0xec, 0xeb, 0xd7, 0xe8, 0xed, 0xe9, 0xe7, 0xea,
+ 0xce, 0xb0, 0xb1, 0xc6, 0xb4, 0xb5, 0xc4, 0xb3, /* 14 */
+ 0xc5, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe,
+ 0xbf, 0xcf, 0xc0, 0xc1, 0xc2, 0xc3, 0xb6, 0xb2, /* 15 */
+ 0xcc, 0xcb, 0xb7, 0xc8, 0xcd, 0xc9, 0xc7, 0xca};
+
+/* maps Greek keysyms to 8859-7 */
+static unsigned char Const greek[128] =
+ {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, 0xb6, 0xb8, 0xb9, 0xba, 0xda, 0x00, 0xbc, /* 10 */
+ 0xbe, 0xdb, 0x00, 0xbf, 0x00, 0x00, 0xb5, 0xaf,
+ 0x00, 0xdc, 0xdd, 0xde, 0xdf, 0xfa, 0xc0, 0xfc, /* 11 */
+ 0xfd, 0xfb, 0xe0, 0xfe, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 12 */
+ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
+ 0xd0, 0xd1, 0xd3, 0x00, 0xd4, 0xd5, 0xd6, 0xd7, /* 13 */
+ 0xd8, 0xd9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 14 */
+ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
+ 0xf0, 0xf1, 0xf3, 0xf2, 0xf4, 0xf5, 0xf6, 0xf7, /* 15 */
+ 0xf8, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+#define sLatin1 (unsigned long)0
+#define sLatin2 (unsigned long)1
+#define sLatin3 (unsigned long)2
+#define sLatin4 (unsigned long)3
+#define sKana (unsigned long)4
+#define sX0201 (unsigned long)0x01000004
+#define sArabic (unsigned long)5
+#define sCyrillic (unsigned long)6
+#define sGreek (unsigned long)7
+#define sAPL (unsigned long)11
+#define sHebrew (unsigned long)12
+
+int XmuLookupString (event, buffer, nbytes, keysym, status, keysymSet)
+ register XKeyEvent *event;
+ char *buffer;
+ int nbytes;
+ KeySym *keysym;
+ XComposeStatus *status;
+ unsigned long keysymSet;
+{
+ int count;
+ KeySym symbol;
+ unsigned long kset;
+
+ kset = keysymSet & 0xffffff;
+ count = XLookupString(event, buffer, nbytes, &symbol, status);
+ if (keysym) *keysym = symbol;
+ if ((nbytes == 0) || (symbol == NoSymbol)) {
+ /* nothing */
+ } else if ((count == 0) && ((symbol >> 8) == kset)) {
+ count = 1;
+ switch (keysymSet) {
+ case sKana:
+ buffer[0] = (symbol & 0xff);
+ if (buffer[0] == 0x7e)
+ count = 0;
+ break;
+ case sCyrillic:
+ buffer[0] = cyrillic[symbol & 0x7f];
+ break;
+ case sGreek:
+ buffer[0] = greek[symbol & 0x7f];
+ if (!buffer[0])
+ count = 0;
+ break;
+ default:
+ buffer[0] = (symbol & 0xff);
+ break;
+ }
+ } else if ((keysymSet != 0) && (count == 1) &&
+ (((unsigned char *)buffer)[0] == symbol) &&
+ (symbol & 0x80) &&
+ !(latin1[symbol & 0x7f] & (1 << kset))) {
+ if ((keysymSet == sHebrew) && (symbol == XK_multiply))
+ buffer[0] = 0xaa;
+ else if ((keysymSet == sHebrew) && (symbol == XK_division))
+ buffer[0] = 0xba;
+ else if ((keysymSet == sCyrillic) && (symbol == XK_section))
+ buffer[0] = 0xfd;
+ else if ((keysymSet == sX0201) && (symbol == XK_yen))
+ buffer[0] = 0x5c;
+ else
+ count = 0;
+ } else if (count != 0) {
+ if ((keysymSet == sX0201) &&
+ ((symbol == XK_backslash) || (symbol == XK_asciitilde)))
+ count = 0;
+ } else if (((symbol >> 8) == sLatin2) &&
+ (symbol & 0x80) && (latin2[symbol & 0x7f] & (1 << kset))) {
+ buffer[0] = (symbol & 0xff);
+ count = 1;
+ } else if ((keysymSet == sGreek) &&
+ ((symbol == XK_leftsinglequotemark) ||
+ (symbol == XK_rightsinglequotemark))) {
+ buffer[0] = symbol - (XK_leftsinglequotemark - 0xa1);
+ count = 1;
+ }
+ return count;
+}
+
+/* produces ISO 8859-1 encoding plus ASCII control */
+int XmuLookupLatin1 (event, buffer, nbytes, keysym, status)
+ register XKeyEvent *event;
+ char *buffer;
+ int nbytes;
+ KeySym *keysym;
+ XComposeStatus *status;
+{
+ return XLookupString(event, buffer, nbytes, keysym, status);
+}
+
+/* produces ISO 8859-2 encoding plus ASCII control */
+int XmuLookupLatin2 (event, buffer, nbytes, keysym, status)
+ register XKeyEvent *event;
+ char *buffer;
+ int nbytes;
+ KeySym *keysym;
+ XComposeStatus *status;
+{
+ return XmuLookupString(event, buffer, nbytes, keysym, status, sLatin2);
+}
+
+/* produces ISO 8859-3 encoding plus ASCII control */
+int XmuLookupLatin3 (event, buffer, nbytes, keysym, status)
+ register XKeyEvent *event;
+ char *buffer;
+ int nbytes;
+ KeySym *keysym;
+ XComposeStatus *status;
+{
+ return XmuLookupString(event, buffer, nbytes, keysym, status, sLatin3);
+}
+
+/* produces ISO 8859-4 encoding plus ASCII control */
+int XmuLookupLatin4 (event, buffer, nbytes, keysym, status)
+ register XKeyEvent *event;
+ char *buffer;
+ int nbytes;
+ KeySym *keysym;
+ XComposeStatus *status;
+{
+ return XmuLookupString(event, buffer, nbytes, keysym, status, sLatin4);
+}
+
+/* produces ISO 8859-1 GL plus Katakana plus ASCII control */
+int XmuLookupKana (event, buffer, nbytes, keysym, status)
+ register XKeyEvent *event;
+ char *buffer;
+ int nbytes;
+ KeySym *keysym;
+ XComposeStatus *status;
+{
+ return XmuLookupString(event, buffer, nbytes, keysym, status, sKana);
+}
+
+/* produces JIS X0201-1976 (8-bit) */
+int XmuLookupJISX0201 (event, buffer, nbytes, keysym, status)
+ register XKeyEvent *event;
+ char *buffer;
+ int nbytes;
+ KeySym *keysym;
+ XComposeStatus *status;
+{
+ return XmuLookupString(event, buffer, nbytes, keysym, status, sX0201);
+}
+
+/* produces ISO 8859-6 encoding plus ASCII control */
+int XmuLookupArabic (event, buffer, nbytes, keysym, status)
+ register XKeyEvent *event;
+ char *buffer;
+ int nbytes;
+ KeySym *keysym;
+ XComposeStatus *status;
+{
+ return XmuLookupString(event, buffer, nbytes, keysym, status, sArabic);
+}
+
+/* produces ISO/IEC 8859-5 encoding plus ASCII control */
+int XmuLookupCyrillic (event, buffer, nbytes, keysym, status)
+ register XKeyEvent *event;
+ char *buffer;
+ int nbytes;
+ KeySym *keysym;
+ XComposeStatus *status;
+{
+ return XmuLookupString(event, buffer, nbytes, keysym, status, sCyrillic);
+}
+
+/* produces ISO 8859-7 encoding plus ASCII control */
+int XmuLookupGreek (event, buffer, nbytes, keysym, status)
+ register XKeyEvent *event;
+ char *buffer;
+ int nbytes;
+ KeySym *keysym;
+ XComposeStatus *status;
+{
+ return XmuLookupString(event, buffer, nbytes, keysym, status, sGreek);
+}
+
+/* XXX this character set needs work */
+
+int XmuLookupAPL (event, buffer, nbytes, keysym, status)
+ register XKeyEvent *event;
+ char *buffer;
+ int nbytes;
+ KeySym *keysym;
+ XComposeStatus *status;
+{
+ return XmuLookupString(event, buffer, nbytes, keysym, status, sAPL);
+}
+
+/* produces ISO 8859-8 encoding plus ASCII control */
+int XmuLookupHebrew (event, buffer, nbytes, keysym, status)
+ register XKeyEvent *event;
+ char *buffer;
+ int nbytes;
+ KeySym *keysym;
+ XComposeStatus *status;
+{
+ return XmuLookupString(event, buffer, nbytes, keysym, status, sHebrew);
+}
diff --git a/src/LookupCmap.c b/src/LookupCmap.c
new file mode 100644
index 0000000..4c57f4f
--- /dev/null
+++ b/src/LookupCmap.c
@@ -0,0 +1,310 @@
+/* $Xorg: LookupCmap.c,v 1.4 2001/02/09 02:03:53 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.
+
+*/
+
+/*
+ * Author: Donna Converse, MIT X Consortium
+ */
+
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+#include <X11/Xmu/StdCmap.h>
+
+extern char *malloc();
+static Status lookup();
+
+/*
+ * To create a standard colormap if one does not currently exist, or
+ * replace the currently existing standard colormap, use
+ * XmuLookupStandardColormap().
+ *
+ * Given a screen, a visual, and a property, XmuLookupStandardColormap()
+ * will determine the best allocation for the property under the specified
+ * visual, and determine the whether to create a new colormap or to use
+ * the default colormap of the screen. It will call XmuStandardColormap()
+ * to create the standard colormap.
+ *
+ * If replace is true, any previous definition of the property will be
+ * replaced. If retain is true, the property and the colormap will be
+ * made permanent for the duration of the server session. However,
+ * pre-existing property definitions which are not replaced cannot be made
+ * permanent by a call to XmuLookupStandardColormap(); a request to retain
+ * resources pertains to newly created resources.
+ *
+ * Returns 0 on failure, non-zero on success. A request to create a
+ * standard colormap upon a visual which cannot support such a map is
+ * considered a failure. An example of this would be requesting any
+ * standard colormap property on a monochrome visual, or, requesting an
+ * RGB_BEST_MAP on a display whose colormap size is 16.
+ */
+
+Status XmuLookupStandardColormap(dpy, screen, visualid, depth, property,
+ replace, retain)
+ Display *dpy; /* specifies X server connection */
+ int screen; /* specifies screen of display */
+ VisualID visualid; /* specifies the visual type */
+ unsigned int depth; /* specifies the visual type */
+ Atom property; /* a standard colormap property */
+ Bool replace; /* specifies whether to replace */
+ Bool retain; /* specifies whether to retain */
+{
+ Display *odpy; /* original display connection */
+ XStandardColormap *colormap;
+ XVisualInfo vinfo_template, *vinfo; /* visual */
+ long vinfo_mask;
+ unsigned long r_max, g_max, b_max; /* allocation */
+ int count;
+ Colormap cmap; /* colormap ID */
+ Status status = 0;
+
+
+ /* Match the requested visual */
+
+ vinfo_template.visualid = visualid;
+ vinfo_template.screen = screen;
+ vinfo_template.depth = depth;
+ vinfo_mask = VisualIDMask | VisualScreenMask | VisualDepthMask;
+ if ((vinfo = XGetVisualInfo(dpy, vinfo_mask, &vinfo_template, &count)) ==
+ NULL)
+ return 0;
+
+ /* Monochrome visuals have no standard maps */
+
+ if (vinfo->colormap_size <= 2) {
+ XFree((char *) vinfo);
+ return 0;
+ }
+
+ /* If the requested property already exists on this screen, and,
+ * if the replace flag has not been set to true, return success.
+ * lookup() will remove a pre-existing map if replace is true.
+ */
+
+ if (lookup(dpy, screen, visualid, property, (XStandardColormap *) NULL,
+ replace) && !replace) {
+ XFree((char *) vinfo);
+ return 1;
+ }
+
+ /* Determine the best allocation for this property under the requested
+ * visualid and depth, and determine whether or not to use the default
+ * colormap of the screen.
+ */
+
+ if (!XmuGetColormapAllocation(vinfo, property, &r_max, &g_max, &b_max)) {
+ XFree((char *) vinfo);
+ return 0;
+ }
+
+ cmap = (property == XA_RGB_DEFAULT_MAP &&
+ visualid == XVisualIDFromVisual(DefaultVisual(dpy, screen)))
+ ? DefaultColormap(dpy, screen) : None;
+
+ /* If retaining resources, open a new connection to the same server */
+
+ if (retain) {
+ odpy = dpy;
+ if ((dpy = XOpenDisplay(XDisplayString(odpy))) == NULL) {
+ XFree((char *) vinfo);
+ return 0;
+ }
+ }
+
+ /* Create the standard colormap */
+
+ colormap = XmuStandardColormap(dpy, screen, visualid, depth, property,
+ cmap, r_max, g_max, b_max);
+
+ /* Set the standard colormap property */
+
+ if (colormap) {
+ XGrabServer(dpy);
+
+ if (lookup(dpy, screen, visualid, property, colormap, replace) &&
+ !replace) {
+ /* Someone has defined the property since we last looked.
+ * Since we will not replace it, release our own resources.
+ * If this is the default map, our allocations will be freed
+ * when this connection closes.
+ */
+ if (colormap->killid == ReleaseByFreeingColormap)
+ XFreeColormap(dpy, colormap->colormap);
+ }
+ else if (retain) {
+ XSetCloseDownMode(dpy, RetainPermanent);
+ }
+ XUngrabServer(dpy);
+ XFree((char *) colormap);
+ status = 1;
+ }
+
+ if (retain)
+ XCloseDisplay(dpy);
+ XFree((char *) vinfo);
+ return status;
+}
+
+/***************************************************************************/
+
+/* Lookup a standard colormap property. If the property is RGB_DEFAULT_MAP,
+ * the visualid is used to determine whether the indicated standard colormap
+ * exists. If the map exists and replace is true, delete the resources used
+ * by the map and remove the property. Return true if the map exists,
+ * or did exist and was deleted; return false if the map was not found.
+ *
+ * Note that this is not the way that a Status return is normally used.
+ *
+ * If new is not NULL, new points to an XStandardColormap structure which
+ * describes a standard colormap of the specified property. It will be made
+ * a standard colormap of the screen if none already exists, or if replace
+ * is true.
+ */
+
+static Status lookup(dpy, screen, visualid, property, new, replace)
+ Display *dpy; /* specifies display connection */
+ int screen; /* specifies screen number */
+ VisualID visualid; /* specifies visualid for std map */
+ Atom property; /* specifies colormap property name */
+ XStandardColormap *new; /* specifies a standard colormap */
+ Bool replace; /* specifies whether to replace */
+{
+ register int i;
+ int count;
+ XStandardColormap *stdcmaps, *s;
+ Window win = RootWindow(dpy, screen);
+
+ /* The property does not already exist */
+
+ if (! XGetRGBColormaps(dpy, win, &stdcmaps, &count, property)) {
+ if (new)
+ XSetRGBColormaps(dpy, win, new, 1, property);
+ return 0;
+ }
+
+ /* The property exists and is not describing the RGB_DEFAULT_MAP */
+
+ if (property != XA_RGB_DEFAULT_MAP) {
+ if (replace) {
+ XmuDeleteStandardColormap(dpy, screen, property);
+ if (new)
+ XSetRGBColormaps(dpy, win, new, 1, property);
+ }
+ XFree((char *)stdcmaps);
+ return 1;
+ }
+
+ /* The property exists and is RGB_DEFAULT_MAP */
+
+ for (i=0, s=stdcmaps; (i < count) && (s->visualid != visualid); i++, s++)
+ ;
+
+ /* No RGB_DEFAULT_MAP property matches the given visualid */
+
+ if (i == count) {
+ if (new) {
+ XStandardColormap *m, *maps;
+
+ s = (XStandardColormap *) malloc((unsigned) ((count+1) * sizeof
+ (XStandardColormap)));
+
+ for (i = 0, m = s, maps = stdcmaps; i < count; i++, m++, maps++) {
+ m->colormap = maps->colormap;
+ m->red_max = maps->red_max;
+ m->red_mult = maps->red_mult;
+ m->green_max = maps->green_max;
+ m->green_mult = maps->green_mult;
+ m->blue_max = maps->blue_max;
+ m->blue_mult = maps->blue_mult;
+ m->base_pixel = maps->base_pixel;
+ m->visualid = maps->visualid;
+ m->killid = maps->killid;
+ }
+ m->colormap = new->colormap;
+ m->red_max = new->red_max;
+ m->red_mult = new->red_mult;
+ m->green_max = new->green_max;
+ m->green_mult = new->green_mult;
+ m->blue_max = new->blue_max;
+ m->blue_mult = new->blue_mult;
+ m->base_pixel = new->base_pixel;
+ m->visualid = new->visualid;
+ m->killid = new->killid;
+
+ XSetRGBColormaps(dpy, win, s, ++count, property);
+ free((char *) s);
+ }
+ XFree((char *) stdcmaps);
+ return 0;
+ }
+
+ /* Found an RGB_DEFAULT_MAP property with a matching visualid */
+
+ if (replace) {
+ /* Free old resources first - we may need them, particularly in
+ * the default colormap of the screen. However, because of this,
+ * it is possible that we will destroy the old resource and fail
+ * to create a new one if XmuStandardColormap() fails.
+ */
+
+ if (count == 1) {
+ XmuDeleteStandardColormap(dpy, screen, property);
+ if (new)
+ XSetRGBColormaps(dpy, win, new, 1, property);
+ }
+ else {
+ XStandardColormap *map;
+
+ /* s still points to the matching standard colormap */
+
+ if (s->killid == ReleaseByFreeingColormap) {
+ if ((s->colormap != None) &&
+ (s->colormap != DefaultColormap(dpy, screen)))
+ XFreeColormap(dpy, s->colormap);
+ }
+ else if (s->killid != None)
+ XKillClient(dpy, s->killid);
+
+ map = (new) ? new : stdcmaps + --count;
+
+ s->colormap = map->colormap;
+ s->red_max = map->red_max;
+ s->red_mult = map->red_mult;
+ s->green_max = map->green_max;
+ s->green_mult = map->green_mult;
+ s->blue_max = map->blue_max;
+ s->blue_mult = map->blue_mult;
+ s->visualid = map->visualid;
+ s->killid = map->killid;
+
+ XSetRGBColormaps(dpy, win, stdcmaps, count, property);
+ }
+ }
+ XFree((char *) stdcmaps);
+ return 1;
+}
diff --git a/src/Lower.c b/src/Lower.c
new file mode 100644
index 0000000..fc588ef
--- /dev/null
+++ b/src/Lower.c
@@ -0,0 +1,121 @@
+/* $Xorg: Lower.c,v 1.4 2001/02/09 02:03:53 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.
+
+*/
+
+#define XK_LATIN1
+#include <X11/keysymdef.h>
+#include <X11/Xmu/CharSet.h>
+
+/*
+ * ISO Latin-1 case conversion routine
+ */
+
+#if NeedFunctionPrototypes
+void XmuCopyISOLatin1Lowered(char *dst, _Xconst char *src)
+#else
+void XmuCopyISOLatin1Lowered(dst, src)
+ char *dst, *src;
+#endif
+{
+ 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';
+}
+
+#if NeedFunctionPrototypes
+void XmuCopyISOLatin1Uppered(char *dst, _Xconst char *src)
+#else
+void XmuCopyISOLatin1Uppered(dst, src)
+ char *dst, *src;
+#endif
+{
+ 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_slash) && (*source <= XK_thorn))
+ *dest = *source - (XK_oslash - XK_Ooblique);
+ else
+ *dest = *source;
+ }
+ *dest = '\0';
+}
+
+#if NeedFunctionPrototypes
+int XmuCompareISOLatin1 (_Xconst char *first, _Xconst char *second)
+#else
+int XmuCompareISOLatin1 (first, second)
+ char *first, *second;
+#endif
+{
+ register unsigned char *ap, *bp;
+
+ for (ap = (unsigned char *) first, bp = (unsigned char *) second;
+ *ap && *bp; ap++, bp++) {
+ register unsigned char a, b;
+
+ if ((a = *ap) != (b = *bp)) {
+ /* try lowercasing and try again */
+
+ if ((a >= XK_A) && (a <= XK_Z))
+ a += (XK_a - XK_A);
+ else if ((a >= XK_Agrave) && (a <= XK_Odiaeresis))
+ a += (XK_agrave - XK_Agrave);
+ else if ((a >= XK_Ooblique) && (a <= XK_Thorn))
+ a += (XK_oslash - XK_Ooblique);
+
+ if ((b >= XK_A) && (b <= XK_Z))
+ b += (XK_a - XK_A);
+ else if ((b >= XK_Agrave) && (b <= XK_Odiaeresis))
+ b += (XK_agrave - XK_Agrave);
+ else if ((b >= XK_Ooblique) && (b <= XK_Thorn))
+ b += (XK_oslash - XK_Ooblique);
+
+ if (a != b) return (((int) a) - ((int) b));
+ }
+ }
+ return (((int) *ap) - ((int) *bp));
+}
diff --git a/src/RdBitF.c b/src/RdBitF.c
new file mode 100644
index 0000000..8f27e37
--- /dev/null
+++ b/src/RdBitF.c
@@ -0,0 +1,401 @@
+/* $Xorg: RdBitF.c,v 1.4 2001/02/09 02:03:53 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.
+
+*/
+
+/*
+ * This file contains miscellaneous utility routines and is not part of the
+ * Xlib standard.
+ *
+ * Public entry points:
+ *
+ * XmuReadBitmapData read data from FILE descriptor
+ * XmuReadBitmapDataFromFile read X10 or X11 format bitmap files
+ * and return data
+ *
+ * Note that this file and ../X/XRdBitF.c look very similar.... Keep them
+ * that way (but don't use common source code so that people can have one
+ * without the other).
+ */
+
+
+/*
+ * Based on an optimized version provided by Jim Becker, Auguest 5, 1988.
+ */
+
+#include <X11/Xos.h>
+#include <X11/Xlib.h>
+#include <X11/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;
+}
+
+
+/*
+ * The data returned by the following routine is always in left-most byte
+ * first and left-most bit first. If it doesn't return BitmapSuccess then
+ * its arguments won't have been touched. This routine should look as much
+ * like the Xlib routine XReadBitmapfile as possible.
+ */
+int XmuReadBitmapData (fstream, width, height, datap, x_hot, y_hot)
+ FILE *fstream; /* handle on file */
+ unsigned int *width, *height; /* RETURNED */
+ unsigned char **datap; /* RETURNED */
+ int *x_hot, *y_hot; /* RETURNED */
+{
+ unsigned char *data = 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 */
+
+#define Xmalloc(size) malloc(size)
+
+ /* first time initialization */
+ if (initialized == False) initHexTable();
+
+ /* error cleanup and return macro */
+#define RETURN(code) { if (data) free (data); 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;
+ data = (unsigned char *) Xmalloc ((unsigned int) size);
+ if (!data)
+ RETURN (BitmapNoMemory);
+
+ if (version10p) {
+ unsigned char *ptr;
+ int bytes;
+
+ for (bytes=0, ptr=data; 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=data; bytes<size; bytes++, ptr++) {
+ if ((value = NextInt(fstream)) < 0)
+ RETURN (BitmapFileInvalid);
+ *ptr=value;
+ }
+ }
+ break;
+ } /* end while */
+
+ if (data == NULL) {
+ RETURN (BitmapFileInvalid);
+ }
+
+ *datap = data;
+ data = NULL;
+ *width = ww;
+ *height = hh;
+ if (x_hot) *x_hot = hx;
+ if (y_hot) *y_hot = hy;
+
+ RETURN (BitmapSuccess);
+}
+
+#if defined(WIN32) || defined(__EMX__) /* || defined(OS2) */
+
+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 = malloc (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;
+{
+#ifndef MAX_PATH
+#define MAX_PATH 512
+#endif
+
+ 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 = malloc (len + 1);
+ strcpy (bufp, drive);
+ strcat (bufp, path);
+ if (access_file (bufp, pathbuf, len_pathbuf, pathret)) {
+ if (bufp != buf) free (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 = malloc (len + 1);
+ strcpy (bufp, drive);
+ strcat (bufp, path);
+ if (access_file (bufp, pathbuf, len_pathbuf, pathret)) {
+ if (bufp != buf) free (bufp);
+ return 1;
+ }
+ }
+
+ /* does OS/2 (with or with gcc-emx) have getdrives? */
+ /* tried everywhere else, go fishing */
+#define C_DRIVE ('C' - 'A')
+#define Z_DRIVE ('Z' - 'A')
+ 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 = malloc (len + 1);
+ *bufp = 'A' + i;
+ *(bufp + 1) = ':';
+ *(bufp + 2) = '\0';
+ strcat (bufp, path);
+ if (access_file (bufp, pathbuf, len_pathbuf, pathret)) {
+ if (bufp != buf) free (bufp);
+ return 1;
+ }
+ }
+ }
+#endif
+ return 0;
+}
+
+FILE* fopen_file(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) free (bufp);
+
+ return ret;
+}
+
+#else
+#define fopen_file fopen
+#endif
+
+
+#if NeedFunctionPrototypes
+int XmuReadBitmapDataFromFile (_Xconst char *filename, unsigned int *width,
+ unsigned int *height, unsigned char **datap,
+ int *x_hot, int *y_hot)
+#else
+int XmuReadBitmapDataFromFile (filename, width, height, datap, x_hot, y_hot)
+ char *filename;
+ unsigned int *width, *height; /* RETURNED */
+ unsigned char **datap; /* RETURNED */
+ int *x_hot, *y_hot; /* RETURNED */
+#endif
+{
+ FILE *fstream;
+ int status;
+
+ if ((fstream = fopen_file (filename, "r")) == NULL) {
+ return BitmapOpenFailed;
+ }
+ status = XmuReadBitmapData (fstream, width, height, datap, x_hot, y_hot);
+ fclose (fstream);
+ return status;
+}
diff --git a/src/ScrOfWin.c b/src/ScrOfWin.c
new file mode 100644
index 0000000..8e986d6
--- /dev/null
+++ b/src/ScrOfWin.c
@@ -0,0 +1,57 @@
+/* $Xorg: ScrOfWin.c,v 1.4 2001/02/09 02:03:53 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.
+
+*/
+
+/*
+ * Author: Jim Fulton, MIT X Consortium
+ */
+
+#include <stdio.h>
+#include <X11/Xlib.h>
+
+
+Screen *XmuScreenOfWindow (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)) {
+ return NULL;
+ }
+ for (i = 0; i < ScreenCount (dpy); i++) { /* find root from list */
+ if (root == RootWindow (dpy, i)) {
+ return ScreenOfDisplay (dpy, i);
+ }
+ }
+ return NULL;
+}
+
diff --git a/src/ShapeWidg.c b/src/ShapeWidg.c
new file mode 100644
index 0000000..c06c6e9
--- /dev/null
+++ b/src/ShapeWidg.c
@@ -0,0 +1,189 @@
+/* $Xorg: ShapeWidg.c,v 1.4 2001/02/09 02:03:53 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 <X11/IntrinsicP.h>
+#include <X11/extensions/shape.h>
+#include "Converters.h"
+#include "Drawing.h"
+
+static ShapeError();
+static ShapeRectangle(), ShapeOval(), ShapeEllipseOrRoundedRectangle();
+
+Boolean XmuReshapeWidget(w, shape_style, corner_width, corner_height)
+ Widget w;
+ int shape_style;
+ int corner_width, corner_height;
+{
+ switch (shape_style) {
+
+ case XmuShapeRectangle:
+ ShapeRectangle(w);
+ break;
+
+ case XmuShapeOval:
+ ShapeOval(w);
+ break;
+
+ case XmuShapeEllipse:
+ case XmuShapeRoundedRectangle:
+ ShapeEllipseOrRoundedRectangle
+ (w,
+ ((shape_style == XmuShapeEllipse) ? True : False),
+ corner_width,
+ corner_height);
+ break;
+
+ default:
+ ShapeError(w);
+ return False;
+ }
+ return True;
+}
+
+static ShapeError(w)
+ Widget w;
+{
+ String params[1];
+ Cardinal num_params = 1;
+ params[0] = XtName(w);
+ XtAppWarningMsg( XtWidgetToApplicationContext(w),
+ "shapeUnknown", "xmuReshapeWidget", "XmuLibrary",
+ "Unsupported shape style for Command widget \"%s\"",
+ params, &num_params
+ );
+}
+
+
+static ShapeRectangle(w)
+ Widget w;
+{
+ XShapeCombineMask( XtDisplay(w), XtWindow(w),
+ ShapeBounding, 0, 0, None, ShapeSet );
+ XShapeCombineMask( XtDisplay(w), XtWindow(w),
+ ShapeClip, 0, 0, None, ShapeSet );
+}
+
+
+static ShapeOval(w)
+ Widget w;
+{
+ Display *dpy = XtDisplay(w);
+ unsigned width = w->core.width + (w->core.border_width<<1);
+ unsigned height = w->core.height + (w->core.border_width<<1);
+ Pixmap p = XCreatePixmap( dpy, XtWindow(w), width, height, 1 );
+ XGCValues values;
+ GC gc;
+ int rad;
+
+ values.foreground = 0;
+ values.background = 1;
+ values.cap_style = CapRound;
+ values.line_width = height;
+ gc = XCreateGC (dpy, p,
+ GCForeground | GCBackground | GCLineWidth | GCCapStyle,
+ &values);
+ XFillRectangle( dpy, p, gc, 0, 0, width, height );
+ XSetForeground( dpy, gc, 1 );
+ if (width <= height) {
+ /* cannot be oval, fall back to ellipse */
+ XFillArc( dpy, p, gc, 0, 0, width, height, 0, 360*64 );
+ } else {
+ rad = height >> 1;
+ XDrawLine( dpy, p, gc, rad, rad, (int)width - rad - 1, rad );
+ }
+ XShapeCombineMask( dpy, XtWindow(w), ShapeBounding,
+ -(w->core.border_width), -(w->core.border_width),
+ p, ShapeSet );
+ if (w->core.border_width) {
+ XSetForeground( dpy, gc, 0 );
+ XFillRectangle( dpy, p, gc, 0, 0, width, height );
+ values.line_width = w->core.height;
+ values.foreground = 1;
+ XChangeGC (dpy, gc, GCLineWidth|GCForeground, &values);
+ if (w->core.width <= w->core.height) {
+ /* cannot be oval, fall back to ellipse */
+ XFillArc( dpy, p, gc, 0, 0, w->core.width, w->core.height,
+ 0, 360*64 );
+ } else {
+ rad = w->core.height >> 1;
+ XDrawLine( dpy, p, gc, rad, rad,
+ (int)w->core.width - rad - 1, rad );
+ }
+ XShapeCombineMask( dpy, XtWindow(w), ShapeClip, 0, 0, p, ShapeSet );
+ } else {
+ XShapeCombineMask( XtDisplay(w), XtWindow(w),
+ ShapeClip, 0, 0, None, ShapeSet );
+ }
+ XFreePixmap( dpy, p );
+ XFreeGC (dpy, gc );
+}
+
+
+static ShapeEllipseOrRoundedRectangle(w, ellipse, ew, eh)
+ Widget w;
+ Boolean ellipse;
+ int ew, eh;
+{
+ Display *dpy = XtDisplay(w);
+ unsigned width = w->core.width + (w->core.border_width<<1);
+ unsigned height = w->core.height + (w->core.border_width<<1);
+ Pixmap p = XCreatePixmap( dpy, XtWindow(w), width, height, 1 );
+ XGCValues values;
+ GC gc;
+
+ values.foreground = 0;
+ gc = XCreateGC (dpy, p, GCForeground, &values );
+ XFillRectangle( dpy, p, gc, 0, 0, width, height );
+ XSetForeground (dpy, gc, 1);
+ if (!ellipse)
+ XmuFillRoundedRectangle( dpy, p, gc, 0, 0, (int)width, (int)height,
+ ew, eh );
+ else
+ XFillArc( dpy, p, gc, 0, 0, width, height, 0, 360*64 );
+ XShapeCombineMask( dpy, XtWindow(w), ShapeBounding,
+ -(w->core.border_width), -(w->core.border_width),
+ p, ShapeSet );
+ if (w->core.border_width) {
+ XSetForeground (dpy, gc, 0);
+ XFillRectangle( dpy, p, gc, 0, 0, width, height );
+ XSetForeground (dpy, gc, 1);
+ if (!ellipse)
+ XmuFillRoundedRectangle( dpy, p, gc, 0, 0,
+ (int)w->core.width, (int)w->core.height,
+ ew, eh );
+ else
+ XFillArc( dpy, p, gc, 0, 0, w->core.width, w->core.height,
+ 0, 360*64 );
+ XShapeCombineMask( dpy, XtWindow(w), ShapeClip, 0, 0, p, ShapeSet );
+ } else {
+ XShapeCombineMask( XtDisplay(w), XtWindow(w),
+ ShapeClip, 0, 0, None, ShapeSet );
+ }
+ XFreePixmap( dpy, p );
+ XFreeGC (dpy, gc);
+}
diff --git a/src/StdCmap.c b/src/StdCmap.c
new file mode 100644
index 0000000..60719e8
--- /dev/null
+++ b/src/StdCmap.c
@@ -0,0 +1,218 @@
+/* $Xorg: StdCmap.c,v 1.4 2001/02/09 02:03:53 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.
+
+*/
+
+/*
+ * Author: Donna Converse, MIT X Consortium
+ */
+
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+#include <X11/Xmu/StdCmap.h>
+
+#define lowbit(x) ((x) & (~(x) + 1))
+
+static Status valid_args(); /* argument restrictions */
+
+/*
+ * To create any one standard colormap, use XmuStandardColormap().
+ *
+ * Create a standard colormap for the given screen, visualid, and visual
+ * depth, with the given red, green, and blue maximum values, with the
+ * given standard property name. Return a pointer to an XStandardColormap
+ * structure which describes the newly created colormap, upon success.
+ * Upon failure, return NULL.
+ *
+ * XmuStandardColormap() calls XmuCreateColormap() to create the map.
+ *
+ * Resources created by this function are not made permanent; that is the
+ * caller's responsibility.
+ */
+
+XStandardColormap *XmuStandardColormap(dpy, screen, visualid, depth, property,
+ cmap, red_max, green_max, blue_max)
+ Display *dpy; /* specifies X server connection */
+ int screen; /* specifies display screen */
+ VisualID visualid; /* identifies the visual type */
+ unsigned int depth; /* identifies the visual type */
+ Atom property; /* a standard colormap property */
+ Colormap cmap; /* specifies colormap ID or None */
+ unsigned long red_max, green_max, blue_max; /* allocations */
+{
+ XStandardColormap *stdcmap;
+ Status status;
+ XVisualInfo vinfo_template, *vinfo;
+ long vinfo_mask;
+ int n;
+
+ /* Match the required visual information to an actual visual */
+ vinfo_template.visualid = visualid;
+ vinfo_template.screen = screen;
+ vinfo_template.depth = depth;
+ vinfo_mask = VisualIDMask | VisualScreenMask | VisualDepthMask;
+ if ((vinfo = XGetVisualInfo(dpy, vinfo_mask, &vinfo_template, &n)) == NULL)
+ return 0;
+
+ /* Check the validity of the combination of visual characteristics,
+ * allocation, and colormap property. Create an XStandardColormap
+ * structure.
+ */
+
+ if (! valid_args(vinfo, red_max, green_max, blue_max, property)
+ || ((stdcmap = XAllocStandardColormap()) == NULL)) {
+ XFree((char *) vinfo);
+ return 0;
+ }
+
+ /* Fill in the XStandardColormap structure */
+
+ if (cmap == DefaultColormap(dpy, screen)) {
+ /* Allocating out of the default map, cannot use XFreeColormap() */
+ Window win = XCreateWindow(dpy, RootWindow(dpy, screen), 1, 1, 1, 1,
+ 0, 0, InputOnly, vinfo->visual,
+ (unsigned long) 0,
+ (XSetWindowAttributes *)NULL);
+ stdcmap->killid = (XID) XCreatePixmap(dpy, win, 1, 1, depth);
+ XDestroyWindow(dpy, win);
+ stdcmap->colormap = cmap;
+ } else {
+ stdcmap->killid = ReleaseByFreeingColormap;
+ stdcmap->colormap = XCreateColormap(dpy, RootWindow(dpy, screen),
+ vinfo->visual, AllocNone);
+ }
+ stdcmap->red_max = red_max;
+ stdcmap->green_max = green_max;
+ stdcmap->blue_max = blue_max;
+ if (property == XA_RGB_GRAY_MAP)
+ stdcmap->red_mult = stdcmap->green_mult = stdcmap->blue_mult = 1;
+ else if (vinfo->class == TrueColor || vinfo->class == DirectColor) {
+ stdcmap->red_mult = lowbit(vinfo->red_mask);
+ stdcmap->green_mult = lowbit(vinfo->green_mask);
+ stdcmap->blue_mult = lowbit(vinfo->blue_mask);
+ } else {
+ stdcmap->red_mult = (red_max > 0)
+ ? (green_max + 1) * (blue_max + 1) : 0;
+ stdcmap->green_mult = (green_max > 0) ? blue_max + 1 : 0;
+ stdcmap->blue_mult = (blue_max > 0) ? 1 : 0;
+ }
+ stdcmap->base_pixel = 0; /* base pixel may change */
+ stdcmap->visualid = vinfo->visualid;
+
+ /* Make the colormap */
+
+ status = XmuCreateColormap(dpy, stdcmap);
+
+ /* Clean up */
+
+ XFree((char *) vinfo);
+ if (!status) {
+
+ /* Free the colormap or the pixmap, if we created one */
+ if (stdcmap->killid == ReleaseByFreeingColormap)
+ XFreeColormap(dpy, stdcmap->colormap);
+ else if (stdcmap->killid != None)
+ XFreePixmap(dpy, stdcmap->killid);
+
+ XFree((char *) stdcmap);
+ return (XStandardColormap *) NULL;
+ }
+ return stdcmap;
+}
+
+/****************************************************************************/
+static Status valid_args(vinfo, red_max, green_max, blue_max, property)
+ XVisualInfo *vinfo; /* specifies visual */
+ unsigned long red_max, green_max, blue_max; /* specifies alloc */
+ Atom property; /* specifies property name */
+{
+ unsigned long ncolors; /* number of colors requested */
+
+ /* Determine that the number of colors requested is <= map size */
+
+ if ((vinfo->class == DirectColor) || (vinfo->class == TrueColor)) {
+ unsigned long mask;
+
+ mask = vinfo->red_mask;
+ while (!(mask & 1))
+ mask >>= 1;
+ if (red_max > mask)
+ return 0;
+ mask = vinfo->green_mask;
+ while (!(mask & 1))
+ mask >>= 1;
+ if (green_max > mask)
+ return 0;
+ mask = vinfo->blue_mask;
+ while (!(mask & 1))
+ mask >>= 1;
+ if (blue_max > mask)
+ return 0;
+ } else if (property == XA_RGB_GRAY_MAP) {
+ ncolors = red_max + green_max + blue_max + 1;
+ if (ncolors > vinfo->colormap_size)
+ return 0;
+ } else {
+ ncolors = (red_max + 1) * (green_max + 1) * (blue_max + 1);
+ if (ncolors > vinfo->colormap_size)
+ return 0;
+ }
+
+ /* Determine that the allocation and visual make sense for the property */
+
+ switch (property)
+ {
+ case XA_RGB_DEFAULT_MAP:
+ if (red_max == 0 || green_max == 0 || blue_max == 0)
+ return 0;
+ break;
+ case XA_RGB_RED_MAP:
+ if (red_max == 0)
+ return 0;
+ break;
+ case XA_RGB_GREEN_MAP:
+ if (green_max == 0)
+ return 0;
+ break;
+ case XA_RGB_BLUE_MAP:
+ if (blue_max == 0)
+ return 0;
+ break;
+ case XA_RGB_BEST_MAP:
+ if (red_max == 0 || green_max == 0 || blue_max == 0)
+ return 0;
+ break;
+ case XA_RGB_GRAY_MAP:
+ if (red_max == 0 || blue_max == 0 || green_max == 0)
+ return 0;
+ break;
+ default:
+ return 0;
+ }
+ return 1;
+}
diff --git a/src/StrToBS.c b/src/StrToBS.c
new file mode 100644
index 0000000..63b5d77
--- /dev/null
+++ b/src/StrToBS.c
@@ -0,0 +1,82 @@
+/* $Xorg: StrToBS.c,v 1.4 2001/02/09 02:03:53 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 <X11/Intrinsic.h>
+#include "Converters.h"
+#include "CharSet.h"
+
+#define done(address, type) \
+ { (*toVal).size = sizeof(type); (*toVal).addr = (XPointer) address; }
+
+/* ARGSUSED */
+void
+XmuCvtStringToBackingStore (args, num_args, fromVal, toVal)
+ XrmValue *args; /* unused */
+ Cardinal *num_args; /* unused */
+ XrmValuePtr fromVal;
+ XrmValuePtr toVal;
+{
+ char lowerString[40];
+ XrmQuark q;
+ static int backingStoreType;
+ static XrmQuark XtQEnotUseful, XtQEwhenMapped, XtQEalways, XtQEdefault;
+ static int haveQuarks = 0;
+
+ if (*num_args != 0)
+ XtWarning("String to BackingStore conversion needs no extra arguments");
+ if (!haveQuarks) {
+ XmuCopyISOLatin1Lowered (lowerString, XtEnotUseful);
+ XtQEnotUseful = XrmStringToQuark(lowerString);
+ XmuCopyISOLatin1Lowered (lowerString, XtEwhenMapped);
+ XtQEwhenMapped = XrmStringToQuark(lowerString);
+ XmuCopyISOLatin1Lowered (lowerString, XtEalways);
+ XtQEalways = XrmStringToQuark(lowerString);
+ XmuCopyISOLatin1Lowered (lowerString, XtEdefault);
+ XtQEdefault = XrmStringToQuark(lowerString);
+ haveQuarks = 1;
+ }
+ if (strlen ((char*)fromVal->addr) >= sizeof lowerString)
+ XtStringConversionWarning((char *) fromVal->addr, "BackingStore");
+ XmuCopyISOLatin1Lowered (lowerString, (char *) fromVal->addr);
+ q = XrmStringToQuark (lowerString);
+ if (q == XtQEnotUseful) {
+ backingStoreType = NotUseful;
+ done (&backingStoreType, int);
+ } else if (q == XtQEwhenMapped) {
+ backingStoreType = WhenMapped;
+ done (&backingStoreType, int);
+ } else if (q == XtQEalways) {
+ backingStoreType = Always;
+ done (&backingStoreType, int);
+ } else if (q == XtQEdefault) {
+ backingStoreType = Always + WhenMapped + NotUseful;
+ done (&backingStoreType, int);
+ } else {
+ XtStringConversionWarning((char *) fromVal->addr, "BackingStore");
+ }
+}
diff --git a/src/StrToBmap.c b/src/StrToBmap.c
new file mode 100644
index 0000000..54afe7e
--- /dev/null
+++ b/src/StrToBmap.c
@@ -0,0 +1,148 @@
+/* $Xorg: StrToBmap.c,v 1.4 2001/02/09 02:03:53 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 <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include <X11/Xmu/Converters.h>
+#include <X11/Xmu/Drawing.h>
+
+
+/*
+ * XmuConvertStringToBitmap:
+ *
+ * creates a depth-1 Pixmap suitable for window manager icons.
+ * "string" represents a bitmap(1) filename which may be absolute,
+ * or relative to the global resource bitmapFilePath, class
+ * BitmapFilePath. If the resource is not defined, the default
+ * value is the build symbol BITMAPDIR.
+ *
+ * shares lots of code with XmuConvertStringToCursor.
+ *
+ * To use, include the following in your ClassInitialize procedure:
+
+static XtConvertArgRec screenConvertArg[] = {
+ {XtBaseOffset, (XtPointer) XtOffset(Widget, core.screen), sizeof(Screen *)}
+};
+
+ XtAddConverter("String", "Bitmap", XmuCvtStringToBitmap,
+ screenConvertArg, XtNumber(screenConvertArg));
+ *
+ */
+
+#define done(address, type) \
+ { (*toVal).size = sizeof(type); (*toVal).addr = (XPointer) address; }
+
+
+/*ARGSUSED*/
+void XmuCvtStringToBitmap(args, num_args, fromVal, toVal)
+ XrmValuePtr args;
+ Cardinal *num_args;
+ XrmValuePtr fromVal;
+ XrmValuePtr toVal;
+{
+ static Pixmap pixmap; /* static for cvt magic */
+ char *name = (char *)fromVal->addr;
+ Screen *screen;
+ Display *dpy;
+ XrmDatabase db;
+ String fn;
+ unsigned int width, height;
+ int xhot, yhot;
+ unsigned char *data;
+
+ if (*num_args != 1)
+ XtErrorMsg("wrongParameters","cvtStringToBitmap","XtToolkitError",
+ "String to pixmap conversion needs screen argument",
+ (String *)NULL, (Cardinal *)NULL);
+
+ if (strcmp(name, "None") == 0) {
+ pixmap = None;
+ done(&pixmap, Pixmap);
+ return;
+ }
+
+ if (strcmp(name, "ParentRelative") == 0) {
+ pixmap = ParentRelative;
+ done(&pixmap, Pixmap);
+ return;
+ }
+
+ screen = *((Screen **) args[0].addr);
+ pixmap = XmuLocateBitmapFile (screen, name,
+ NULL, 0, NULL, NULL, NULL, NULL);
+ if (pixmap == None) {
+ dpy = DisplayOfScreen(screen);
+ db = XrmGetDatabase(dpy);
+ XrmSetDatabase(dpy, XtScreenDatabase(screen));
+ fn = XtResolvePathname(dpy, "bitmaps", name, "", NULL, NULL, 0, NULL);
+ if (!fn)
+ fn = XtResolvePathname(dpy, "", name, ".xbm", NULL, NULL, 0, NULL);
+ XrmSetDatabase(dpy, db);
+ if (fn &&
+ XmuReadBitmapDataFromFile (fn, &width, &height, &data,
+ &xhot, &yhot) == BitmapSuccess) {
+ pixmap = XCreatePixmapFromBitmapData (dpy,
+ RootWindowOfScreen(screen),
+ (char *) data, width, height,
+ 1, 0, 1);
+ XFree ((char *)data);
+ }
+ }
+
+ if (pixmap != None) {
+ done (&pixmap, Pixmap);
+ } else {
+ XtStringConversionWarning (name, "Pixmap");
+ return;
+ }
+}
+
diff --git a/src/StrToCurs.c b/src/StrToCurs.c
new file mode 100644
index 0000000..600e4f1
--- /dev/null
+++ b/src/StrToCurs.c
@@ -0,0 +1,334 @@
+/* $Xorg: StrToCurs.c,v 1.4 2001/02/09 02:03:53 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 <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include <X11/Xmu/Converters.h>
+#include <X11/Xmu/Drawing.h>
+
+#ifndef X_NOT_POSIX
+#ifdef _POSIX_SOURCE
+#include <limits.h>
+#else
+#define _POSIX_SOURCE
+#include <limits.h>
+#undef _POSIX_SOURCE
+#endif
+#endif /* X_NOT_POSIX */
+#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 /* PATH_MAX */
+
+/* Kludge source to avoid encountering broken shared library linkers
+ which insist on resolving references unused by the application,
+ and broken object file formats that don't correctly distinguish
+ references to procedures from references to data.
+ */
+#if defined(SUNSHLIB) || defined(SVR4)
+#define XMU_KLUDGE
+#endif
+
+/*
+ * XmuConvertStringToCursor:
+ *
+ * allows String to specify a standard cursor name (from cursorfont.h), a
+ * font name and glyph index of the form "FONT fontname index [[font] index]",
+ * or a bitmap file name (absolute, or relative to the global resource
+ * bitmapFilePath, class BitmapFilePath). If the resource is not
+ * defined, the default value is the build symbol BITMAPDIR.
+ *
+ * shares lots of code with XmuCvtStringToPixmap, but unfortunately
+ * can't use it as the hotspot info is lost.
+ *
+ * To use, include the following in your ClassInitialize procedure:
+
+static XtConvertArgRec screenConvertArg[] = {
+ {XtBaseOffset, (XtPointer) XtOffsetOf(WidgetRec, core.screen),
+ sizeof(Screen *)}
+};
+
+ XtAddConverter(XtRString, XtRCursor, XmuCvtStringToCursor,
+ screenConvertArg, XtNumber(screenConvertArg));
+ *
+ */
+
+#define done(address, type) \
+ { (*toVal).size = sizeof(type); (*toVal).addr = (XPointer) address; }
+
+#define FONTSPECIFIER "FONT "
+
+/*ARGSUSED*/
+void XmuCvtStringToCursor(args, num_args, fromVal, toVal)
+ XrmValuePtr args;
+ Cardinal *num_args;
+ XrmValuePtr fromVal;
+ XrmValuePtr toVal;
+{
+ static Cursor cursor; /* static for cvt magic */
+ char *name = (char *)fromVal->addr;
+ Screen *screen;
+ register int i;
+ char maskname[PATH_MAX];
+ Pixmap source, mask;
+ /* XXX - make fg/bg resources */
+ static XColor bgColor = {0, 0xffff, 0xffff, 0xffff};
+ static XColor fgColor = {0, 0, 0, 0};
+ int xhot, yhot;
+ int len;
+
+
+ if (*num_args != 1)
+ XtErrorMsg("wrongParameters","cvtStringToCursor","XtToolkitError",
+ "String to cursor conversion needs screen argument",
+ (String *)NULL, (Cardinal *)NULL);
+
+ screen = *((Screen **) args[0].addr);
+
+ if (0 == strncmp(FONTSPECIFIER, name, strlen(FONTSPECIFIER))) {
+ char source_name[PATH_MAX], mask_name[PATH_MAX];
+ char fmtstr[1024];
+ int source_char, mask_char, fields;
+ Font source_font, mask_font;
+ XrmValue fromString, toFont;
+ XrmValue cvtArg;
+ Boolean success;
+ Display *dpy = DisplayOfScreen(screen);
+#ifdef XMU_KLUDGE
+ Cardinal num;
+#endif
+
+ sprintf (fmtstr, "FONT %%%ds %%d %%%ds %%d",
+ sizeof source_name - 1, sizeof mask_name - 1);
+
+ fields = sscanf(name, fmtstr,
+ source_name, &source_char,
+ mask_name, &mask_char);
+ if (fields < 2) {
+ XtStringConversionWarning(name, XtRCursor);
+ return;
+ }
+
+ fromString.addr = source_name;
+ fromString.size = strlen(source_name) + 1;
+ toFont.addr = (XPointer) &source_font;
+ toFont.size = sizeof(Font);
+ cvtArg.addr = (XPointer) &dpy;
+ cvtArg.size = sizeof(Display *);
+ /* XXX using display of screen argument as message display */
+#ifdef XMU_KLUDGE
+ /* XXX Sacrifice caching */
+ num = 1;
+ success = XtCvtStringToFont(dpy, &cvtArg, &num, &fromString, &toFont,
+ NULL);
+#else
+ success = XtCallConverter(dpy, XtCvtStringToFont, &cvtArg,
+ (Cardinal)1, &fromString, &toFont, NULL);
+#endif
+ if (!success) {
+ XtStringConversionWarning(name, XtRCursor);
+ return;
+ }
+
+ switch (fields) {
+ case 2: /* defaulted mask font & char */
+ mask_font = source_font;
+ mask_char = source_char;
+ break;
+
+ case 3: /* defaulted mask font */
+ mask_font = source_font;
+ mask_char = atoi(mask_name);
+ break;
+
+ case 4: /* specified mask font & char */
+ fromString.addr = mask_name;
+ fromString.size = strlen(mask_name) + 1;
+ toFont.addr = (XPointer) &mask_font;
+ toFont.size = sizeof(Font);
+ /* XXX using display of screen argument as message display */
+#ifdef XMU_KLUDGE
+ /* XXX Sacrifice caching */
+ num = 1;
+ success = XtCvtStringToFont(dpy, &cvtArg, &num, &fromString,
+ &toFont, NULL);
+#else
+ success = XtCallConverter(dpy, XtCvtStringToFont, &cvtArg,
+ (Cardinal)1, &fromString, &toFont, NULL);
+#endif
+ if (!success) {
+ XtStringConversionWarning(name, XtRCursor);
+ return;
+ }
+ }
+
+ cursor = XCreateGlyphCursor( DisplayOfScreen(screen), source_font,
+ mask_font, source_char, mask_char,
+ &fgColor, &bgColor );
+ done(&cursor, Cursor);
+ return;
+ }
+
+ i = XmuCursorNameToIndex (name);
+ if (i != -1) {
+ cursor = XCreateFontCursor (DisplayOfScreen(screen), i);
+ done(&cursor, Cursor);
+ return;
+ }
+
+ if ((source = XmuLocateBitmapFile (screen, name,
+ maskname, (sizeof maskname) - 4,
+ NULL, NULL, &xhot, &yhot)) == None) {
+ XtStringConversionWarning (name, XtRCursor);
+ }
+ len = strlen (maskname);
+ for (i = 0; i < 2; i++) {
+ strcpy (maskname + len, i == 0 ? "Mask" : "msk");
+ if ((mask = XmuLocateBitmapFile (screen, maskname, NULL, 0,
+ NULL, NULL, NULL, NULL)) != None)
+ break;
+ }
+
+ cursor = XCreatePixmapCursor( DisplayOfScreen(screen), source, mask,
+ &fgColor, &bgColor, xhot, yhot );
+ XFreePixmap( DisplayOfScreen(screen), source );
+ if (mask != None) XFreePixmap( DisplayOfScreen(screen), mask );
+
+ done(&cursor, Cursor);
+}
+
+#define new_done(type, value) \
+ { \
+ if (toVal->addr != NULL) { \
+ if (toVal->size < sizeof(type)) { \
+ toVal->size = sizeof(type); \
+ return False; \
+ } \
+ *(type*)(toVal->addr) = (value); \
+ } \
+ else { \
+ static type static_val; \
+ static_val = (value); \
+ toVal->addr = (XPointer)&static_val; \
+ } \
+ toVal->size = sizeof(type); \
+ return True; \
+ }
+
+/* Function Name: XmuCvtStringToColorCursor
+ * Description: Converts a string into a colored cursor.
+ * Arguments: dpy
+ * args - an argument list (see below).
+ * num_args - number of elements in the argument list.
+ * fromVal - value to convert from.
+ * toVal - value to convert to.
+ * data
+ * Returns: True or False
+ */
+
+/*ARGSUSED*/
+Boolean
+XmuCvtStringToColorCursor(dpy, args, num_args, fromVal, toVal, converter_data)
+ Display *dpy;
+ XrmValuePtr args;
+ Cardinal *num_args;
+ XrmValuePtr fromVal;
+ XrmValuePtr toVal;
+ XtPointer *converter_data; /* unused */
+{
+ Cursor cursor;
+ Pixel fg, bg;
+ Colormap c_map;
+ XColor colors[2];
+ Cardinal number;
+ XrmValue ret_val;
+
+ if (*num_args != 4) {
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ "wrongParameters","cvtStringToColorCursor","XmuError",
+ "String to color cursor conversion needs four arguments",
+ (String *)NULL, (Cardinal *)NULL);
+ return False;
+ }
+
+ fg = *((Pixel *) args[1].addr);
+ bg = *((Pixel *) args[2].addr);
+ c_map = *((Colormap *) args[3].addr);
+
+ number = 1;
+ XmuCvtStringToCursor(args, &number, fromVal, &ret_val);
+
+ cursor = *((Cursor *) ret_val.addr);
+
+ if (cursor == None)
+ new_done(Cursor, cursor);
+
+ colors[0].pixel = fg;
+ colors[1].pixel = bg;
+
+ XQueryColors (dpy, c_map, colors, 2);
+ XRecolorCursor(dpy, cursor, colors, colors + 1);
+ new_done(Cursor, cursor);
+}
+
+
+
diff --git a/src/StrToGrav.c b/src/StrToGrav.c
new file mode 100644
index 0000000..7f74745
--- /dev/null
+++ b/src/StrToGrav.c
@@ -0,0 +1,101 @@
+/* $Xorg: StrToGrav.c,v 1.4 2001/02/09 02:03:53 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/Intrinsic.h>
+#include <X11/Xmu/Converters.h>
+
+#define done(address, type) \
+ { (*toVal).size = sizeof(type); (*toVal).addr = (XPointer) address; }
+
+static struct _namepair {
+ XrmQuark quark;
+ char *name;
+ XtGravity gravity;
+} names[] = {
+ { NULLQUARK, XtEForget, ForgetGravity },
+ { NULLQUARK, XtENorthWest, NorthWestGravity },
+ { NULLQUARK, XtENorth, NorthGravity },
+ { NULLQUARK, XtENorthEast, NorthEastGravity },
+ { NULLQUARK, XtEWest, WestGravity },
+ { NULLQUARK, XtECenter, CenterGravity },
+ { NULLQUARK, XtEEast, EastGravity },
+ { NULLQUARK, XtESouthWest, SouthWestGravity },
+ { NULLQUARK, XtESouth, SouthGravity },
+ { NULLQUARK, XtESouthEast, SouthEastGravity },
+ { NULLQUARK, XtEStatic, StaticGravity },
+ { NULLQUARK, XtEUnmap, UnmapGravity },
+ { NULLQUARK, XtEleft, WestGravity },
+ { NULLQUARK, XtEtop, NorthGravity },
+ { NULLQUARK, XtEright, EastGravity },
+ { NULLQUARK, XtEbottom, SouthGravity },
+ { NULLQUARK, NULL, ForgetGravity }
+};
+
+/*
+ * This function is deprecated as of the addition of
+ * XtCvtStringToGravity in R6.
+ */
+
+void XmuCvtStringToGravity (args, num_args, fromVal, toVal)
+ XrmValuePtr args;
+ Cardinal *num_args;
+ XrmValuePtr fromVal;
+ XrmValuePtr toVal;
+{
+ static Boolean haveQuarks = FALSE;
+ char lowerName[40];
+ XrmQuark q;
+ char *s;
+ struct _namepair *np;
+
+ if (*num_args != 0)
+ XtWarningMsg("wrongParameters","cvtStringToGravity","XtToolkitError",
+ "String to Gravity conversion needs no extra arguments",
+ (String *) NULL, (Cardinal *)NULL);
+
+ if (!haveQuarks) {
+ for (np = names; np->name; np++) {
+ np->quark = XrmPermStringToQuark (np->name);
+ }
+ haveQuarks = TRUE;
+ }
+
+ s = (char *) fromVal->addr;
+ if (strlen(s) < sizeof lowerName) {
+ XmuCopyISOLatin1Lowered (lowerName, s);
+ q = XrmStringToQuark (lowerName);
+
+ for (np = names; np->name; np++) {
+ if (np->quark == q) {
+ done (&np->gravity, XtGravity);
+ return;
+ }
+ }
+ }
+ XtStringConversionWarning((char *) fromVal->addr, XtRGravity);
+}
diff --git a/src/StrToJust.c b/src/StrToJust.c
new file mode 100644
index 0000000..1284edb
--- /dev/null
+++ b/src/StrToJust.c
@@ -0,0 +1,75 @@
+/* $Xorg: StrToJust.c,v 1.4 2001/02/09 02:03:53 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 <X11/Intrinsic.h>
+#include "Converters.h"
+#include "CharSet.h"
+
+/* ARGSUSED */
+void
+XmuCvtStringToJustify(args, num_args, fromVal, toVal)
+ XrmValuePtr args; /* unused */
+ Cardinal *num_args; /* unused */
+ XrmValuePtr fromVal;
+ XrmValuePtr toVal;
+{
+ static XtJustify e;
+ static XrmQuark XrmQEleft;
+ static XrmQuark XrmQEcenter;
+ static XrmQuark XrmQEright;
+ static int haveQuarks;
+ XrmQuark q;
+ char *s = (char *) fromVal->addr;
+ char lowerName[40];
+
+ if (s == NULL) return;
+
+ if (!haveQuarks) {
+ XrmQEleft = XrmPermStringToQuark(XtEleft);
+ XrmQEcenter = XrmPermStringToQuark(XtEcenter);
+ XrmQEright = XrmPermStringToQuark(XtEright);
+ haveQuarks = 1;
+ }
+
+ if (strlen (s) < sizeof lowerName) {
+
+ XmuCopyISOLatin1Lowered(lowerName, s);
+
+ q = XrmStringToQuark(lowerName);
+
+ toVal->size = sizeof(XtJustify);
+ toVal->addr = (XPointer) &e;
+
+ if (q == XrmQEleft) { e = XtJustifyLeft; return; }
+ if (q == XrmQEcenter) { e = XtJustifyCenter; return; }
+ if (q == XrmQEright) { e = XtJustifyRight; return; }
+ }
+
+ toVal->size = 0;
+ toVal->addr = NULL;
+}
diff --git a/src/StrToLong.c b/src/StrToLong.c
new file mode 100644
index 0000000..bb39466
--- /dev/null
+++ b/src/StrToLong.c
@@ -0,0 +1,53 @@
+/* $Xorg: StrToLong.c,v 1.4 2001/02/09 02:03:53 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/Intrinsic.h>
+#include "Converters.h"
+
+#define done(address, type) \
+ { (*toVal).size = sizeof(type); (*toVal).addr = (XPointer) address; }
+
+void XmuCvtStringToLong (args, num_args, fromVal, toVal)
+ XrmValuePtr args;
+ Cardinal *num_args;
+ XrmValuePtr fromVal;
+ XrmValuePtr toVal;
+{
+ static long l;
+
+ if (*num_args != 0)
+ XtWarningMsg("wrongParameters","cvtStringToLong","XtToolkitError",
+ "String to Long conversion needs no extra arguments",
+ (String *) NULL, (Cardinal *)NULL);
+ if (sscanf((char *)fromVal->addr, "%ld", &l) == 1) {
+ done(&l, long);
+ } else {
+ XtStringConversionWarning((char *) fromVal->addr, XtRLong);
+ }
+}
diff --git a/src/StrToOrnt.c b/src/StrToOrnt.c
new file mode 100644
index 0000000..fc45af5
--- /dev/null
+++ b/src/StrToOrnt.c
@@ -0,0 +1,75 @@
+/* $Xorg: StrToOrnt.c,v 1.4 2001/02/09 02:03:53 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 <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include "Converters.h"
+#include "CharSet.h"
+
+
+#define done(address, type) \
+ { (*toVal).size = sizeof(type); (*toVal).addr = (XPointer) address; }
+
+/* ARGSUSED */
+void
+XmuCvtStringToOrientation(args, num_args, fromVal, toVal)
+ XrmValuePtr args; /* unused */
+ Cardinal *num_args; /* unused */
+ XrmValuePtr fromVal;
+ XrmValuePtr toVal;
+{
+ static XtOrientation orient;
+ static XrmQuark XtQEhorizontal;
+ static XrmQuark XtQEvertical;
+ static int haveQuarks = 0;
+ XrmQuark q;
+ char lowerName[40];
+
+ if (!haveQuarks) {
+ XtQEhorizontal = XrmPermStringToQuark(XtEhorizontal);
+ XtQEvertical = XrmPermStringToQuark(XtEvertical);
+ haveQuarks = 1;
+ }
+
+ if (strlen ((char*)fromVal->addr) < sizeof lowerName) {
+ XmuCopyISOLatin1Lowered(lowerName, (char *) fromVal->addr);
+ q = XrmStringToQuark(lowerName);
+ if (q == XtQEhorizontal) {
+ orient = XtorientHorizontal;
+ done(&orient, XtOrientation);
+ return;
+ }
+ if (q == XtQEvertical) {
+ orient = XtorientVertical;
+ done(&orient, XtOrientation);
+ return;
+ }
+ }
+ toVal->size = 0;
+ toVal->addr = NULL;
+}
diff --git a/src/StrToShap.c b/src/StrToShap.c
new file mode 100644
index 0000000..cf0c548
--- /dev/null
+++ b/src/StrToShap.c
@@ -0,0 +1,88 @@
+/* $Xorg: StrToShap.c,v 1.5 2001/02/09 02:03:53 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 <X11/Intrinsic.h>
+#include "Converters.h"
+#include "CharSet.h"
+
+/* ARGSUSED */
+#define done(type, value) \
+ { \
+ if (toVal->addr != NULL) { \
+ if (toVal->size < sizeof(type)) { \
+ toVal->size = sizeof(type); \
+ return False; \
+ } \
+ *(type*)(toVal->addr) = (value); \
+ } \
+ else { \
+ static type static_val; \
+ static_val = (value); \
+ toVal->addr = (XtPointer)&static_val; \
+ } \
+ toVal->size = sizeof(type); \
+ return True; \
+ }
+
+
+Boolean XmuCvtStringToShapeStyle(dpy, args, num_args, from, toVal, data)
+ Display *dpy;
+ XrmValue *args; /* unused */
+ Cardinal *num_args; /* unused */
+ XrmValue *from;
+ XrmValue *toVal;
+ XtPointer *data; /* unused */
+{
+ if ( XmuCompareISOLatin1((char*)from->addr, XtERectangle) == 0
+ || XmuCompareISOLatin1((char*)from->addr, "ShapeRectangle") == 0)
+ done( int, XmuShapeRectangle );
+ if ( XmuCompareISOLatin1((char*)from->addr, XtEOval) == 0
+ || XmuCompareISOLatin1((char*)from->addr, "ShapeOval") == 0)
+ done( int, XmuShapeOval );
+ if ( XmuCompareISOLatin1((char*)from->addr, XtEEllipse) == 0
+ || XmuCompareISOLatin1((char*)from->addr, "ShapeEllipse") == 0)
+ done( int, XmuShapeEllipse );
+ if ( XmuCompareISOLatin1((char*)from->addr, XtERoundedRectangle) == 0
+ || XmuCompareISOLatin1((char*)from->addr, "ShapeRoundedRectangle") == 0)
+ done( int, XmuShapeRoundedRectangle );
+ {
+ int style = 0;
+ char ch, *p = (char*)from->addr;
+ while ((ch = *p++)) {
+ if (ch >= '0' && ch <= '9') {
+ style *= 10;
+ style += ch - '0';
+ }
+ else break;
+ }
+ if (ch == '\0' && style <= XmuShapeRoundedRectangle)
+ done( int, style );
+ }
+ XtDisplayStringConversionWarning( dpy, (char*)from->addr, XtRShapeStyle );
+ return False;
+}
diff --git a/src/StrToWidg.c b/src/StrToWidg.c
new file mode 100644
index 0000000..115a86c
--- /dev/null
+++ b/src/StrToWidg.c
@@ -0,0 +1,183 @@
+/* $Xorg: StrToWidg.c,v 1.4 2001/02/09 02:03:53 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.
+
+*/
+
+/*
+ * XmuCvtStringToWidget
+ *
+ * static XtConvertArgRec parentCvtArgs[] = {
+ * {XtBaseOffset, (XtPointer)XtOffset(Widget, core.parent), sizeof(Widget)},
+ * };
+ *
+ * matches the string against the name of the immediate children (normal
+ * or popup) of the parent. If none match, compares string to classname
+ * & returns first match. Case is significant.
+ */
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/ObjectP.h>
+
+#define done(address, type) \
+ { toVal->size = sizeof(type); \
+ toVal->addr = (XPointer) address; \
+ return; \
+ }
+
+/* ARGSUSED */
+void XmuCvtStringToWidget(args, num_args, fromVal, toVal)
+ XrmValuePtr args; /* parent */
+ Cardinal *num_args; /* 1 */
+ XrmValuePtr fromVal;
+ XrmValuePtr toVal;
+{
+ static Widget widget, *widgetP, parent;
+ XrmName name = XrmStringToName(fromVal->addr);
+ int i;
+
+ if (*num_args != 1)
+ XtErrorMsg("wrongParameters", "cvtStringToWidget", "xtToolkitError",
+ "StringToWidget conversion needs parent arg", NULL, 0);
+
+ parent = *(Widget*)args[0].addr;
+ /* try to match names of normal children */
+ if (XtIsComposite(parent)) {
+ i = ((CompositeWidget)parent)->composite.num_children;
+ for (widgetP = ((CompositeWidget)parent)->composite.children;
+ i; i--, widgetP++) {
+ if ((*widgetP)->core.xrm_name == name) {
+ widget = *widgetP;
+ done(&widget, Widget);
+ }
+ }
+ }
+ /* try to match names of popup children */
+ i = parent->core.num_popups;
+ for (widgetP = parent->core.popup_list; i; i--, widgetP++) {
+ if ((*widgetP)->core.xrm_name == name) {
+ widget = *widgetP;
+ done(&widget, Widget);
+ }
+ }
+ /* try to match classes of normal children */
+ if (XtIsComposite(parent)) {
+ i = ((CompositeWidget)parent)->composite.num_children;
+ for (widgetP = ((CompositeWidget)parent)->composite.children;
+ i; i--, widgetP++) {
+ if ((*widgetP)->core.widget_class->core_class.xrm_class == name) {
+ widget = *widgetP;
+ done(&widget, Widget);
+ }
+ }
+ }
+ /* try to match classes of popup children */
+ i = parent->core.num_popups;
+ for (widgetP = parent->core.popup_list; i; i--, widgetP++) {
+ if ((*widgetP)->core.widget_class->core_class.xrm_class == name) {
+ widget = *widgetP;
+ done(&widget, Widget);
+ }
+ }
+ XtStringConversionWarning(fromVal->addr, XtRWidget);
+ toVal->addr = NULL;
+ toVal->size = 0;
+}
+
+#undef done
+
+#define newDone(type, value) \
+ { \
+ if (toVal->addr != NULL) { \
+ if (toVal->size < sizeof(type)) { \
+ toVal->size = sizeof(type); \
+ return False; \
+ } \
+ *(type*)(toVal->addr) = (value); \
+ } \
+ else { \
+ static type static_val; \
+ static_val = (value); \
+ toVal->addr = (XtPointer)&static_val; \
+ } \
+ toVal->size = sizeof(type); \
+ return True; \
+ }
+
+
+/*ARGSUSED*/
+Boolean XmuNewCvtStringToWidget(dpy, args, num_args, fromVal, toVal,
+ converter_data)
+ Display *dpy;
+ XrmValue *args; /* parent */
+ Cardinal *num_args; /* 1 */
+ XrmValue *fromVal;
+ XrmValue *toVal;
+ XtPointer *converter_data;
+{
+ Widget *widgetP, parent;
+ XrmName name = XrmStringToName(fromVal->addr);
+ int i;
+
+ if (*num_args != 1)
+ XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
+ "wrongParameters","cvtStringToWidget","xtToolkitError",
+ "String To Widget conversion needs parent argument",
+ (String *)NULL, (Cardinal *)NULL);
+
+ parent = *(Widget*)args[0].addr;
+ /* try to match names of normal children */
+ if (XtIsComposite(parent)) {
+ i = ((CompositeWidget)parent)->composite.num_children;
+ for (widgetP = ((CompositeWidget)parent)->composite.children;
+ i; i--, widgetP++) {
+ if ((*widgetP)->core.xrm_name == name)
+ newDone(Widget, *widgetP);
+ }
+ }
+ /* try to match names of popup children */
+ i = parent->core.num_popups;
+ for (widgetP = parent->core.popup_list; i; i--, widgetP++) {
+ if ((*widgetP)->core.xrm_name == name)
+ newDone(Widget, *widgetP);
+ }
+ /* try to match classes of normal children */
+ if (XtIsComposite(parent)) {
+ i = ((CompositeWidget)parent)->composite.num_children;
+ for (widgetP = ((CompositeWidget)parent)->composite.children;
+ i; i--, widgetP++) {
+ if ((*widgetP)->core.widget_class->core_class.xrm_class == name)
+ newDone(Widget, *widgetP);
+ }
+ }
+ /* try to match classes of popup children */
+ i = parent->core.num_popups;
+ for (widgetP = parent->core.popup_list; i; i--, widgetP++) {
+ if ((*widgetP)->core.widget_class->core_class.xrm_class == name)
+ newDone(Widget, *widgetP);
+ }
+ XtDisplayStringConversionWarning(dpy, (String)fromVal->addr, XtRWidget);
+ return False;
+}
diff --git a/src/UpdMapHint.c b/src/UpdMapHint.c
new file mode 100644
index 0000000..afd7f22
--- /dev/null
+++ b/src/UpdMapHint.c
@@ -0,0 +1,59 @@
+/* $Xorg: UpdMapHint.c,v 1.4 2001/02/09 02:03:53 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.
+
+*/
+
+/*
+ * Author: Jim Fulton, MIT X Consortium
+ */
+
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+Bool XmuUpdateMapHints (dpy, w, hints)
+ Display *dpy;
+ Window w;
+ XSizeHints *hints;
+{
+ static XSizeHints *shp = NULL;
+
+ if (!hints) { /* get them first */
+ long supp;
+
+ if (!shp) {
+ shp = XAllocSizeHints();
+ if (!shp) return False;
+ }
+ if (!XGetWMNormalHints (dpy, w, shp, &supp)) return False;
+ hints = shp;
+ }
+ hints->flags &= ~(PPosition|PSize);
+ hints->flags |= (USPosition|USSize);
+ XSetWMNormalHints (dpy, w, hints);
+ return True;
+}
+
diff --git a/src/VisCmap.c b/src/VisCmap.c
new file mode 100644
index 0000000..d560853
--- /dev/null
+++ b/src/VisCmap.c
@@ -0,0 +1,175 @@
+/* $Xorg: VisCmap.c,v 1.4 2001/02/09 02:03:53 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.
+
+*/
+
+/*
+ * Author: Donna Converse, MIT X Consortium
+ */
+
+#include <stdio.h>
+#include <math.h>
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+#include <X11/Xmu/StdCmap.h>
+
+/*
+ * To create all of the appropriate standard colormaps for a given visual on
+ * a given screen, use XmuVisualStandardColormaps.
+ *
+ * Define all appropriate standard colormap properties for the given visual.
+ * If replace is true, any previous definition will be removed.
+ * If retain is true, new properties will be retained for the duration of
+ * the server session. Return 0 on failure, non-zero on success.
+ * On failure, no new properties will be defined, and, old ones may have
+ * been removed if replace was True.
+ *
+ * Not all standard colormaps are meaningful to all visual classes. This
+ * routine will check and define the following properties for the following
+ * classes, provided that the size of the colormap is not too small.
+ *
+ * DirectColor and PseudoColor
+ * RGB_DEFAULT_MAP
+ * RGB_BEST_MAP
+ * RGB_RED_MAP
+ * RGB_GREEN_MAP
+ * RGB_BLUE_MAP
+ * RGB_GRAY_MAP
+ *
+ * TrueColor and StaticColor
+ * RGB_BEST_MAP
+ *
+ * GrayScale and StaticGray
+ * RGB_GRAY_MAP
+ */
+
+Status XmuVisualStandardColormaps(dpy, screen, visualid, depth, replace,
+ retain)
+ Display *dpy; /* specifies server connection */
+ int screen; /* specifies screen number */
+ VisualID visualid; /* specifies the visual */
+ unsigned int depth; /* specifies the visual */
+ Bool replace; /* specifies whether to replace */
+ Bool retain; /* specifies whether to retain */
+{
+ Status status;
+ int n;
+ long vinfo_mask;
+ XVisualInfo vinfo_template, *vinfo;
+
+ vinfo_template.screen = screen;
+ vinfo_template.visualid = visualid;
+ vinfo_template.depth = depth;
+ vinfo_mask = VisualScreenMask | VisualIDMask | VisualDepthMask;
+ if ((vinfo = XGetVisualInfo(dpy, vinfo_mask, &vinfo_template, &n)) == NULL)
+ return 0;
+
+ if (vinfo->colormap_size <= 2) {
+ /* Monochrome visuals have no standard maps; considered successful */
+ XFree((char *) vinfo);
+ return 1;
+ }
+
+ switch (vinfo->class)
+ {
+ case PseudoColor:
+ case DirectColor:
+ status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
+ XA_RGB_DEFAULT_MAP, replace,retain);
+ if (!status) break;
+
+ status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
+ XA_RGB_GRAY_MAP, replace, retain);
+ if (!status) {
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP);
+ break;
+ }
+
+ status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
+ XA_RGB_RED_MAP, replace, retain);
+ if (!status) {
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP);
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_GRAY_MAP);
+ break;
+ }
+
+ status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
+ XA_RGB_GREEN_MAP, replace, retain);
+ if (!status) {
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP);
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_GRAY_MAP);
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_RED_MAP);
+ break;
+ }
+
+ status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
+ XA_RGB_BLUE_MAP, replace, retain);
+ if (!status) {
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP);
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_GRAY_MAP);
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_RED_MAP);
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_GREEN_MAP);
+ break;
+ }
+ /* fall through */
+
+ case StaticColor:
+ case TrueColor:
+
+ status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
+ XA_RGB_BEST_MAP, replace, retain);
+ if (!status && (vinfo->class == PseudoColor ||
+ vinfo->class == DirectColor)) {
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP);
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_GRAY_MAP);
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_RED_MAP);
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_GREEN_MAP);
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_BLUE_MAP);
+ }
+ break;
+ /* the end for PseudoColor, DirectColor, StaticColor, and TrueColor */
+
+ case GrayScale:
+ status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
+ XA_RGB_DEFAULT_MAP, replace,
+ retain);
+ if (! status) break;
+ /* fall through */
+
+ case StaticGray:
+
+ status = XmuLookupStandardColormap(dpy, screen, visualid, depth,
+ XA_RGB_GRAY_MAP, replace, retain);
+ if (! status && vinfo->class == GrayScale) {
+ XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP);
+ break;
+ }
+ }
+
+ XFree((char *) vinfo);
+ return status;
+}
diff --git a/src/WidgetNode.c b/src/WidgetNode.c
new file mode 100644
index 0000000..9c039e0
--- /dev/null
+++ b/src/WidgetNode.c
@@ -0,0 +1,305 @@
+/* $Xorg: WidgetNode.c,v 1.5 2001/02/09 02:03:53 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.
+
+*/
+
+/*
+ * Author: Jim Fulton, MIT X Consortium
+ */
+
+
+
+#include <stdio.h>
+#include <X11/Xos.h>
+#include <X11/IntrinsicP.h>
+#include <X11/Xaw/Cardinals.h>
+#include <X11/Xmu/CharSet.h>
+#include <X11/Xmu/WidgetNode.h>
+
+
+static char *binsearch (key, base, nelems, elemsize, compar)
+ char *key; /* template of object to find */
+ char *base; /* beginning of array */
+ int nelems; /* number of elements in array */
+ int elemsize; /* sizeof an element */
+ int (*compar)(); /* qsort-style compare function */
+{
+ int lower = 0, upper = nelems - 1;
+
+ while (lower <= upper) {
+ int middle = (lower + upper) / 2;
+ char *p = base + middle * elemsize;
+ int res = (*compar) (p, key);
+
+ if (res < 0) {
+ lower = middle + 1;
+ } else if (res == 0) {
+ return p;
+ } else {
+ upper = middle - 1;
+ }
+ }
+
+ return NULL;
+}
+
+
+static int compare_resource_entries (a, b)
+ register char *a, *b;
+{
+ return strcmp (((XtResourceList)a)->resource_name,
+ ((XtResourceList)b)->resource_name);
+}
+
+
+static XmuWidgetNode *find_resource (node, name, cons)
+ XmuWidgetNode *node;
+ char *name;
+ Bool cons;
+{
+ register XmuWidgetNode *sup;
+ XtResource res;
+
+#define reslist ((char *) (cons ? sup->constraints : sup->resources))
+#define nreslist (int) (cons ? sup->nconstraints : sup->nresources)
+
+ res.resource_name = name;
+ for (sup = node->superclass;
+ sup && (XtResourceList) binsearch ((char *) &res,
+ reslist, nreslist,
+ sizeof(XtResource),
+ compare_resource_entries);
+ node = sup, sup = sup->superclass) ;
+
+#undef reslist
+#undef nreslist
+
+ return node;
+}
+
+
+static void mark_resource_owner (node)
+ register XmuWidgetNode *node;
+{
+ register int i;
+ XtResourceList childres;
+
+ childres = node->resources;
+ for (i = 0; i < node->nresources; i++, childres++) {
+ node->resourcewn[i] = find_resource (node, childres->resource_name,
+ False);
+ }
+
+ childres = node->constraints;
+ for (i = 0; i < node->nconstraints; i++, childres++) {
+ node->constraintwn[i] = find_resource (node, childres->resource_name,
+ True);
+ }
+}
+
+
+/*
+ * Public Interfaces
+ */
+
+void XmuWnInitializeNodes (nodearray, nnodes)
+ XmuWidgetNode *nodearray;
+ int nnodes;
+{
+ int i;
+ XmuWidgetNode *wn;
+
+ /*
+ * Assume that the node array is in alphabetic order, so we need to
+ * search backwards to make sure that the children are listed forward.
+ */
+ for (i = nnodes - 1, wn = nodearray + (nnodes - 1); i >= 0; i--, wn--) {
+ WidgetClass superclass = XmuWnSuperclass(wn);
+ int j;
+ XmuWidgetNode *swn;
+ int lablen = strlen (wn->label);
+ int namelen = strlen (XmuWnClassname(wn));
+
+ wn->lowered_label = XtMalloc (lablen + namelen + 2);
+ if (!wn->lowered_label) {
+ fprintf (stderr,
+ "%s: unable to allocate %d bytes for widget name\n",
+ "XmuWnInitializeNodes", lablen + namelen + 2);
+ exit (1);
+ }
+ wn->lowered_classname = wn->lowered_label + (lablen + 1);
+ XmuCopyISOLatin1Lowered (wn->lowered_label, wn->label);
+ XmuCopyISOLatin1Lowered (wn->lowered_classname, XmuWnClassname(wn));
+ wn->superclass = NULL;
+ wn->have_resources = False;
+ wn->resources = NULL;
+ wn->resourcewn = NULL;
+ wn->nresources = 0;
+ wn->constraints = NULL;
+ wn->constraintwn = NULL;
+ wn->nconstraints = 0;
+ wn->data = (XtPointer) NULL;
+
+ /*
+ * walk up the superclass chain
+ */
+ while (superclass) {
+ for (j = 0, swn = nodearray; j < nnodes; j++, swn++) {
+ if (superclass == XmuWnClass(swn)) {
+ wn->superclass = swn;
+ goto done; /* stupid C language */
+ }
+ }
+ /*
+ * Hmm, we have a hidden superclass (such as in core in R4); just
+ * ignore it and keep on walking
+ */
+ superclass = superclass->core_class.superclass;
+ }
+ done:
+ if (wn->superclass) {
+ wn->siblings = wn->superclass->children;
+ wn->superclass->children = wn;
+ }
+ }
+
+ return;
+}
+
+
+void XmuWnFetchResources (node, toplevel, topnode)
+ XmuWidgetNode *node;
+ Widget toplevel;
+ XmuWidgetNode *topnode;
+{
+ Widget dummy;
+ XmuWidgetNode *wn;
+
+ if (node->have_resources) return;
+
+ dummy = XtCreateWidget (node->label, XmuWnClass(node), toplevel,
+ NULL, ZERO);
+ if (dummy) XtDestroyWidget (dummy);
+
+
+ /*
+ * walk up tree geting resources; since we've instantiated the widget,
+ * we know that all of our superclasses have been initialized
+ */
+ for (wn = node; wn && !wn->have_resources; wn = wn->superclass) {
+ XtGetResourceList (XmuWnClass(wn), &wn->resources, &wn->nresources);
+ if (wn->resources) {
+ qsort ((char *) wn->resources, wn->nresources,
+ sizeof(XtResource), compare_resource_entries);
+ }
+ wn->resourcewn = (XmuWidgetNode **) XtCalloc (wn->nresources,
+ sizeof (XmuWidgetNode *));
+ if (!wn->resourcewn) {
+ fprintf (stderr,
+ "%s: unable to calloc %d %d byte widget node ptrs\n",
+ "XmuWnFetchResources",wn->nresources,
+ sizeof (XmuWidgetNode *));
+ exit (1);
+ }
+
+ XtGetConstraintResourceList (XmuWnClass(wn), &wn->constraints,
+ &wn->nconstraints);
+ if (wn->constraints) {
+ qsort ((char *) wn->constraints, wn->nconstraints,
+ sizeof(XtResource), compare_resource_entries);
+ }
+ wn->constraintwn = (XmuWidgetNode **)
+ XtCalloc (wn->nconstraints, sizeof (XmuWidgetNode *));
+ if (!wn->constraintwn) {
+ fprintf (stderr,
+ "%s: unable to calloc %d %d byte widget node ptrs\n",
+ "XmuWnFetchResources", wn->nconstraints,
+ sizeof (XmuWidgetNode *));
+ exit (1);
+ }
+
+ wn->have_resources = True;
+ if (wn == topnode) break;
+ }
+
+
+ /*
+ * Walk up tree removing all resources that appear in superclass; we can
+ * mash the resource list in place since it was copied out of widget.
+ */
+ for (wn = node; wn; wn = wn->superclass) {
+ mark_resource_owner (wn);
+ if (wn == topnode) break;
+ }
+
+ return;
+}
+
+
+int XmuWnCountOwnedResources (node, ownernode, cons)
+ XmuWidgetNode *node, *ownernode;
+ Bool cons;
+{
+ register int i;
+ XmuWidgetNode **wn = (cons ? node->constraintwn : node->resourcewn);
+ int nmatches = 0;
+
+ for (i = (cons ? node->nconstraints : node->nresources); i > 0; i--, wn++)
+ if (*wn == ownernode) nmatches++;
+ return nmatches;
+}
+
+
+#if NeedFunctionPrototypes
+XmuWidgetNode *XmuWnNameToNode (XmuWidgetNode *nodelist, int nnodes,
+ _Xconst char *name)
+#else
+XmuWidgetNode *XmuWnNameToNode (nodelist, nnodes, name)
+ XmuWidgetNode *nodelist;
+ int nnodes;
+ char *name;
+#endif
+{
+ int i;
+ XmuWidgetNode *wn;
+ char* tmpp;
+ char tmp[1024];
+ XmuWidgetNode* ret = NULL;
+
+ if ((i = strlen (name)) < sizeof tmp) tmpp = tmp;
+ else tmpp = XtMalloc (i + 1);
+ if (tmpp == NULL) return ret;
+ XmuCopyISOLatin1Lowered (tmpp, name);
+ for (i = 0, wn = nodelist; i < nnodes; i++, wn++) {
+ if (strcmp (tmpp, wn->lowered_label) == 0 ||
+ strcmp (tmpp, wn->lowered_classname) == 0) {
+ ret = wn;
+ break;
+ }
+ }
+ if (tmpp != tmp) XtFree (tmpp);
+ return ret;
+}
diff --git a/src/Xct.c b/src/Xct.c
new file mode 100644
index 0000000..2014c4d
--- /dev/null
+++ b/src/Xct.c
@@ -0,0 +1,695 @@
+/* $Xorg: Xct.c,v 1.4 2001/02/09 02:03:53 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/Xfuncs.h>
+#include "Xct.h"
+#include <stdio.h>
+
+#define UsedGraphic 0x0001
+#define UsedDirection 0x0002
+
+typedef struct _XctPriv {
+ XctString ptr;
+ XctString ptrend;
+ unsigned flags;
+ XctHDirection *dirstack;
+ unsigned dirsize;
+ char **encodings;
+ unsigned enc_count;
+ XctString itembuf;
+ unsigned buf_count;
+} *XctPriv;
+
+#define IsMore(priv) ((priv)->ptr != (priv)->ptrend)
+#define AmountLeft(priv) ((priv)->ptrend - (priv)->ptr)
+
+extern char *malloc();
+extern char *realloc();
+
+#define HT 0x09
+#define NL 0x0a
+#define ESC 0x1b
+#define CSI 0x9b
+
+#define IsLegalC0(data, c) (((c) == HT) || ((c) == NL) || \
+ (((data)->version > XctVersion) && \
+ ((data)->flags & XctAcceptC0Extensions)))
+
+#define IsLegalC1(priv, c) (((data)->version > XctVersion) && \
+ ((data)->flags & XctAcceptC1Extensions))
+
+#define IsI2(c) (((c) >= 0x20) && ((c) <= 0x2f))
+#define IsI3(c) (((c) >= 0x30) && ((c) <= 0x3f))
+#define IsESCF(c) (((c) >= 0x30) && ((c) <= 0x7e))
+#define IsCSIF(c) (((c) >= 0x40) && ((c) <= 0x7e))
+#define IsC0(c) ((c) <= 0x1f)
+#define IsGL(c) (((c) >= 0x20) && ((c) <= 0x7f))
+#define IsC1(c) (((c) >= 0x80) && ((c) <= 0x9f))
+#define IsGR(c) ((c) >= 0xa0)
+
+#define HasC 1
+#define HasGL 2
+#define HasGR 4
+#define ToGL 8
+
+static void
+ComputeGLGR(data)
+ register XctData data;
+{
+ /* XXX this will need more work if more sets are registered */
+ if ((data->GL_set_size == 94) && (data->GL_char_size == 1) &&
+ (data->GL[0] == '\102') &&
+ (data->GR_set_size == 96) && (data->GR_char_size == 1))
+ data->GLGR_encoding = data->GR_encoding;
+ else if ((data->GL_set_size == 94) && (data->GL_char_size == 1) &&
+ (data->GL[0] == '\112') &&
+ (data->GR_set_size == 94) && (data->GR_char_size == 1))
+ data->GLGR_encoding = data->GR_encoding;
+ else
+ data->GLGR_encoding = (char *)NULL;
+}
+
+static int
+HandleGL(data, c)
+ register XctData data;
+ unsigned char c;
+{
+ switch (c) {
+ case 0x42:
+ data->GL = "\102";
+ data->GL_encoding = "ISO8859-1";
+ break;
+ case 0x4a:
+ data->GL = "\112";
+ data->GL_encoding = "JISX0201.1976-0";
+ break;
+ default:
+ return 0;
+ }
+ data->GL_set_size = 94;
+ data->GL_char_size = 1;
+ ComputeGLGR(data);
+ return 1;
+}
+
+static int
+HandleMultiGL(data, c)
+ register XctData data;
+ unsigned char c;
+{
+ switch (c) {
+ case 0x41:
+ data->GL = "\101";
+ data->GL_encoding = "GB2312.1980-0";
+ break;
+ case 0x42:
+ data->GL = "\102";
+ data->GL_encoding = "JISX0208.1983-0";
+ break;
+ case 0x43:
+ data->GL = "\103";
+ data->GL_encoding = "KSC5601.1987-0";
+ break;
+ default:
+ return 0;
+ }
+ data->GL_set_size = 94;
+ data->GL_char_size = 2;
+#ifdef notdef
+ if (c < 0x60)
+ data->GL_char_size = 2;
+ else if (c < 0x70)
+ data->GL_char_size = 3;
+ else
+ data->GL_char_size = 4;
+#endif
+ data->GLGR_encoding = (char *)NULL;
+ return 1;
+}
+
+static int
+Handle94GR(data, c)
+ register XctData data;
+ unsigned char c;
+{
+ switch (c) {
+ case 0x49:
+ data->GR = "\111";
+ data->GR_encoding = "JISX0201.1976-0";
+ break;
+ default:
+ return 0;
+ }
+ data->priv->flags &= ~ToGL;
+ data->GR_set_size = 94;
+ data->GR_char_size = 1;
+ data->GLGR_encoding = (char *)NULL;
+ return 1;
+}
+
+static int
+Handle96GR(data, c)
+ register XctData data;
+ unsigned char c;
+{
+ switch (c) {
+ case 0x41:
+ data->GR = "\101";
+ data->GR_encoding = "ISO8859-1";
+ break;
+ case 0x42:
+ data->GR = "\102";
+ data->GR_encoding = "ISO8859-2";
+ break;
+ case 0x43:
+ data->GR = "\103";
+ data->GR_encoding = "ISO8859-3";
+ break;
+ case 0x44:
+ data->GR = "\104";
+ data->GR_encoding = "ISO8859-4";
+ break;
+ case 0x46:
+ data->GR = "\106";
+ data->GR_encoding = "ISO8859-7";
+ break;
+ case 0x47:
+ data->GR = "\107";
+ data->GR_encoding = "ISO8859-6";
+ break;
+ case 0x48:
+ data->GR = "\110";
+ data->GR_encoding = "ISO8859-8";
+ break;
+ case 0x4c:
+ data->GR = "\114";
+ data->GR_encoding = "ISO8859-5";
+ break;
+ case 0x4d:
+ data->GR = "\115";
+ data->GR_encoding = "ISO8859-9";
+ break;
+ default:
+ return 0;
+ }
+ data->priv->flags &= ~ToGL;
+ data->GR_set_size = 96;
+ data->GR_char_size = 1;
+ ComputeGLGR(data);
+ return 1;
+}
+
+static int
+HandleMultiGR(data, c)
+ register XctData data;
+ unsigned char c;
+{
+ switch (c) {
+ case 0x41:
+ data->GR = "\101";
+ if (data->flags & XctShiftMultiGRToGL)
+ data->GR_encoding = "GB2312.1980-0";
+ else
+ data->GR_encoding = "GB2312.1980-1";
+ break;
+ case 0x42:
+ data->GR = "\102";
+ if (data->flags & XctShiftMultiGRToGL)
+ data->GR_encoding = "JISX0208.1983-0";
+ else
+ data->GR_encoding = "JISX0208.1983-1";
+ break;
+ case 0x43:
+ data->GR = "\103";
+ if (data->flags & XctShiftMultiGRToGL)
+ data->GR_encoding = "KSC5601.1987-0";
+ else
+ data->GR_encoding = "KSC5601.1987-1";
+ break;
+ default:
+ return 0;
+ }
+ if (data->flags & XctShiftMultiGRToGL)
+ data->priv->flags |= ToGL;
+ else
+ data->priv->flags &= ~ToGL;
+ data->GR_set_size = 94;
+ data->GR_char_size = 2;
+#ifdef notdef
+ if (c < 0x60)
+ data->GR_char_size = 2;
+ else if (c < 0x70)
+ data->GR_char_size = 3;
+ else
+ data->GR_char_size = 4;
+#endif
+ data->GLGR_encoding = (char *)NULL;
+ return 1;
+}
+
+static int
+HandleExtended(data, c)
+ register XctData data;
+ unsigned char c;
+{
+ register XctPriv priv = data->priv;
+ XctString enc = data->item + 6;
+ register XctString ptr = enc;
+ int i, len;
+
+ while (*ptr != 0x02) {
+ if (!*ptr || (++ptr == priv->ptr))
+ return 0;
+ }
+ data->item = ptr + 1;
+ data->item_length = priv->ptr - data->item;
+ len = ptr - enc;
+ for (i = 0;
+ (i < priv->enc_count) &&
+ strncmp(priv->encodings[i], (char *)enc, len);
+ i++)
+ ;
+ if (i == priv->enc_count) {
+ XctString cp;
+
+ for (cp = enc; cp != ptr; cp++) {
+ if ((!IsGL(*cp) && !IsGR(*cp)) || (*cp == 0x2a) || (*cp == 0x3f))
+ return 0;
+ }
+ ptr = (XctString)malloc((unsigned)len + 1);
+ (void) memmove((char *)ptr, (char *)enc, len);
+ ptr[len] = 0x00;
+ priv->enc_count++;
+ if (priv->encodings)
+ priv->encodings = (char **)realloc(
+ (char *)priv->encodings,
+ priv->enc_count * sizeof(char *));
+ else
+ priv->encodings = (char **)malloc(sizeof(char *));
+ priv->encodings[i] = (char *)ptr;
+ }
+ data->encoding = priv->encodings[i];
+ data->char_size = c - 0x30;
+ return 1;
+}
+
+static void
+ShiftGRToGL(data, hasCdata)
+ register XctData data;
+ int hasCdata;
+{
+ register XctPriv priv = data->priv;
+ register int i;
+
+ if (data->item_length > priv->buf_count) {
+ priv->buf_count = data->item_length;
+ if (priv->itembuf)
+ priv->itembuf = (XctString)realloc((char *)priv->itembuf,
+ priv->buf_count);
+ else
+ priv->itembuf = (XctString)malloc(priv->buf_count);
+ }
+ (void) memmove((char *)priv->itembuf, (char *)data->item,
+ data->item_length);
+ data->item = priv->itembuf;
+ if (hasCdata) {
+ for (i = data->item_length; --i >= 0; ) {
+ if (IsGR(data->item[i]))
+ data->item[i] &= 0x7f;
+ }
+ } else {
+ for (i = data->item_length; --i >= 0; )
+ data->item[i] &= 0x7f;
+ }
+}
+
+/* Create an XctData structure for parsing a Compound Text string. */
+#if NeedFunctionPrototypes
+XctData
+XctCreate(_Xconst unsigned char *string, int length, XctFlags flags)
+#else
+XctData
+XctCreate(string, length, flags)
+ XctString string;
+ int length;
+ XctFlags flags;
+#endif
+{
+ register XctData data;
+ register XctPriv priv;
+
+ data = (XctData)malloc(sizeof(struct _XctRec) + sizeof(struct _XctPriv));
+ if (!data)
+ return data;
+ data->priv = priv = (XctPriv)(data + 1);
+ data->total_string = (XctString)string;
+ data->total_length = length;
+ data->flags = flags;
+ priv->dirstack = (XctHDirection *)NULL;
+ priv->dirsize = 0;
+ priv->encodings = (char **)NULL;
+ priv->enc_count = 0;
+ priv->itembuf = (XctString)NULL;
+ priv->buf_count = 0;
+ XctReset(data);
+ return data;
+}
+
+/* Reset the XctData structure to re-parse the string from the beginning. */
+void
+XctReset(data)
+ register XctData data;
+{
+ register XctPriv priv = data->priv;
+
+ priv->ptr = data->total_string;
+ priv->ptrend = data->total_string + data->total_length;
+ data->item = (XctString)NULL;
+ data->item_length = 0;
+ data->encoding = (char *)NULL;
+ data->char_size = 1;
+ data->horizontal = XctUnspecified;
+ data->horz_depth = 0;
+ priv->flags = 0;
+ data->GL_set_size = data->GR_set_size = 0; /* XXX */
+ (void)HandleGL(data, (unsigned char)0x42);
+ (void)Handle96GR(data, (unsigned char)0x41);
+ data->version = 1;
+ data->can_ignore_exts = 0;
+ /* parse version, if present */
+ if ((data->total_length >= 4) &&
+ (priv->ptr[0] == ESC) && (priv->ptr[1] == 0x23) &&
+ IsI2(priv->ptr[2]) &&
+ ((priv->ptr[3] == 0x30) || (priv->ptr[3] == 0x31))) {
+ data->version = priv->ptr[2] - 0x1f;
+ if (priv->ptr[3] == 0x30)
+ data->can_ignore_exts = 1;
+ priv->ptr += 4;
+ }
+}
+
+/* Parse the next "item" from the Compound Text string. The return value
+ * indicates what kind of item is returned. The item itself, and the current
+ * contextual state, are reported as components of the XctData structure.
+ */
+XctResult
+XctNextItem(data)
+ register XctData data;
+{
+ register XctPriv priv = data->priv;
+ unsigned char c;
+ int len, bits;
+
+#define NEXT data->item_length++; priv->ptr++
+
+ while (IsMore(priv)) {
+ data->item = priv->ptr;
+ data->item_length = 0;
+ c = *priv->ptr;
+ if (c == ESC) {
+ NEXT;
+ while (IsMore(priv) && IsI2(*priv->ptr)) {
+ NEXT;
+ }
+ if (!IsMore(priv))
+ return XctError;
+ c = *priv->ptr;
+ NEXT;
+ if (!IsESCF(c))
+ return XctError;
+ switch (data->item[1]) {
+ case 0x24:
+ if (data->item_length > 3) {
+ if (data->item[2] == 0x28) {
+ if (HandleMultiGL(data, c))
+ continue;
+ } else if (data->item[2] == 0x29) {
+ if (HandleMultiGR(data, c))
+ continue;
+ }
+ }
+ break;
+ case 0x25:
+ if ((data->item_length == 4) && (data->item[2] == 0x2f) &&
+ (c <= 0x3f)) {
+ if ((AmountLeft(priv) < 2) ||
+ (priv->ptr[0] < 0x80) || (priv->ptr[1] < 0x80))
+ return XctError;
+ len = *priv->ptr - 0x80;
+ NEXT;
+ len = (len << 7) + (*priv->ptr - 0x80);
+ NEXT;
+ if (AmountLeft(priv) < len)
+ return XctError;
+ data->item_length += len;
+ priv->ptr += len;
+ if (c <= 0x34) {
+ if (!HandleExtended(data, c) ||
+ ((data->horz_depth == 0) &&
+ (priv->flags & UsedDirection)))
+ return XctError;
+ priv->flags |= UsedGraphic;
+ return XctExtendedSegment;
+ }
+ }
+ break;
+ case 0x28:
+ if (HandleGL(data, c))
+ continue;
+ break;
+ case 0x29:
+ if (Handle94GR(data, c))
+ continue;
+ break;
+ case 0x2d:
+ if (Handle96GR(data, c))
+ continue;
+ break;
+ }
+ } else if (c == CSI) {
+ NEXT;
+ while (IsMore(priv) && IsI3(*priv->ptr)) {
+ NEXT;
+ }
+ while (IsMore(priv) && IsI2(*priv->ptr)) {
+ NEXT;
+ }
+ if (!IsMore(priv))
+ return XctError;
+ c = *priv->ptr;
+ NEXT;
+ if (!IsCSIF(c))
+ return XctError;
+ if (c == 0x5d) {
+ if ((data->item_length == 3) &&
+ ((data->item[1] == 0x31) || (data->item[1] == 0x32))) {
+ data->horz_depth++;
+ if (priv->dirsize < data->horz_depth) {
+ priv->dirsize += 10;
+ if (priv->dirstack)
+ priv->dirstack = (XctHDirection *)
+ realloc((char *)priv->dirstack,
+ priv->dirsize *
+ sizeof(XctHDirection));
+ else
+ priv->dirstack = (XctHDirection *)
+ malloc(priv->dirsize *
+ sizeof(XctHDirection));
+ }
+ priv->dirstack[data->horz_depth - 1] = data->horizontal;
+ if (data->item[1] == 0x31)
+ data->horizontal = XctLeftToRight;
+ else
+ data->horizontal = XctRightToLeft;
+ if ((priv->flags & UsedGraphic) &&
+ !(priv->flags & UsedDirection))
+ return XctError;
+ priv->flags |= UsedDirection;
+ if (data->flags & XctHideDirection)
+ continue;
+ return XctHorizontal;
+ } else if (data->item_length == 2) {
+ if (!data->horz_depth)
+ return XctError;
+ data->horz_depth--;
+ data->horizontal = priv->dirstack[data->horz_depth];
+ if (data->flags & XctHideDirection)
+ continue;
+ return XctHorizontal;
+ }
+ }
+ } else if (data->flags & XctSingleSetSegments) {
+ NEXT;
+ if IsC0(c) {
+ data->encoding = (char *)NULL;
+ data->char_size = 1;
+ if (IsLegalC0(data, c))
+ return XctC0Segment;
+ } else if (IsGL(c)) {
+ data->encoding = data->GL_encoding;
+ data->char_size = data->GL_char_size;
+ while (IsMore(priv) && IsGL(*priv->ptr)) {
+ NEXT;
+ }
+ if (((data->char_size > 1) &&
+ (data->item_length % data->char_size)) ||
+ ((data->horz_depth == 0) &&
+ (priv->flags & UsedDirection)))
+ return XctError;
+ priv->flags |= UsedGraphic;
+ return XctGLSegment;
+ } else if (IsC1(c)) {
+ data->encoding = (char *)NULL;
+ data->char_size = 1;
+ if (IsLegalC1(data, c))
+ return XctC1Segment;
+ } else {
+ data->encoding = data->GR_encoding;
+ data->char_size = data->GR_char_size;
+ while (IsMore(priv) && IsGR(*priv->ptr)) {
+ NEXT;
+ }
+ if (((data->char_size > 1) &&
+ (data->item_length % data->char_size)) ||
+ ((data->horz_depth == 0) &&
+ (priv->flags & UsedDirection)))
+ return XctError;
+ priv->flags |= UsedGraphic;
+ if (!(priv->flags & ToGL))
+ return XctGRSegment;
+ ShiftGRToGL(data, 0);
+ return XctGLSegment;
+ }
+ } else {
+ bits = 0;
+ while (1) {
+ if (IsC0(c) || IsC1(c)) {
+ if ((c == ESC) || (c == CSI))
+ break;
+ if (IsC0(c) ? !IsLegalC0(data, c) : !IsLegalC1(data, c))
+ break;
+ bits |= HasC;
+ NEXT;
+ } else {
+ len = data->item_length;
+ if (IsGL(c)) {
+ if ((data->flags & XctShiftMultiGRToGL) &&
+ (bits & HasGR))
+ break;
+ NEXT;
+ bits |= HasGL;
+ while (IsMore(priv) && IsGL(*priv->ptr)) {
+ NEXT;
+ }
+ if ((data->GL_char_size > 1) &&
+ ((data->item_length - len) % data->GL_char_size))
+ return XctError;
+ } else {
+ if ((data->flags & XctShiftMultiGRToGL) &&
+ (bits & HasGL))
+ break;
+ NEXT;
+ bits |= HasGR;
+ while (IsMore(priv) && IsGR(*priv->ptr)) {
+ NEXT;
+ }
+ if ((data->GR_char_size > 1) &&
+ ((data->item_length - len) % data->GR_char_size))
+ return XctError;
+ }
+ }
+ if (!IsMore(priv))
+ break;
+ c = *priv->ptr;
+ }
+ if (data->item_length) {
+ if (bits & (HasGL|HasGR)) {
+ priv->flags |= UsedGraphic;
+ if ((data->horz_depth == 0) &&
+ (priv->flags & UsedDirection))
+ return XctError;
+ if ((data->flags & XctShiftMultiGRToGL) && (bits & HasGR))
+ ShiftGRToGL(data, bits & HasC);
+ }
+ if ((bits == (HasGL|HasGR)) ||
+ (data->GLGR_encoding && !(bits & HasC))) {
+ data->encoding = data->GLGR_encoding;
+ if (data->GL_char_size == data->GR_char_size)
+ data->char_size = data->GL_char_size;
+ else
+ data->char_size = 0;
+ } else if (bits == HasGL) {
+ data->encoding = data->GL_encoding;
+ data->char_size = data->GL_char_size;
+ } else if (bits == HasGR) {
+ data->encoding = data->GR_encoding;
+ data->char_size = data->GR_char_size;
+ } else {
+ data->encoding = (char *)NULL;
+ data->char_size = 1;
+ if ((bits & HasGL) &&
+ (data->GL_char_size != data->char_size))
+ data->char_size = 0;
+ if ((bits & HasGR) &&
+ (data->GR_char_size != data->char_size))
+ data->char_size = 0;
+ }
+ return XctSegment;
+ }
+ NEXT;
+ }
+ if (data->version <= XctVersion)
+ return XctError;
+ if (data->flags & XctProvideExtensions)
+ return XctExtension;
+ if (!data->can_ignore_exts)
+ return XctError;
+ }
+ return XctEndOfText;
+}
+
+/* Free all data associated with an XctDataStructure. */
+void
+XctFree(data)
+ register XctData data;
+{
+ int i;
+ register XctPriv priv = data->priv;
+
+ if (priv->dirstack)
+ free((char *)priv->dirstack);
+ if (data->flags & XctFreeString)
+ free((char *)data->total_string);
+ for (i = 0; i < priv->enc_count; i++)
+ free(priv->encodings[i]);
+ if (priv->encodings)
+ free((char *)priv->encodings);
+ if (priv->itembuf)
+ free((char *)priv->itembuf);
+ free((char *)data);
+}
diff --git a/src/sharedlib.c b/src/sharedlib.c
new file mode 100644
index 0000000..0b835b5
--- /dev/null
+++ b/src/sharedlib.c
@@ -0,0 +1,71 @@
+/* $Xorg: sharedlib.c,v 1.4 2001/02/09 02:03:53 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.
+
+*/
+
+#if defined(SUNSHLIB) && !defined(SHAREDCODE)
+
+#include "Atoms.h"
+
+struct _AtomRec {
+ char *name;
+ struct _DisplayRec* head;
+};
+
+#if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
+#define DeclareAtom(atom) \
+extern struct _AtomRec __##atom; \
+AtomPtr _##atom = &__##atom;
+#else
+#define DeclareAtom(atom) \
+extern struct _AtomRec __/**/atom; \
+AtomPtr _/**/atom = &__/**/atom;
+#endif
+
+DeclareAtom(XA_ATOM_PAIR)
+DeclareAtom(XA_CHARACTER_POSITION)
+DeclareAtom(XA_CLASS)
+DeclareAtom(XA_CLIENT_WINDOW)
+DeclareAtom(XA_CLIPBOARD)
+DeclareAtom(XA_COMPOUND_TEXT)
+DeclareAtom(XA_DECNET_ADDRESS)
+DeclareAtom(XA_DELETE)
+DeclareAtom(XA_FILENAME)
+DeclareAtom(XA_HOSTNAME)
+DeclareAtom(XA_IP_ADDRESS)
+DeclareAtom(XA_LENGTH)
+DeclareAtom(XA_LIST_LENGTH)
+DeclareAtom(XA_NAME)
+DeclareAtom(XA_NET_ADDRESS)
+DeclareAtom(XA_NULL)
+DeclareAtom(XA_OWNER_OS)
+DeclareAtom(XA_SPAN)
+DeclareAtom(XA_TARGETS)
+DeclareAtom(XA_TEXT)
+DeclareAtom(XA_TIMESTAMP)
+DeclareAtom(XA_USER)
+
+#endif /* SUNSHLIB */