codekingpro/portable-devtools
114k
1 2/***********************************************************3 4Copyright 1987, 1998 The Open Group5 6Permission to use, copy, modify, distribute, and sell this software and its7documentation for any purpose is hereby granted without fee, provided that8the above copyright notice appear in all copies and that both that9copyright notice and this permission notice appear in supporting10documentation.11 12The above copyright notice and this permission notice shall be included in13all copies or substantial portions of the Software.14 15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE18OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN19AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN20CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.21 22Except as contained in this notice, the name of The Open Group shall not be23used in advertising or otherwise to promote the sale, use or other dealings24in this Software without prior written authorization from The Open Group.25 26 27Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.28 29 All Rights Reserved30 31Permission to use, copy, modify, and distribute this software and its32documentation for any purpose and without fee is hereby granted,33provided that the above copyright notice appear in all copies and that34both that copyright notice and this permission notice appear in35supporting documentation, and that the name of Digital not be36used in advertising or publicity pertaining to distribution of the37software without specific, written prior permission.38 39DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING40ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL41DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR42ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,43WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,44ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS45SOFTWARE.46 47******************************************************************/48 49#ifndef _X11_XUTIL_H_50#define _X11_XUTIL_H_51 52/* You must include <X11/Xlib.h> before including this file */53#include <X11/Xlib.h>54#include <X11/keysym.h>55 56/* The Xlib structs are full of implicit padding to properly align members.57 We can't clean that up without breaking ABI, so tell clang not to bother58 complaining about it. */59#ifdef __clang__60#pragma clang diagnostic push61#pragma clang diagnostic ignored "-Wpadded"62#endif63 64#if defined(MAC_OSX_TK)65# define Region XRegion66#endif67 68/*69 * Bitmask returned by XParseGeometry(). Each bit tells if the corresponding70 * value (x, y, width, height) was found in the parsed string.71 */72#define NoValue 0x000073#define XValue 0x000174#define YValue 0x000275#define WidthValue 0x000476#define HeightValue 0x000877#define AllValues 0x000F78#define XNegative 0x001079#define YNegative 0x002080 81/*82 * new version containing base_width, base_height, and win_gravity fields;83 * used with WM_NORMAL_HINTS.84 */85typedef struct {86 long flags; /* marks which fields in this structure are defined */87 int x, y; /* obsolete for new window mgrs, but clients */88 int width, height; /* should set so old wm's don't mess up */89 int min_width, min_height;90 int max_width, max_height;91 int width_inc, height_inc;92 struct {93 int x; /* numerator */94 int y; /* denominator */95 } min_aspect, max_aspect;96 int base_width, base_height; /* added by ICCCM version 1 */97 int win_gravity; /* added by ICCCM version 1 */98} XSizeHints;99 100/*101 * The next block of definitions are for window manager properties that102 * clients and applications use for communication.103 */104 105/* flags argument in size hints */106#define USPosition (1L << 0) /* user specified x, y */107#define USSize (1L << 1) /* user specified width, height */108 109#define PPosition (1L << 2) /* program specified position */110#define PSize (1L << 3) /* program specified size */111#define PMinSize (1L << 4) /* program specified minimum size */112#define PMaxSize (1L << 5) /* program specified maximum size */113#define PResizeInc (1L << 6) /* program specified resize increments */114#define PAspect (1L << 7) /* program specified min and max aspect ratios */115#define PBaseSize (1L << 8) /* program specified base for incrementing */116#define PWinGravity (1L << 9) /* program specified window gravity */117 118/* obsolete */119#define PAllHints (PPosition|PSize|PMinSize|PMaxSize|PResizeInc|PAspect)120 121 122 123typedef struct {124 long flags; /* marks which fields in this structure are defined */125 Bool input; /* does this application rely on the window manager to126 get keyboard input? */127 int initial_state; /* see below */128 Pixmap icon_pixmap; /* pixmap to be used as icon */129 Window icon_window; /* window to be used as icon */130 int icon_x, icon_y; /* initial position of icon */131 Pixmap icon_mask; /* icon mask bitmap */132 XID window_group; /* id of related window group */133 /* this structure may be extended in the future */134} XWMHints;135 136/* definition for flags of XWMHints */137 138#define InputHint (1L << 0)139#define StateHint (1L << 1)140#define IconPixmapHint (1L << 2)141#define IconWindowHint (1L << 3)142#define IconPositionHint (1L << 4)143#define IconMaskHint (1L << 5)144#define WindowGroupHint (1L << 6)145#define AllHints (InputHint|StateHint|IconPixmapHint|IconWindowHint| \146IconPositionHint|IconMaskHint|WindowGroupHint)147#define XUrgencyHint (1L << 8)148 149/* definitions for initial window state */150#define WithdrawnState 0 /* for windows that are not mapped */151#define NormalState 1 /* most applications want to start this way */152#define IconicState 3 /* application wants to start as an icon */153 154/*155 * Obsolete states no longer defined by ICCCM156 */157#define DontCareState 0 /* don't know or care */158#define ZoomState 2 /* application wants to start zoomed */159#define InactiveState 4 /* application believes it is seldom used; */160 /* some wm's may put it on inactive menu */161 162 163/*164 * new structure for manipulating TEXT properties; used with WM_NAME,165 * WM_ICON_NAME, WM_CLIENT_MACHINE, and WM_COMMAND.166 */167typedef struct {168 unsigned char *value; /* same as Property routines */169 Atom encoding; /* prop type */170 int format; /* prop data format: 8, 16, or 32 */171 unsigned long nitems; /* number of data items in value */172} XTextProperty;173 174#define XNoMemory -1175#define XLocaleNotSupported -2176#define XConverterNotFound -3177 178typedef enum {179 XStringStyle, /* STRING */180 XCompoundTextStyle, /* COMPOUND_TEXT */181 XTextStyle, /* text in owner's encoding (current locale)*/182 XStdICCTextStyle, /* STRING, else COMPOUND_TEXT */183 /* The following is an XFree86 extension, introduced in November 2000 */184 XUTF8StringStyle /* UTF8_STRING */185} XICCEncodingStyle;186 187typedef struct {188 int min_width, min_height;189 int max_width, max_height;190 int width_inc, height_inc;191} XIconSize;192 193typedef struct {194 char *res_name;195 char *res_class;196} XClassHint;197 198#ifdef XUTIL_DEFINE_FUNCTIONS199extern int XDestroyImage(200 XImage *ximage);201extern unsigned long XGetPixel(202 XImage *ximage,203 int x, int y);204extern int XPutPixel(205 XImage *ximage,206 int x, int y,207 unsigned long pixel);208extern XImage *XSubImage(209 XImage *ximage,210 int x, int y,211 unsigned int width, unsigned int height);212extern int XAddPixel(213 XImage *ximage,214 long value);215#else216/*217 * These macros are used to give some sugar to the image routines so that218 * naive people are more comfortable with them.219 */220#define XDestroyImage(ximage) \221 ((*((ximage)->f.destroy_image))((ximage)))222#define XGetPixel(ximage, x, y) \223 ((*((ximage)->f.get_pixel))((ximage), (x), (y)))224#define XPutPixel(ximage, x, y, pixel) \225 ((*((ximage)->f.put_pixel))((ximage), (x), (y), (pixel)))226#define XSubImage(ximage, x, y, width, height) \227 ((*((ximage)->f.sub_image))((ximage), (x), (y), (width), (height)))228#define XAddPixel(ximage, value) \229 ((*((ximage)->f.add_pixel))((ximage), (value)))230#endif231 232/*233 * Compose sequence status structure, used in calling XLookupString.234 */235typedef struct _XComposeStatus {236 XPointer compose_ptr; /* state table pointer */237 int chars_matched; /* match state */238} XComposeStatus;239 240/*241 * Keysym macros, used on Keysyms to test for classes of symbols242 */243#define IsKeypadKey(keysym) \244 (((unsigned)(keysym) >= XK_KP_Space) && ((unsigned)(keysym) <= XK_KP_Equal))245 246#define IsPrivateKeypadKey(keysym) \247 (((unsigned)(keysym) >= 0x11000000) && ((unsigned)(keysym) <= 0x1100FFFF))248 249#define IsCursorKey(keysym) \250 (((unsigned)(keysym) >= XK_Home) && ((unsigned)(keysym) < XK_Select))251 252#define IsPFKey(keysym) \253 (((unsigned)(keysym) >= XK_KP_F1) && ((unsigned)(keysym) <= XK_KP_F4))254 255#define IsFunctionKey(keysym) \256 (((unsigned)(keysym) >= XK_F1) && ((unsigned)(keysym) <= XK_F35))257 258#define IsMiscFunctionKey(keysym) \259 (((unsigned)(keysym) >= XK_Select) && ((unsigned)(keysym) <= XK_Break))260 261#ifdef XK_XKB_KEYS262#define IsModifierKey(keysym) \263 ((((unsigned)(keysym) >= XK_Shift_L) && ((unsigned)(keysym) <= XK_Hyper_R)) \264 || (((unsigned)(keysym) >= XK_ISO_Lock) && \265 ((unsigned)(keysym) <= XK_ISO_Level5_Lock)) \266 || ((unsigned)(keysym) == XK_Mode_switch) \267 || ((unsigned)(keysym) == XK_Num_Lock))268#else269#define IsModifierKey(keysym) \270 ((((unsigned)(keysym) >= XK_Shift_L) && ((unsigned)(keysym) <= XK_Hyper_R)) \271 || ((unsigned)(keysym) == XK_Mode_switch) \272 || ((unsigned)(keysym) == XK_Num_Lock))273#endif274/*275 * opaque reference to Region data type276 */277typedef struct _XRegion *Region;278 279/* Return values from XRectInRegion() */280 281#define RectangleOut 0282#define RectangleIn 1283#define RectanglePart 2284 285 286/*287 * Information used by the visual utility routines to find desired visual288 * type from the many visuals a display may support.289 */290 291typedef struct {292 Visual *visual;293 VisualID visualid;294 int screen;295 int depth;296#if defined(__cplusplus) || defined(c_plusplus)297 int c_class; /* C++ */298#else299 int class;300#endif301 unsigned long red_mask;302 unsigned long green_mask;303 unsigned long blue_mask;304 int colormap_size;305 int bits_per_rgb;306} XVisualInfo;307 308#define VisualNoMask 0x0309#define VisualIDMask 0x1310#define VisualScreenMask 0x2311#define VisualDepthMask 0x4312#define VisualClassMask 0x8313#define VisualRedMaskMask 0x10314#define VisualGreenMaskMask 0x20315#define VisualBlueMaskMask 0x40316#define VisualColormapSizeMask 0x80317#define VisualBitsPerRGBMask 0x100318#define VisualAllMask 0x1FF319 320/*321 * This defines a window manager property that clients may use to322 * share standard color maps of type RGB_COLOR_MAP:323 */324typedef struct {325 Colormap colormap;326 unsigned long red_max;327 unsigned long red_mult;328 unsigned long green_max;329 unsigned long green_mult;330 unsigned long blue_max;331 unsigned long blue_mult;332 unsigned long base_pixel;333 VisualID visualid; /* added by ICCCM version 1 */334 XID killid; /* added by ICCCM version 1 */335} XStandardColormap;336 337#define ReleaseByFreeingColormap ((XID) 1L) /* for killid field above */338 339 340/*341 * return codes for XReadBitmapFile and XWriteBitmapFile342 */343#define BitmapSuccess 0344#define BitmapOpenFailed 1345#define BitmapFileInvalid 2346#define BitmapNoMemory 3347 348/****************************************************************349 *350 * Context Management351 *352 ****************************************************************/353 354 355/* Associative lookup table return codes */356 357#define XCSUCCESS 0 /* No error. */358#define XCNOMEM 1 /* Out of memory */359#define XCNOENT 2 /* No entry in table */360 361typedef int XContext;362 363#define XUniqueContext() ((XContext) XrmUniqueQuark())364#define XStringToContext(string) ((XContext) XrmStringToQuark(string))365 366_XFUNCPROTOBEGIN367 368/* The following declarations are alphabetized. */369 370extern XClassHint *XAllocClassHint (371 void372);373 374extern XIconSize *XAllocIconSize (375 void376);377 378extern XSizeHints *XAllocSizeHints (379 void380);381 382extern XStandardColormap *XAllocStandardColormap (383 void384);385 386extern XWMHints *XAllocWMHints (387 void388);389 390extern int XClipBox(391 Region /* r */,392 XRectangle* /* rect_return */393);394 395extern Region XCreateRegion(396 void397);398 399extern const char *XDefaultString (void);400 401extern int XDeleteContext(402 Display* /* display */,403 XID /* rid */,404 XContext /* context */405);406 407extern int XDestroyRegion(408 Region /* r */409);410 411extern int XEmptyRegion(412 Region /* r */413);414 415extern int XEqualRegion(416 Region /* r1 */,417 Region /* r2 */418);419 420extern int XFindContext(421 Display* /* display */,422 XID /* rid */,423 XContext /* context */,424 XPointer* /* data_return */425);426 427extern Status XGetClassHint(428 Display* /* display */,429 Window /* w */,430 XClassHint* /* class_hints_return */431);432 433extern Status XGetIconSizes(434 Display* /* display */,435 Window /* w */,436 XIconSize** /* size_list_return */,437 int* /* count_return */438);439 440extern Status XGetNormalHints(441 Display* /* display */,442 Window /* w */,443 XSizeHints* /* hints_return */444);445 446extern Status XGetRGBColormaps(447 Display* /* display */,448 Window /* w */,449 XStandardColormap** /* stdcmap_return */,450 int* /* count_return */,451 Atom /* property */452);453 454extern Status XGetSizeHints(455 Display* /* display */,456 Window /* w */,457 XSizeHints* /* hints_return */,458 Atom /* property */459);460 461extern Status XGetStandardColormap(462 Display* /* display */,463 Window /* w */,464 XStandardColormap* /* colormap_return */,465 Atom /* property */466);467 468extern Status XGetTextProperty(469 Display* /* display */,470 Window /* window */,471 XTextProperty* /* text_prop_return */,472 Atom /* property */473);474 475extern Status XGetWMClientMachine(476 Display* /* display */,477 Window /* w */,478 XTextProperty* /* text_prop_return */479);480 481extern XWMHints *XGetWMHints(482 Display* /* display */,483 Window /* w */484);485 486extern Status XGetWMIconName(487 Display* /* display */,488 Window /* w */,489 XTextProperty* /* text_prop_return */490);491 492extern Status XGetWMName(493 Display* /* display */,494 Window /* w */,495 XTextProperty* /* text_prop_return */496);497 498extern Status XGetWMNormalHints(499 Display* /* display */,500 Window /* w */,501 XSizeHints* /* hints_return */,502 long* /* supplied_return */503);504 505extern Status XGetWMSizeHints(506 Display* /* display */,507 Window /* w */,508 XSizeHints* /* hints_return */,509 long* /* supplied_return */,510 Atom /* property */511);512 513extern Status XGetZoomHints(514 Display* /* display */,515 Window /* w */,516 XSizeHints* /* zhints_return */517);518 519extern int XIntersectRegion(520 Region /* sra */,521 Region /* srb */,522 Region /* dr_return */523);524 525extern void XConvertCase(526 KeySym /* sym */,527 KeySym* /* lower */,528 KeySym* /* upper */529);530 531extern int XLookupString(532 XKeyEvent* /* event_struct */,533 char* /* buffer_return */,534 int /* bytes_buffer */,535 KeySym* /* keysym_return */,536 XComposeStatus* /* status_in_out */537);538 539extern Status XMatchVisualInfo(540 Display* /* display */,541 int /* screen */,542 int /* depth */,543 int /* class */,544 XVisualInfo* /* vinfo_return */545);546 547extern int XOffsetRegion(548 Region /* r */,549 int /* dx */,550 int /* dy */551);552 553extern Bool XPointInRegion(554 Region /* r */,555 int /* x */,556 int /* y */557);558 559extern Region XPolygonRegion(560 XPoint* /* points */,561 int /* n */,562 int /* fill_rule */563);564 565extern int XRectInRegion(566 Region /* r */,567 int /* x */,568 int /* y */,569 unsigned int /* width */,570 unsigned int /* height */571);572 573extern int XSaveContext(574 Display* /* display */,575 XID /* rid */,576 XContext /* context */,577 _Xconst char* /* data */578);579 580extern int XSetClassHint(581 Display* /* display */,582 Window /* w */,583 XClassHint* /* class_hints */584);585 586extern int XSetIconSizes(587 Display* /* display */,588 Window /* w */,589 XIconSize* /* size_list */,590 int /* count */591);592 593extern int XSetNormalHints(594 Display* /* display */,595 Window /* w */,596 XSizeHints* /* hints */597);598 599extern void XSetRGBColormaps(600 Display* /* display */,601 Window /* w */,602 XStandardColormap* /* stdcmaps */,603 int /* count */,604 Atom /* property */605);606 607extern int XSetSizeHints(608 Display* /* display */,609 Window /* w */,610 XSizeHints* /* hints */,611 Atom /* property */612);613 614extern int XSetStandardProperties(615 Display* /* display */,616 Window /* w */,617 _Xconst char* /* window_name */,618 _Xconst char* /* icon_name */,619 Pixmap /* icon_pixmap */,620 char** /* argv */,621 int /* argc */,622 XSizeHints* /* hints */623);624 625extern void XSetTextProperty(626 Display* /* display */,627 Window /* w */,628 XTextProperty* /* text_prop */,629 Atom /* property */630);631 632extern int XSetWMHints(633 Display* /* display */,634 Window /* w */,635 XWMHints* /* wm_hints */636);637 638extern void XSetWMIconName(639 Display* /* display */,640 Window /* w */,641 XTextProperty* /* text_prop */642);643 644extern void XSetWMName(645 Display* /* display */,646 Window /* w */,647 XTextProperty* /* text_prop */648);649 650extern void XSetWMNormalHints(651 Display* /* display */,652 Window /* w */,653 XSizeHints* /* hints */654);655 656extern void XSetWMProperties(657 Display* /* display */,658 Window /* w */,659 XTextProperty* /* window_name */,660 XTextProperty* /* icon_name */,661 char** /* argv */,662 int /* argc */,663 XSizeHints* /* normal_hints */,664 XWMHints* /* wm_hints */,665 XClassHint* /* class_hints */666);667 668extern void XmbSetWMProperties(669 Display* /* display */,670 Window /* w */,671 _Xconst char* /* window_name */,672 _Xconst char* /* icon_name */,673 char** /* argv */,674 int /* argc */,675 XSizeHints* /* normal_hints */,676 XWMHints* /* wm_hints */,677 XClassHint* /* class_hints */678);679 680extern void Xutf8SetWMProperties(681 Display* /* display */,682 Window /* w */,683 _Xconst char* /* window_name */,684 _Xconst char* /* icon_name */,685 char** /* argv */,686 int /* argc */,687 XSizeHints* /* normal_hints */,688 XWMHints* /* wm_hints */,689 XClassHint* /* class_hints */690);691 692extern void XSetWMSizeHints(693 Display* /* display */,694 Window /* w */,695 XSizeHints* /* hints */,696 Atom /* property */697);698 699extern int XSetRegion(700 Display* /* display */,701 GC /* gc */,702 Region /* r */703);704 705extern void XSetStandardColormap(706 Display* /* display */,707 Window /* w */,708 XStandardColormap* /* colormap */,709 Atom /* property */710);711 712extern int XSetZoomHints(713 Display* /* display */,714 Window /* w */,715 XSizeHints* /* zhints */716);717 718extern int XShrinkRegion(719 Region /* r */,720 int /* dx */,721 int /* dy */722);723 724extern int XSubtractRegion(725 Region /* sra */,726 Region /* srb */,727 Region /* dr_return */728);729 730extern int XmbTextListToTextProperty(731 Display* display,732 char** list,733 int count,734 XICCEncodingStyle style,735 XTextProperty* text_prop_return736);737 738extern int XwcTextListToTextProperty(739 Display* display,740 wchar_t** list,741 int count,742 XICCEncodingStyle style,743 XTextProperty* text_prop_return744);745 746extern int Xutf8TextListToTextProperty(747 Display* display,748 char** list,749 int count,750 XICCEncodingStyle style,751 XTextProperty* text_prop_return752);753 754extern void XwcFreeStringList(755 wchar_t** list756);757 758extern Status XTextPropertyToStringList(759 XTextProperty* /* text_prop */,760 char*** /* list_return */,761 int* /* count_return */762);763 764extern int XmbTextPropertyToTextList(765 Display* display,766 const XTextProperty* text_prop,767 char*** list_return,768 int* count_return769);770 771extern int XwcTextPropertyToTextList(772 Display* display,773 const XTextProperty* text_prop,774 wchar_t*** list_return,775 int* count_return776);777 778extern int Xutf8TextPropertyToTextList(779 Display* display,780 const XTextProperty* text_prop,781 char*** list_return,782 int* count_return783);784 785extern int XUnionRectWithRegion(786 XRectangle* /* rectangle */,787 Region /* src_region */,788 Region /* dest_region_return */789);790 791extern int XUnionRegion(792 Region /* sra */,793 Region /* srb */,794 Region /* dr_return */795);796 797extern int XWMGeometry(798 Display* /* display */,799 int /* screen_number */,800 _Xconst char* /* user_geometry */,801 _Xconst char* /* default_geometry */,802 unsigned int /* border_width */,803 XSizeHints* /* hints */,804 int* /* x_return */,805 int* /* y_return */,806 int* /* width_return */,807 int* /* height_return */,808 int* /* gravity_return */809);810 811extern int XXorRegion(812 Region /* sra */,813 Region /* srb */,814 Region /* dr_return */815);816 817#ifdef __clang__818#pragma clang diagnostic pop819#endif820 821_XFUNCPROTOEND822 823#if defined(MAC_OSX_TK)824# undef Region825#endif826 827#endif /* _X11_XUTIL_H_ */828 