#ifndef _XUTIL_H_
#define _XUTIL_H_
#include <X11/Xlib.h>
#define NoValue 0x0000
#define XValue 0x0001
#define YValue 0x0002
#define WidthValue 0x0004
#define HeightValue 0x0008
#define AllValues 0x000F
#define XNegative 0x0010
#define YNegative 0x0020
typedef struct {
long flags;
int x, y;
int width, height;
int min_width, min_height;
int max_width, max_height;
int width_inc, height_inc;
struct {
int x;
int y;
} min_aspect, max_aspect;
int base_width, base_height;
int win_gravity;
} XSizeHints;
#define USPosition (1L << 0)
#define USSize (1L << 1)
#define PPosition (1L << 2)
#define PSize (1L << 3)
#define PMinSize (1L << 4)
#define PMaxSize (1L << 5)
#define PResizeInc (1L << 6)
#define PAspect (1L << 7)
#define PBaseSize (1L << 8)
#define PWinGravity (1L << 9)
#define PAllHints (PPosition|PSize|PMinSize|PMaxSize|PResizeInc|PAspect)
typedef struct {
long flags;
Bool input;
int initial_state;
Pixmap icon_pixmap;
Window icon_window;
int icon_x, icon_y;
Pixmap icon_mask;
XID window_group;
} XWMHints;
#define InputHint (1L << 0)
#define StateHint (1L << 1)
#define IconPixmapHint (1L << 2)
#define IconWindowHint (1L << 3)
#define IconPositionHint (1L << 4)
#define IconMaskHint (1L << 5)
#define WindowGroupHint (1L << 6)
#define AllHints (InputHint|StateHint|IconPixmapHint|IconWindowHint| \
IconPositionHint|IconMaskHint|WindowGroupHint)
#define XUrgencyHint (1L << 8)
#define WithdrawnState 0
#define NormalState 1
#define IconicState 3
#define DontCareState 0
#define ZoomState 2
#define InactiveState 4
typedef struct {
unsigned char *value;
Atom encoding;
int format;
unsigned long nitems;
} XTextProperty;
#define XNoMemory -1
#define XLocaleNotSupported -2
#define XConverterNotFound -3
typedef enum {
XStringStyle,
XCompoundTextStyle,
XTextStyle,
XStdICCTextStyle,
XUTF8StringStyle
} XICCEncodingStyle;
typedef struct {
int min_width, min_height;
int max_width, max_height;
int width_inc, height_inc;
} XIconSize;
typedef struct {
char *res_name;
char *res_class;
} XClassHint;
#ifdef XUTIL_DEFINE_FUNCTIONS
extern int XDestroyImage(
XImage *ximage);
extern unsigned long XGetPixel(
XImage *ximage,
int x, int y);
extern int XPutPixel(
XImage *ximage,
int x, int y,
unsigned long pixel);
extern XImage *XSubImage(
XImage *ximage,
int x, int y,
unsigned int width, unsigned int height);
extern int XAddPixel(
XImage *ximage,
long value);
#else
#define XDestroyImage(ximage) \
((*((ximage)->f.destroy_image))((ximage)))
#define XGetPixel(ximage, x, y) \
((*((ximage)->f.get_pixel))((ximage), (x), (y)))
#define XPutPixel(ximage, x, y, pixel) \
((*((ximage)->f.put_pixel))((ximage), (x), (y), (pixel)))
#define XSubImage(ximage, x, y, width, height) \
((*((ximage)->f.sub_image))((ximage), (x), (y), (width), (height)))
#define XAddPixel(ximage, value) \
((*((ximage)->f.add_pixel))((ximage), (value)))
#endif
typedef struct _XComposeStatus {
XPointer compose_ptr;
int chars_matched;
} XComposeStatus;
#define IsKeypadKey(keysym) \
(((KeySym)(keysym) >= XK_KP_Space) && ((KeySym)(keysym) <= XK_KP_Equal))
#define IsPrivateKeypadKey(keysym) \
(((KeySym)(keysym) >= 0x11000000) && ((KeySym)(keysym) <= 0x1100FFFF))
#define IsCursorKey(keysym) \
(((KeySym)(keysym) >= XK_Home) && ((KeySym)(keysym) < XK_Select))
#define IsPFKey(keysym) \
(((KeySym)(keysym) >= XK_KP_F1) && ((KeySym)(keysym) <= XK_KP_F4))
#define IsFunctionKey(keysym) \
(((KeySym)(keysym) >= XK_F1) && ((KeySym)(keysym) <= XK_F35))
#define IsMiscFunctionKey(keysym) \
(((KeySym)(keysym) >= XK_Select) && ((KeySym)(keysym) <= XK_Break))
#define IsModifierKey(keysym) \
((((KeySym)(keysym) >= XK_Shift_L) && ((KeySym)(keysym) <= XK_Hyper_R)) \
|| (((KeySym)(keysym) >= XK_ISO_Lock) && \
((KeySym)(keysym) <= XK_ISO_Last_Group_Lock)) \
|| ((KeySym)(keysym) == XK_Mode_switch) \
|| ((KeySym)(keysym) == XK_Num_Lock))
typedef struct _XRegion *Region;
#define RectangleOut 0
#define RectangleIn 1
#define RectanglePart 2
typedef struct {
Visual *visual;
VisualID visualid;
int screen;
int depth;
#if defined(__cplusplus) || defined(c_plusplus)
int c_class;
#else
int class;
#endif
unsigned long red_mask;
unsigned long green_mask;
unsigned long blue_mask;
int colormap_size;
int bits_per_rgb;
} XVisualInfo;
#define VisualNoMask 0x0
#define VisualIDMask 0x1
#define VisualScreenMask 0x2
#define VisualDepthMask 0x4
#define VisualClassMask 0x8
#define VisualRedMaskMask 0x10
#define VisualGreenMaskMask 0x20
#define VisualBlueMaskMask 0x40
#define VisualColormapSizeMask 0x80
#define VisualBitsPerRGBMask 0x100
#define VisualAllMask 0x1FF
typedef struct {
Colormap colormap;
unsigned long red_max;
unsigned long red_mult;
unsigned long green_max;
unsigned long green_mult;
unsigned long blue_max;
unsigned long blue_mult;
unsigned long base_pixel;
VisualID visualid;
XID killid;
} XStandardColormap;
#define ReleaseByFreeingColormap ((XID) 1L)
#define BitmapSuccess 0
#define BitmapOpenFailed 1
#define BitmapFileInvalid 2
#define BitmapNoMemory 3
#define XCSUCCESS 0
#define XCNOMEM 1
#define XCNOENT 2
typedef int XContext;
#define XUniqueContext() ((XContext) XrmUniqueQuark())
#define XStringToContext(string) ((XContext) XrmStringToQuark(string))
_XFUNCPROTOBEGIN
extern XClassHint *XAllocClassHint (
void
);
extern XIconSize *XAllocIconSize (
void
);
extern XSizeHints *XAllocSizeHints (
void
);
extern XStandardColormap *XAllocStandardColormap (
void
);
extern XWMHints *XAllocWMHints (
void
);
extern int XClipBox(
Region ,
XRectangle*
);
extern Region XCreateRegion(
void
);
extern const char *XDefaultString (void);
extern int XDeleteContext(
Display* ,
XID ,
XContext
);
extern int XDestroyRegion(
Region
);
extern int XEmptyRegion(
Region
);
extern int XEqualRegion(
Region ,
Region
);
extern int XFindContext(
Display* ,
XID ,
XContext ,
XPointer*
);
extern Status XGetClassHint(
Display* ,
Window ,
XClassHint*
);
extern Status XGetIconSizes(
Display* ,
Window ,
XIconSize** ,
int*
);
extern Status XGetNormalHints(
Display* ,
Window ,
XSizeHints*
);
extern Status XGetRGBColormaps(
Display* ,
Window ,
XStandardColormap** ,
int* ,
Atom
);
extern Status XGetSizeHints(
Display* ,
Window ,
XSizeHints* ,
Atom
);
extern Status XGetStandardColormap(
Display* ,
Window ,
XStandardColormap* ,
Atom
);
extern Status XGetTextProperty(
Display* ,
Window ,
XTextProperty* ,
Atom
);
extern XVisualInfo *XGetVisualInfo(
Display* ,
long ,
XVisualInfo* ,
int*
);
extern Status XGetWMClientMachine(
Display* ,
Window ,
XTextProperty*
);
extern XWMHints *XGetWMHints(
Display* ,
Window
);
extern Status XGetWMIconName(
Display* ,
Window ,
XTextProperty*
);
extern Status XGetWMName(
Display* ,
Window ,
XTextProperty*
);
extern Status XGetWMNormalHints(
Display* ,
Window ,
XSizeHints* ,
long*
);
extern Status XGetWMSizeHints(
Display* ,
Window ,
XSizeHints* ,
long* ,
Atom
);
extern Status XGetZoomHints(
Display* ,
Window ,
XSizeHints*
);
extern int XIntersectRegion(
Region ,
Region ,
Region
);
extern void XConvertCase(
KeySym ,
KeySym* ,
KeySym*
);
extern int XLookupString(
XKeyEvent* ,
char* ,
int ,
KeySym* ,
XComposeStatus*
);
extern Status XMatchVisualInfo(
Display* ,
int ,
int ,
int ,
XVisualInfo*
);
extern int XOffsetRegion(
Region ,
int ,
int
);
extern Bool XPointInRegion(
Region ,
int ,
int
);
extern Region XPolygonRegion(
XPoint* ,
int ,
int
);
extern int XRectInRegion(
Region ,
int ,
int ,
unsigned int ,
unsigned int
);
extern int XSaveContext(
Display* ,
XID ,
XContext ,
_Xconst char*
);
extern int XSetClassHint(
Display* ,
Window ,
XClassHint*
);
extern int XSetIconSizes(
Display* ,
Window ,
XIconSize* ,
int
);
extern int XSetNormalHints(
Display* ,
Window ,
XSizeHints*
);
extern void XSetRGBColormaps(
Display* ,
Window ,
XStandardColormap* ,
int ,
Atom
);
extern int XSetSizeHints(
Display* ,
Window ,
XSizeHints* ,
Atom
);
extern int XSetStandardProperties(
Display* ,
Window ,
_Xconst char* ,
_Xconst char* ,
Pixmap ,
char** ,
int ,
XSizeHints*
);
extern void XSetTextProperty(
Display* ,
Window ,
XTextProperty* ,
Atom
);
extern void XSetWMClientMachine(
Display* ,
Window ,
XTextProperty*
);
extern int XSetWMHints(
Display* ,
Window ,
XWMHints*
);
extern void XSetWMIconName(
Display* ,
Window ,
XTextProperty*
);
extern void XSetWMName(
Display* ,
Window ,
XTextProperty*
);
extern void XSetWMNormalHints(
Display* ,
Window ,
XSizeHints*
);
extern void XSetWMProperties(
Display* ,
Window ,
XTextProperty* ,
XTextProperty* ,
char** ,
int ,
XSizeHints* ,
XWMHints* ,
XClassHint*
);
extern void XmbSetWMProperties(
Display* ,
Window ,
_Xconst char* ,
_Xconst char* ,
char** ,
int ,
XSizeHints* ,
XWMHints* ,
XClassHint*
);
extern void Xutf8SetWMProperties(
Display* ,
Window ,
_Xconst char* ,
_Xconst char* ,
char** ,
int ,
XSizeHints* ,
XWMHints* ,
XClassHint*
);
extern void XSetWMSizeHints(
Display* ,
Window ,
XSizeHints* ,
Atom
);
extern int XSetRegion(
Display* ,
GC ,
Region
);
extern void XSetStandardColormap(
Display* ,
Window ,
XStandardColormap* ,
Atom
);
extern int XSetZoomHints(
Display* ,
Window ,
XSizeHints*
);
extern int XShrinkRegion(
Region ,
int ,
int
);
extern Status XStringListToTextProperty(
char** ,
int ,
XTextProperty*
);
extern int XSubtractRegion(
Region ,
Region ,
Region
);
extern int XmbTextListToTextProperty(
Display* display,
char** list,
int count,
XICCEncodingStyle style,
XTextProperty* text_prop_return
);
extern int XwcTextListToTextProperty(
Display* display,
wchar_t** list,
int count,
XICCEncodingStyle style,
XTextProperty* text_prop_return
);
extern int Xutf8TextListToTextProperty(
Display* display,
char** list,
int count,
XICCEncodingStyle style,
XTextProperty* text_prop_return
);
extern void XwcFreeStringList(
wchar_t** list
);
extern Status XTextPropertyToStringList(
XTextProperty* ,
char*** ,
int*
);
extern int XmbTextPropertyToTextList(
Display* display,
const XTextProperty* text_prop,
char*** list_return,
int* count_return
);
extern int XwcTextPropertyToTextList(
Display* display,
const XTextProperty* text_prop,
wchar_t*** list_return,
int* count_return
);
extern int Xutf8TextPropertyToTextList(
Display* display,
const XTextProperty* text_prop,
char*** list_return,
int* count_return
);
extern int XUnionRectWithRegion(
XRectangle* ,
Region ,
Region
);
extern int XUnionRegion(
Region ,
Region ,
Region
);
extern int XWMGeometry(
Display* ,
int ,
_Xconst char* ,
_Xconst char* ,
unsigned int ,
XSizeHints* ,
int* ,
int* ,
int* ,
int* ,
int*
);
extern int XXorRegion(
Region ,
Region ,
Region
);
_XFUNCPROTOEND
#endif