Path: blob/master/thirdparty/linuxbsd_headers/X11/Xutil.h
9898 views
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 _X11_XUTIL_H_49#define _X11_XUTIL_H_5051/* You must include <X11/Xlib.h> before including this file */52#include <X11/Xlib.h>53#include <X11/keysym.h>5455/* The Xlib structs are full of implicit padding to properly align members.56We can't clean that up without breaking ABI, so tell clang not to bother57complaining about it. */58#ifdef __clang__59#pragma clang diagnostic push60#pragma clang diagnostic ignored "-Wpadded"61#endif6263/*64* Bitmask returned by XParseGeometry(). Each bit tells if the corresponding65* value (x, y, width, height) was found in the parsed string.66*/67#define NoValue 0x000068#define XValue 0x000169#define YValue 0x000270#define WidthValue 0x000471#define HeightValue 0x000872#define AllValues 0x000F73#define XNegative 0x001074#define YNegative 0x00207576/*77* new version containing base_width, base_height, and win_gravity fields;78* used with WM_NORMAL_HINTS.79*/80typedef struct {81long flags; /* marks which fields in this structure are defined */82int x, y; /* obsolete for new window mgrs, but clients */83int width, height; /* should set so old wm's don't mess up */84int min_width, min_height;85int max_width, max_height;86int width_inc, height_inc;87struct {88int x; /* numerator */89int y; /* denominator */90} min_aspect, max_aspect;91int base_width, base_height; /* added by ICCCM version 1 */92int win_gravity; /* added by ICCCM version 1 */93} XSizeHints;9495/*96* The next block of definitions are for window manager properties that97* clients and applications use for communication.98*/99100/* flags argument in size hints */101#define USPosition (1L << 0) /* user specified x, y */102#define USSize (1L << 1) /* user specified width, height */103104#define PPosition (1L << 2) /* program specified position */105#define PSize (1L << 3) /* program specified size */106#define PMinSize (1L << 4) /* program specified minimum size */107#define PMaxSize (1L << 5) /* program specified maximum size */108#define PResizeInc (1L << 6) /* program specified resize increments */109#define PAspect (1L << 7) /* program specified min and max aspect ratios */110#define PBaseSize (1L << 8) /* program specified base for incrementing */111#define PWinGravity (1L << 9) /* program specified window gravity */112113/* obsolete */114#define PAllHints (PPosition|PSize|PMinSize|PMaxSize|PResizeInc|PAspect)115116117118typedef struct {119long flags; /* marks which fields in this structure are defined */120Bool input; /* does this application rely on the window manager to121get keyboard input? */122int initial_state; /* see below */123Pixmap icon_pixmap; /* pixmap to be used as icon */124Window icon_window; /* window to be used as icon */125int icon_x, icon_y; /* initial position of icon */126Pixmap icon_mask; /* icon mask bitmap */127XID window_group; /* id of related window group */128/* this structure may be extended in the future */129} XWMHints;130131/* definition for flags of XWMHints */132133#define InputHint (1L << 0)134#define StateHint (1L << 1)135#define IconPixmapHint (1L << 2)136#define IconWindowHint (1L << 3)137#define IconPositionHint (1L << 4)138#define IconMaskHint (1L << 5)139#define WindowGroupHint (1L << 6)140#define AllHints (InputHint|StateHint|IconPixmapHint|IconWindowHint| \141IconPositionHint|IconMaskHint|WindowGroupHint)142#define XUrgencyHint (1L << 8)143144/* definitions for initial window state */145#define WithdrawnState 0 /* for windows that are not mapped */146#define NormalState 1 /* most applications want to start this way */147#define IconicState 3 /* application wants to start as an icon */148149/*150* Obsolete states no longer defined by ICCCM151*/152#define DontCareState 0 /* don't know or care */153#define ZoomState 2 /* application wants to start zoomed */154#define InactiveState 4 /* application believes it is seldom used; */155/* some wm's may put it on inactive menu */156157158/*159* new structure for manipulating TEXT properties; used with WM_NAME,160* WM_ICON_NAME, WM_CLIENT_MACHINE, and WM_COMMAND.161*/162typedef struct {163unsigned char *value; /* same as Property routines */164Atom encoding; /* prop type */165int format; /* prop data format: 8, 16, or 32 */166unsigned long nitems; /* number of data items in value */167} XTextProperty;168169#define XNoMemory -1170#define XLocaleNotSupported -2171#define XConverterNotFound -3172173typedef enum {174XStringStyle, /* STRING */175XCompoundTextStyle, /* COMPOUND_TEXT */176XTextStyle, /* text in owner's encoding (current locale)*/177XStdICCTextStyle, /* STRING, else COMPOUND_TEXT */178/* The following is an XFree86 extension, introduced in November 2000 */179XUTF8StringStyle /* UTF8_STRING */180} XICCEncodingStyle;181182typedef struct {183int min_width, min_height;184int max_width, max_height;185int width_inc, height_inc;186} XIconSize;187188typedef struct {189char *res_name;190char *res_class;191} XClassHint;192193#ifdef XUTIL_DEFINE_FUNCTIONS194extern int XDestroyImage(195XImage *ximage);196extern unsigned long XGetPixel(197XImage *ximage,198int x, int y);199extern int XPutPixel(200XImage *ximage,201int x, int y,202unsigned long pixel);203extern XImage *XSubImage(204XImage *ximage,205int x, int y,206unsigned int width, unsigned int height);207extern int XAddPixel(208XImage *ximage,209long value);210#else211/*212* These macros are used to give some sugar to the image routines so that213* naive people are more comfortable with them.214*/215#define XDestroyImage(ximage) \216((*((ximage)->f.destroy_image))((ximage)))217#define XGetPixel(ximage, x, y) \218((*((ximage)->f.get_pixel))((ximage), (x), (y)))219#define XPutPixel(ximage, x, y, pixel) \220((*((ximage)->f.put_pixel))((ximage), (x), (y), (pixel)))221#define XSubImage(ximage, x, y, width, height) \222((*((ximage)->f.sub_image))((ximage), (x), (y), (width), (height)))223#define XAddPixel(ximage, value) \224((*((ximage)->f.add_pixel))((ximage), (value)))225#endif226227/*228* Compose sequence status structure, used in calling XLookupString.229*/230typedef struct _XComposeStatus {231XPointer compose_ptr; /* state table pointer */232int chars_matched; /* match state */233} XComposeStatus;234235/*236* Keysym macros, used on Keysyms to test for classes of symbols237*/238#define IsKeypadKey(keysym) \239(((KeySym)(keysym) >= XK_KP_Space) && ((KeySym)(keysym) <= XK_KP_Equal))240241#define IsPrivateKeypadKey(keysym) \242(((KeySym)(keysym) >= 0x11000000) && ((KeySym)(keysym) <= 0x1100FFFF))243244#define IsCursorKey(keysym) \245(((KeySym)(keysym) >= XK_Home) && ((KeySym)(keysym) < XK_Select))246247#define IsPFKey(keysym) \248(((KeySym)(keysym) >= XK_KP_F1) && ((KeySym)(keysym) <= XK_KP_F4))249250#define IsFunctionKey(keysym) \251(((KeySym)(keysym) >= XK_F1) && ((KeySym)(keysym) <= XK_F35))252253#define IsMiscFunctionKey(keysym) \254(((KeySym)(keysym) >= XK_Select) && ((KeySym)(keysym) <= XK_Break))255256#ifdef XK_XKB_KEYS257#define IsModifierKey(keysym) \258((((KeySym)(keysym) >= XK_Shift_L) && ((KeySym)(keysym) <= XK_Hyper_R)) \259|| (((KeySym)(keysym) >= XK_ISO_Lock) && \260((KeySym)(keysym) <= XK_ISO_Level5_Lock)) \261|| ((KeySym)(keysym) == XK_Mode_switch) \262|| ((KeySym)(keysym) == XK_Num_Lock))263#else264#define IsModifierKey(keysym) \265((((KeySym)(keysym) >= XK_Shift_L) && ((KeySym)(keysym) <= XK_Hyper_R)) \266|| ((KeySym)(keysym) == XK_Mode_switch) \267|| ((KeySym)(keysym) == XK_Num_Lock))268#endif269/*270* opaque reference to Region data type271*/272typedef struct _XRegion *Region;273274/* Return values from XRectInRegion() */275276#define RectangleOut 0277#define RectangleIn 1278#define RectanglePart 2279280281/*282* Information used by the visual utility routines to find desired visual283* type from the many visuals a display may support.284*/285286typedef struct {287Visual *visual;288VisualID visualid;289int screen;290int depth;291#if defined(__cplusplus) || defined(c_plusplus)292int c_class; /* C++ */293#else294int class;295#endif296unsigned long red_mask;297unsigned long green_mask;298unsigned long blue_mask;299int colormap_size;300int bits_per_rgb;301} XVisualInfo;302303#define VisualNoMask 0x0304#define VisualIDMask 0x1305#define VisualScreenMask 0x2306#define VisualDepthMask 0x4307#define VisualClassMask 0x8308#define VisualRedMaskMask 0x10309#define VisualGreenMaskMask 0x20310#define VisualBlueMaskMask 0x40311#define VisualColormapSizeMask 0x80312#define VisualBitsPerRGBMask 0x100313#define VisualAllMask 0x1FF314315/*316* This defines a window manager property that clients may use to317* share standard color maps of type RGB_COLOR_MAP:318*/319typedef struct {320Colormap colormap;321unsigned long red_max;322unsigned long red_mult;323unsigned long green_max;324unsigned long green_mult;325unsigned long blue_max;326unsigned long blue_mult;327unsigned long base_pixel;328VisualID visualid; /* added by ICCCM version 1 */329XID killid; /* added by ICCCM version 1 */330} XStandardColormap;331332#define ReleaseByFreeingColormap ((XID) 1L) /* for killid field above */333334335/*336* return codes for XReadBitmapFile and XWriteBitmapFile337*/338#define BitmapSuccess 0339#define BitmapOpenFailed 1340#define BitmapFileInvalid 2341#define BitmapNoMemory 3342343/****************************************************************344*345* Context Management346*347****************************************************************/348349350/* Associative lookup table return codes */351352#define XCSUCCESS 0 /* No error. */353#define XCNOMEM 1 /* Out of memory */354#define XCNOENT 2 /* No entry in table */355356typedef int XContext;357358#define XUniqueContext() ((XContext) XrmUniqueQuark())359#define XStringToContext(string) ((XContext) XrmStringToQuark(string))360361_XFUNCPROTOBEGIN362363/* The following declarations are alphabetized. */364365extern XClassHint *XAllocClassHint (366void367);368369extern XIconSize *XAllocIconSize (370void371);372373extern XSizeHints *XAllocSizeHints (374void375);376377extern XStandardColormap *XAllocStandardColormap (378void379);380381extern XWMHints *XAllocWMHints (382void383);384385extern int XClipBox(386Region /* r */,387XRectangle* /* rect_return */388);389390extern Region XCreateRegion(391void392);393394extern const char *XDefaultString (void);395396extern int XDeleteContext(397Display* /* display */,398XID /* rid */,399XContext /* context */400);401402extern int XDestroyRegion(403Region /* r */404);405406extern int XEmptyRegion(407Region /* r */408);409410extern int XEqualRegion(411Region /* r1 */,412Region /* r2 */413);414415extern int XFindContext(416Display* /* display */,417XID /* rid */,418XContext /* context */,419XPointer* /* data_return */420);421422extern Status XGetClassHint(423Display* /* display */,424Window /* w */,425XClassHint* /* class_hints_return */426);427428extern Status XGetIconSizes(429Display* /* display */,430Window /* w */,431XIconSize** /* size_list_return */,432int* /* count_return */433);434435extern Status XGetNormalHints(436Display* /* display */,437Window /* w */,438XSizeHints* /* hints_return */439);440441extern Status XGetRGBColormaps(442Display* /* display */,443Window /* w */,444XStandardColormap** /* stdcmap_return */,445int* /* count_return */,446Atom /* property */447);448449extern Status XGetSizeHints(450Display* /* display */,451Window /* w */,452XSizeHints* /* hints_return */,453Atom /* property */454);455456extern Status XGetStandardColormap(457Display* /* display */,458Window /* w */,459XStandardColormap* /* colormap_return */,460Atom /* property */461);462463extern Status XGetTextProperty(464Display* /* display */,465Window /* window */,466XTextProperty* /* text_prop_return */,467Atom /* property */468);469470extern XVisualInfo *XGetVisualInfo(471Display* /* display */,472long /* vinfo_mask */,473XVisualInfo* /* vinfo_template */,474int* /* nitems_return */475);476477extern Status XGetWMClientMachine(478Display* /* display */,479Window /* w */,480XTextProperty* /* text_prop_return */481);482483extern XWMHints *XGetWMHints(484Display* /* display */,485Window /* w */486);487488extern Status XGetWMIconName(489Display* /* display */,490Window /* w */,491XTextProperty* /* text_prop_return */492);493494extern Status XGetWMName(495Display* /* display */,496Window /* w */,497XTextProperty* /* text_prop_return */498);499500extern Status XGetWMNormalHints(501Display* /* display */,502Window /* w */,503XSizeHints* /* hints_return */,504long* /* supplied_return */505);506507extern Status XGetWMSizeHints(508Display* /* display */,509Window /* w */,510XSizeHints* /* hints_return */,511long* /* supplied_return */,512Atom /* property */513);514515extern Status XGetZoomHints(516Display* /* display */,517Window /* w */,518XSizeHints* /* zhints_return */519);520521extern int XIntersectRegion(522Region /* sra */,523Region /* srb */,524Region /* dr_return */525);526527extern void XConvertCase(528KeySym /* sym */,529KeySym* /* lower */,530KeySym* /* upper */531);532533extern int XLookupString(534XKeyEvent* /* event_struct */,535char* /* buffer_return */,536int /* bytes_buffer */,537KeySym* /* keysym_return */,538XComposeStatus* /* status_in_out */539);540541extern Status XMatchVisualInfo(542Display* /* display */,543int /* screen */,544int /* depth */,545int /* class */,546XVisualInfo* /* vinfo_return */547);548549extern int XOffsetRegion(550Region /* r */,551int /* dx */,552int /* dy */553);554555extern Bool XPointInRegion(556Region /* r */,557int /* x */,558int /* y */559);560561extern Region XPolygonRegion(562XPoint* /* points */,563int /* n */,564int /* fill_rule */565);566567extern int XRectInRegion(568Region /* r */,569int /* x */,570int /* y */,571unsigned int /* width */,572unsigned int /* height */573);574575extern int XSaveContext(576Display* /* display */,577XID /* rid */,578XContext /* context */,579_Xconst char* /* data */580);581582extern int XSetClassHint(583Display* /* display */,584Window /* w */,585XClassHint* /* class_hints */586);587588extern int XSetIconSizes(589Display* /* display */,590Window /* w */,591XIconSize* /* size_list */,592int /* count */593);594595extern int XSetNormalHints(596Display* /* display */,597Window /* w */,598XSizeHints* /* hints */599);600601extern void XSetRGBColormaps(602Display* /* display */,603Window /* w */,604XStandardColormap* /* stdcmaps */,605int /* count */,606Atom /* property */607);608609extern int XSetSizeHints(610Display* /* display */,611Window /* w */,612XSizeHints* /* hints */,613Atom /* property */614);615616extern int XSetStandardProperties(617Display* /* display */,618Window /* w */,619_Xconst char* /* window_name */,620_Xconst char* /* icon_name */,621Pixmap /* icon_pixmap */,622char** /* argv */,623int /* argc */,624XSizeHints* /* hints */625);626627extern void XSetTextProperty(628Display* /* display */,629Window /* w */,630XTextProperty* /* text_prop */,631Atom /* property */632);633634extern void XSetWMClientMachine(635Display* /* display */,636Window /* w */,637XTextProperty* /* text_prop */638);639640extern int XSetWMHints(641Display* /* display */,642Window /* w */,643XWMHints* /* wm_hints */644);645646extern void XSetWMIconName(647Display* /* display */,648Window /* w */,649XTextProperty* /* text_prop */650);651652extern void XSetWMName(653Display* /* display */,654Window /* w */,655XTextProperty* /* text_prop */656);657658extern void XSetWMNormalHints(659Display* /* display */,660Window /* w */,661XSizeHints* /* hints */662);663664extern void XSetWMProperties(665Display* /* display */,666Window /* w */,667XTextProperty* /* window_name */,668XTextProperty* /* icon_name */,669char** /* argv */,670int /* argc */,671XSizeHints* /* normal_hints */,672XWMHints* /* wm_hints */,673XClassHint* /* class_hints */674);675676extern void XmbSetWMProperties(677Display* /* display */,678Window /* w */,679_Xconst char* /* window_name */,680_Xconst char* /* icon_name */,681char** /* argv */,682int /* argc */,683XSizeHints* /* normal_hints */,684XWMHints* /* wm_hints */,685XClassHint* /* class_hints */686);687688extern void Xutf8SetWMProperties(689Display* /* display */,690Window /* w */,691_Xconst char* /* window_name */,692_Xconst char* /* icon_name */,693char** /* argv */,694int /* argc */,695XSizeHints* /* normal_hints */,696XWMHints* /* wm_hints */,697XClassHint* /* class_hints */698);699700extern void XSetWMSizeHints(701Display* /* display */,702Window /* w */,703XSizeHints* /* hints */,704Atom /* property */705);706707extern int XSetRegion(708Display* /* display */,709GC /* gc */,710Region /* r */711);712713extern void XSetStandardColormap(714Display* /* display */,715Window /* w */,716XStandardColormap* /* colormap */,717Atom /* property */718);719720extern int XSetZoomHints(721Display* /* display */,722Window /* w */,723XSizeHints* /* zhints */724);725726extern int XShrinkRegion(727Region /* r */,728int /* dx */,729int /* dy */730);731732extern Status XStringListToTextProperty(733char** /* list */,734int /* count */,735XTextProperty* /* text_prop_return */736);737738extern int XSubtractRegion(739Region /* sra */,740Region /* srb */,741Region /* dr_return */742);743744extern int XmbTextListToTextProperty(745Display* display,746char** list,747int count,748XICCEncodingStyle style,749XTextProperty* text_prop_return750);751752extern int XwcTextListToTextProperty(753Display* display,754wchar_t** list,755int count,756XICCEncodingStyle style,757XTextProperty* text_prop_return758);759760extern int Xutf8TextListToTextProperty(761Display* display,762char** list,763int count,764XICCEncodingStyle style,765XTextProperty* text_prop_return766);767768extern void XwcFreeStringList(769wchar_t** list770);771772extern Status XTextPropertyToStringList(773XTextProperty* /* text_prop */,774char*** /* list_return */,775int* /* count_return */776);777778extern int XmbTextPropertyToTextList(779Display* display,780const XTextProperty* text_prop,781char*** list_return,782int* count_return783);784785extern int XwcTextPropertyToTextList(786Display* display,787const XTextProperty* text_prop,788wchar_t*** list_return,789int* count_return790);791792extern int Xutf8TextPropertyToTextList(793Display* display,794const XTextProperty* text_prop,795char*** list_return,796int* count_return797);798799extern int XUnionRectWithRegion(800XRectangle* /* rectangle */,801Region /* src_region */,802Region /* dest_region_return */803);804805extern int XUnionRegion(806Region /* sra */,807Region /* srb */,808Region /* dr_return */809);810811extern int XWMGeometry(812Display* /* display */,813int /* screen_number */,814_Xconst char* /* user_geometry */,815_Xconst char* /* default_geometry */,816unsigned int /* border_width */,817XSizeHints* /* hints */,818int* /* x_return */,819int* /* y_return */,820int* /* width_return */,821int* /* height_return */,822int* /* gravity_return */823);824825extern int XXorRegion(826Region /* sra */,827Region /* srb */,828Region /* dr_return */829);830831#ifdef __clang__832#pragma clang diagnostic pop833#endif834835_XFUNCPROTOEND836837#endif /* _X11_XUTIL_H_ */838839840