1/***********************************************************23Copyright 1987, 1998 The Open Group45Permission to use, copy, modify, distribute, and sell this software and its6documentation for any purpose is hereby granted without fee, provided that7the above copyright notice appear in all copies and that both that8copyright notice and this permission notice appear in supporting9documentation.1011The above copyright notice and this permission notice shall be included in12all copies or substantial portions of the Software.1314THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE17OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN18AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN19CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.2021Except as contained in this notice, the name of The Open Group shall not be22used in advertising or otherwise to promote the sale, use or other dealings23in this Software without prior written authorization from The Open Group.242526Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.2728All Rights Reserved2930Permission to use, copy, modify, and distribute this software and its31documentation for any purpose and without fee is hereby granted,32provided that the above copyright notice appear in all copies and that33both that copyright notice and this permission notice appear in34supporting documentation, and that the name of Digital not be35used in advertising or publicity pertaining to distribution of the36software without specific, written prior permission.3738DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING39ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL40DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR41ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,42WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,43ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS44SOFTWARE.4546******************************************************************/4748#ifndef _XUTIL_H_49#define _XUTIL_H_5051/* You must include <X11/Xlib.h> before including this file */52#include <X11/Xlib.h>53#include <X11/keysym.h>5455/*56* Bitmask returned by XParseGeometry(). Each bit tells if the corresponding57* value (x, y, width, height) was found in the parsed string.58*/59#define NoValue 0x000060#define XValue 0x000161#define YValue 0x000262#define WidthValue 0x000463#define HeightValue 0x000864#define AllValues 0x000F65#define XNegative 0x001066#define YNegative 0x00206768/*69* new version containing base_width, base_height, and win_gravity fields;70* used with WM_NORMAL_HINTS.71*/72typedef struct {73long flags; /* marks which fields in this structure are defined */74int x, y; /* obsolete for new window mgrs, but clients */75int width, height; /* should set so old wm's don't mess up */76int min_width, min_height;77int max_width, max_height;78int width_inc, height_inc;79struct {80int x; /* numerator */81int y; /* denominator */82} min_aspect, max_aspect;83int base_width, base_height; /* added by ICCCM version 1 */84int win_gravity; /* added by ICCCM version 1 */85} XSizeHints;8687/*88* The next block of definitions are for window manager properties that89* clients and applications use for communication.90*/9192/* flags argument in size hints */93#define USPosition (1L << 0) /* user specified x, y */94#define USSize (1L << 1) /* user specified width, height */9596#define PPosition (1L << 2) /* program specified position */97#define PSize (1L << 3) /* program specified size */98#define PMinSize (1L << 4) /* program specified minimum size */99#define PMaxSize (1L << 5) /* program specified maximum size */100#define PResizeInc (1L << 6) /* program specified resize increments */101#define PAspect (1L << 7) /* program specified min and max aspect ratios */102#define PBaseSize (1L << 8) /* program specified base for incrementing */103#define PWinGravity (1L << 9) /* program specified window gravity */104105/* obsolete */106#define PAllHints (PPosition|PSize|PMinSize|PMaxSize|PResizeInc|PAspect)107108109110typedef struct {111long flags; /* marks which fields in this structure are defined */112Bool input; /* does this application rely on the window manager to113get keyboard input? */114int initial_state; /* see below */115Pixmap icon_pixmap; /* pixmap to be used as icon */116Window icon_window; /* window to be used as icon */117int icon_x, icon_y; /* initial position of icon */118Pixmap icon_mask; /* icon mask bitmap */119XID window_group; /* id of related window group */120/* this structure may be extended in the future */121} XWMHints;122123/* definition for flags of XWMHints */124125#define InputHint (1L << 0)126#define StateHint (1L << 1)127#define IconPixmapHint (1L << 2)128#define IconWindowHint (1L << 3)129#define IconPositionHint (1L << 4)130#define IconMaskHint (1L << 5)131#define WindowGroupHint (1L << 6)132#define AllHints (InputHint|StateHint|IconPixmapHint|IconWindowHint| \133IconPositionHint|IconMaskHint|WindowGroupHint)134#define XUrgencyHint (1L << 8)135136/* definitions for initial window state */137#define WithdrawnState 0 /* for windows that are not mapped */138#define NormalState 1 /* most applications want to start this way */139#define IconicState 3 /* application wants to start as an icon */140141/*142* Obsolete states no longer defined by ICCCM143*/144#define DontCareState 0 /* don't know or care */145#define ZoomState 2 /* application wants to start zoomed */146#define InactiveState 4 /* application believes it is seldom used; */147/* some wm's may put it on inactive menu */148149150/*151* new structure for manipulating TEXT properties; used with WM_NAME,152* WM_ICON_NAME, WM_CLIENT_MACHINE, and WM_COMMAND.153*/154typedef struct {155unsigned char *value; /* same as Property routines */156Atom encoding; /* prop type */157int format; /* prop data format: 8, 16, or 32 */158unsigned long nitems; /* number of data items in value */159} XTextProperty;160161#define XNoMemory -1162#define XLocaleNotSupported -2163#define XConverterNotFound -3164165typedef enum {166XStringStyle, /* STRING */167XCompoundTextStyle, /* COMPOUND_TEXT */168XTextStyle, /* text in owner's encoding (current locale)*/169XStdICCTextStyle, /* STRING, else COMPOUND_TEXT */170/* The following is an XFree86 extension, introduced in November 2000 */171XUTF8StringStyle /* UTF8_STRING */172} XICCEncodingStyle;173174typedef struct {175int min_width, min_height;176int max_width, max_height;177int width_inc, height_inc;178} XIconSize;179180typedef struct {181char *res_name;182char *res_class;183} XClassHint;184185#ifdef XUTIL_DEFINE_FUNCTIONS186extern int XDestroyImage(187XImage *ximage);188extern unsigned long XGetPixel(189XImage *ximage,190int x, int y);191extern int XPutPixel(192XImage *ximage,193int x, int y,194unsigned long pixel);195extern XImage *XSubImage(196XImage *ximage,197int x, int y,198unsigned int width, unsigned int height);199extern int XAddPixel(200XImage *ximage,201long value);202#else203/*204* These macros are used to give some sugar to the image routines so that205* naive people are more comfortable with them.206*/207#define XDestroyImage(ximage) \208((*((ximage)->f.destroy_image))((ximage)))209#define XGetPixel(ximage, x, y) \210((*((ximage)->f.get_pixel))((ximage), (x), (y)))211#define XPutPixel(ximage, x, y, pixel) \212((*((ximage)->f.put_pixel))((ximage), (x), (y), (pixel)))213#define XSubImage(ximage, x, y, width, height) \214((*((ximage)->f.sub_image))((ximage), (x), (y), (width), (height)))215#define XAddPixel(ximage, value) \216((*((ximage)->f.add_pixel))((ximage), (value)))217#endif218219/*220* Compose sequence status structure, used in calling XLookupString.221*/222typedef struct _XComposeStatus {223XPointer compose_ptr; /* state table pointer */224int chars_matched; /* match state */225} XComposeStatus;226227/*228* Keysym macros, used on Keysyms to test for classes of symbols229*/230#define IsKeypadKey(keysym) \231(((KeySym)(keysym) >= XK_KP_Space) && ((KeySym)(keysym) <= XK_KP_Equal))232233#define IsPrivateKeypadKey(keysym) \234(((KeySym)(keysym) >= 0x11000000) && ((KeySym)(keysym) <= 0x1100FFFF))235236#define IsCursorKey(keysym) \237(((KeySym)(keysym) >= XK_Home) && ((KeySym)(keysym) < XK_Select))238239#define IsPFKey(keysym) \240(((KeySym)(keysym) >= XK_KP_F1) && ((KeySym)(keysym) <= XK_KP_F4))241242#define IsFunctionKey(keysym) \243(((KeySym)(keysym) >= XK_F1) && ((KeySym)(keysym) <= XK_F35))244245#define IsMiscFunctionKey(keysym) \246(((KeySym)(keysym) >= XK_Select) && ((KeySym)(keysym) <= XK_Break))247248#ifdef XK_XKB_KEYS249#define IsModifierKey(keysym) \250((((KeySym)(keysym) >= XK_Shift_L) && ((KeySym)(keysym) <= XK_Hyper_R)) \251|| (((KeySym)(keysym) >= XK_ISO_Lock) && \252((KeySym)(keysym) <= XK_ISO_Last_Group_Lock)) \253|| ((KeySym)(keysym) == XK_Mode_switch) \254|| ((KeySym)(keysym) == XK_Num_Lock))255#else256#define IsModifierKey(keysym) \257((((KeySym)(keysym) >= XK_Shift_L) && ((KeySym)(keysym) <= XK_Hyper_R)) \258|| ((KeySym)(keysym) == XK_Mode_switch) \259|| ((KeySym)(keysym) == XK_Num_Lock))260#endif261/*262* opaque reference to Region data type263*/264typedef struct _XRegion *Region;265266/* Return values from XRectInRegion() */267268#define RectangleOut 0269#define RectangleIn 1270#define RectanglePart 2271272273/*274* Information used by the visual utility routines to find desired visual275* type from the many visuals a display may support.276*/277278typedef struct {279Visual *visual;280VisualID visualid;281int screen;282int depth;283#if defined(__cplusplus) || defined(c_plusplus)284int c_class; /* C++ */285#else286int class;287#endif288unsigned long red_mask;289unsigned long green_mask;290unsigned long blue_mask;291int colormap_size;292int bits_per_rgb;293} XVisualInfo;294295#define VisualNoMask 0x0296#define VisualIDMask 0x1297#define VisualScreenMask 0x2298#define VisualDepthMask 0x4299#define VisualClassMask 0x8300#define VisualRedMaskMask 0x10301#define VisualGreenMaskMask 0x20302#define VisualBlueMaskMask 0x40303#define VisualColormapSizeMask 0x80304#define VisualBitsPerRGBMask 0x100305#define VisualAllMask 0x1FF306307/*308* This defines a window manager property that clients may use to309* share standard color maps of type RGB_COLOR_MAP:310*/311typedef struct {312Colormap colormap;313unsigned long red_max;314unsigned long red_mult;315unsigned long green_max;316unsigned long green_mult;317unsigned long blue_max;318unsigned long blue_mult;319unsigned long base_pixel;320VisualID visualid; /* added by ICCCM version 1 */321XID killid; /* added by ICCCM version 1 */322} XStandardColormap;323324#define ReleaseByFreeingColormap ((XID) 1L) /* for killid field above */325326327/*328* return codes for XReadBitmapFile and XWriteBitmapFile329*/330#define BitmapSuccess 0331#define BitmapOpenFailed 1332#define BitmapFileInvalid 2333#define BitmapNoMemory 3334335/****************************************************************336*337* Context Management338*339****************************************************************/340341342/* Associative lookup table return codes */343344#define XCSUCCESS 0 /* No error. */345#define XCNOMEM 1 /* Out of memory */346#define XCNOENT 2 /* No entry in table */347348typedef int XContext;349350#define XUniqueContext() ((XContext) XrmUniqueQuark())351#define XStringToContext(string) ((XContext) XrmStringToQuark(string))352353_XFUNCPROTOBEGIN354355/* The following declarations are alphabetized. */356357extern XClassHint *XAllocClassHint (358void359);360361extern XIconSize *XAllocIconSize (362void363);364365extern XSizeHints *XAllocSizeHints (366void367);368369extern XStandardColormap *XAllocStandardColormap (370void371);372373extern XWMHints *XAllocWMHints (374void375);376377extern int XClipBox(378Region /* r */,379XRectangle* /* rect_return */380);381382extern Region XCreateRegion(383void384);385386extern const char *XDefaultString (void);387388extern int XDeleteContext(389Display* /* display */,390XID /* rid */,391XContext /* context */392);393394extern int XDestroyRegion(395Region /* r */396);397398extern int XEmptyRegion(399Region /* r */400);401402extern int XEqualRegion(403Region /* r1 */,404Region /* r2 */405);406407extern int XFindContext(408Display* /* display */,409XID /* rid */,410XContext /* context */,411XPointer* /* data_return */412);413414extern Status XGetClassHint(415Display* /* display */,416Window /* w */,417XClassHint* /* class_hints_return */418);419420extern Status XGetIconSizes(421Display* /* display */,422Window /* w */,423XIconSize** /* size_list_return */,424int* /* count_return */425);426427extern Status XGetNormalHints(428Display* /* display */,429Window /* w */,430XSizeHints* /* hints_return */431);432433extern Status XGetRGBColormaps(434Display* /* display */,435Window /* w */,436XStandardColormap** /* stdcmap_return */,437int* /* count_return */,438Atom /* property */439);440441extern Status XGetSizeHints(442Display* /* display */,443Window /* w */,444XSizeHints* /* hints_return */,445Atom /* property */446);447448extern Status XGetStandardColormap(449Display* /* display */,450Window /* w */,451XStandardColormap* /* colormap_return */,452Atom /* property */453);454455extern Status XGetTextProperty(456Display* /* display */,457Window /* window */,458XTextProperty* /* text_prop_return */,459Atom /* property */460);461462extern XVisualInfo *XGetVisualInfo(463Display* /* display */,464long /* vinfo_mask */,465XVisualInfo* /* vinfo_template */,466int* /* nitems_return */467);468469extern Status XGetWMClientMachine(470Display* /* display */,471Window /* w */,472XTextProperty* /* text_prop_return */473);474475extern XWMHints *XGetWMHints(476Display* /* display */,477Window /* w */478);479480extern Status XGetWMIconName(481Display* /* display */,482Window /* w */,483XTextProperty* /* text_prop_return */484);485486extern Status XGetWMName(487Display* /* display */,488Window /* w */,489XTextProperty* /* text_prop_return */490);491492extern Status XGetWMNormalHints(493Display* /* display */,494Window /* w */,495XSizeHints* /* hints_return */,496long* /* supplied_return */497);498499extern Status XGetWMSizeHints(500Display* /* display */,501Window /* w */,502XSizeHints* /* hints_return */,503long* /* supplied_return */,504Atom /* property */505);506507extern Status XGetZoomHints(508Display* /* display */,509Window /* w */,510XSizeHints* /* zhints_return */511);512513extern int XIntersectRegion(514Region /* sra */,515Region /* srb */,516Region /* dr_return */517);518519extern void XConvertCase(520KeySym /* sym */,521KeySym* /* lower */,522KeySym* /* upper */523);524525extern int XLookupString(526XKeyEvent* /* event_struct */,527char* /* buffer_return */,528int /* bytes_buffer */,529KeySym* /* keysym_return */,530XComposeStatus* /* status_in_out */531);532533extern Status XMatchVisualInfo(534Display* /* display */,535int /* screen */,536int /* depth */,537int /* class */,538XVisualInfo* /* vinfo_return */539);540541extern int XOffsetRegion(542Region /* r */,543int /* dx */,544int /* dy */545);546547extern Bool XPointInRegion(548Region /* r */,549int /* x */,550int /* y */551);552553extern Region XPolygonRegion(554XPoint* /* points */,555int /* n */,556int /* fill_rule */557);558559extern int XRectInRegion(560Region /* r */,561int /* x */,562int /* y */,563unsigned int /* width */,564unsigned int /* height */565);566567extern int XSaveContext(568Display* /* display */,569XID /* rid */,570XContext /* context */,571_Xconst char* /* data */572);573574extern int XSetClassHint(575Display* /* display */,576Window /* w */,577XClassHint* /* class_hints */578);579580extern int XSetIconSizes(581Display* /* display */,582Window /* w */,583XIconSize* /* size_list */,584int /* count */585);586587extern int XSetNormalHints(588Display* /* display */,589Window /* w */,590XSizeHints* /* hints */591);592593extern void XSetRGBColormaps(594Display* /* display */,595Window /* w */,596XStandardColormap* /* stdcmaps */,597int /* count */,598Atom /* property */599);600601extern int XSetSizeHints(602Display* /* display */,603Window /* w */,604XSizeHints* /* hints */,605Atom /* property */606);607608extern int XSetStandardProperties(609Display* /* display */,610Window /* w */,611_Xconst char* /* window_name */,612_Xconst char* /* icon_name */,613Pixmap /* icon_pixmap */,614char** /* argv */,615int /* argc */,616XSizeHints* /* hints */617);618619extern void XSetTextProperty(620Display* /* display */,621Window /* w */,622XTextProperty* /* text_prop */,623Atom /* property */624);625626extern void XSetWMClientMachine(627Display* /* display */,628Window /* w */,629XTextProperty* /* text_prop */630);631632extern int XSetWMHints(633Display* /* display */,634Window /* w */,635XWMHints* /* wm_hints */636);637638extern void XSetWMIconName(639Display* /* display */,640Window /* w */,641XTextProperty* /* text_prop */642);643644extern void XSetWMName(645Display* /* display */,646Window /* w */,647XTextProperty* /* text_prop */648);649650extern void XSetWMNormalHints(651Display* /* display */,652Window /* w */,653XSizeHints* /* hints */654);655656extern void XSetWMProperties(657Display* /* display */,658Window /* w */,659XTextProperty* /* window_name */,660XTextProperty* /* icon_name */,661char** /* argv */,662int /* argc */,663XSizeHints* /* normal_hints */,664XWMHints* /* wm_hints */,665XClassHint* /* class_hints */666);667668extern void XmbSetWMProperties(669Display* /* display */,670Window /* w */,671_Xconst char* /* window_name */,672_Xconst char* /* icon_name */,673char** /* argv */,674int /* argc */,675XSizeHints* /* normal_hints */,676XWMHints* /* wm_hints */,677XClassHint* /* class_hints */678);679680extern void Xutf8SetWMProperties(681Display* /* display */,682Window /* w */,683_Xconst char* /* window_name */,684_Xconst char* /* icon_name */,685char** /* argv */,686int /* argc */,687XSizeHints* /* normal_hints */,688XWMHints* /* wm_hints */,689XClassHint* /* class_hints */690);691692extern void XSetWMSizeHints(693Display* /* display */,694Window /* w */,695XSizeHints* /* hints */,696Atom /* property */697);698699extern int XSetRegion(700Display* /* display */,701GC /* gc */,702Region /* r */703);704705extern void XSetStandardColormap(706Display* /* display */,707Window /* w */,708XStandardColormap* /* colormap */,709Atom /* property */710);711712extern int XSetZoomHints(713Display* /* display */,714Window /* w */,715XSizeHints* /* zhints */716);717718extern int XShrinkRegion(719Region /* r */,720int /* dx */,721int /* dy */722);723724extern Status XStringListToTextProperty(725char** /* list */,726int /* count */,727XTextProperty* /* text_prop_return */728);729730extern int XSubtractRegion(731Region /* sra */,732Region /* srb */,733Region /* dr_return */734);735736extern int XmbTextListToTextProperty(737Display* display,738char** list,739int count,740XICCEncodingStyle style,741XTextProperty* text_prop_return742);743744extern int XwcTextListToTextProperty(745Display* display,746wchar_t** list,747int count,748XICCEncodingStyle style,749XTextProperty* text_prop_return750);751752extern int Xutf8TextListToTextProperty(753Display* display,754char** list,755int count,756XICCEncodingStyle style,757XTextProperty* text_prop_return758);759760extern void XwcFreeStringList(761wchar_t** list762);763764extern Status XTextPropertyToStringList(765XTextProperty* /* text_prop */,766char*** /* list_return */,767int* /* count_return */768);769770extern int XmbTextPropertyToTextList(771Display* display,772const XTextProperty* text_prop,773char*** list_return,774int* count_return775);776777extern int XwcTextPropertyToTextList(778Display* display,779const XTextProperty* text_prop,780wchar_t*** list_return,781int* count_return782);783784extern int Xutf8TextPropertyToTextList(785Display* display,786const XTextProperty* text_prop,787char*** list_return,788int* count_return789);790791extern int XUnionRectWithRegion(792XRectangle* /* rectangle */,793Region /* src_region */,794Region /* dest_region_return */795);796797extern int XUnionRegion(798Region /* sra */,799Region /* srb */,800Region /* dr_return */801);802803extern int XWMGeometry(804Display* /* display */,805int /* screen_number */,806_Xconst char* /* user_geometry */,807_Xconst char* /* default_geometry */,808unsigned int /* border_width */,809XSizeHints* /* hints */,810int* /* x_return */,811int* /* y_return */,812int* /* width_return */,813int* /* height_return */,814int* /* gravity_return */815);816817extern int XXorRegion(818Region /* sra */,819Region /* srb */,820Region /* dr_return */821);822823_XFUNCPROTOEND824825#endif /* _XUTIL_H_ */826827828