123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903 |
- {$MODE objfpc} // get integer sizes right
- Unit XUtil;
- interface
- uses x,xlib;
- { You must include <X11/Xlib.h> before including this file }
- {
- * Bitmask returned by XParseGeometry(). Each bit tells if the corresponding
- * value (x, y, width, height) was found in the parsed string.
- }
- Const
- NoValue =$0000;
- XValue =$0001;
- YValue =$0002;
- WidthValue =$0004;
- HeightValue =$0008;
- AllValues =$000F;
- XNegative =$0010;
- YNegative =$0020;
- {
- * new version containing base_width, base_height, and win_gravity fields;
- * used with WM_NORMAL_HINTS.
- }
- Type
- long = Cardinal; { Untill we know better. M.}
- Type
- TAspectRecord = record
- x,y : integer;
- end;
- TXSizeHints = record
- flags : Long; { marks which fields in this structure are defined }
- x, y : Integer ; { obsolete for new window mgrs, but clients }
- width, height: Integer ; { should set so old wm's don't mess up }
- min_width, min_height : Integer ;
- max_width, max_height : Integer ;
- width_inc, height_inc : Integer ;
- min_aspect, max_aspect : TAspectRecord;
- base_width, base_height : Integer ; { added by ICCCM version 1 }
- win_gravity : Integer ; { added by ICCCM version 1 }
- end;
- PXSizeHints=^TXSizeHints;
- {
- * The next block of definitions are for window manager properties that
- * clients and applications use for communication.
- }
- { flags argument in size hints }
- Const
- USPosition = 1 shl 0; { user specified x, y }
- USSize = 1 shl 1; { user specified width, height }
- PPosition = 1 shl 2; { program specified position }
- PSize = 1 shl 3; { program specified size }
- PMinSize = 1 shl 4; { program specified minimum size }
- PMaxSize = 1 shl 5; { program specified maximum size }
- PResizeInc = 1 shl 6; { program specified resize increments }
- PAspect = 1 shl 7; { program specified min and max aspect ratios }
- PBaseSize = 1 shl 8; { program specified base for incrementing }
- PWinGravity = 1 shl 9; { program specified window gravity }
- { obsolete }
- PAllHints = PPosition or PSize or PMinSize or PMaxSize or PResizeInc or PAspect;
- Type
- TXWMHints = record
- flags : long; { marks which fields in this structure are defined }
- input : TBool ; { does this application rely on the window manager to
- get keyboard input? }
- initial_state : Integer ; { see below }
- icon_pixmap : TPixmap ; { pixmap to be used as icon }
- icon_window : TWindow ; { window to be used as icon }
- icon_x, icon_y : Integer ; { initial position of icon }
- icon_mask : TPixmap ; { icon mask bitmap }
- window_group : TXID ; { id of related window group }
- { this structure may be extended in the future }
- end;
- { definition for flags of XWMHints }
- Const
- InputHint = 1 shl 0;
- StateHint = 1 shl 1;
- IconPixmapHint = 1 shl 2;
- IconWindowHint = 1 shl 3;
- IconPositionHint = 1 shl 4;
- IconMaskHint = 1 shl 5;
- AllHints = InputHint or StateHint or IconPixmapHint or IconWindowHint or
- IconPositionHint or IconMaskHint {or WindowGroupHint};
- XUrgencyHint = 1 shl 8;
- { definitions for initial window state }
- WithdrawnState = 0; { for windows that are not mapped }
- NormalState = 1; { most applications want to start this way }
- IconicState = 3; { application wants to start as an icon }
- {
- * Obsolete states no longer defined by ICCCM
- }
- DontCareState = 0; { don't know or care }
- ZoomState = 2; { application wants to start zoomed }
- InactiveState = 4; { application believes it is seldom used; }
- { some wm's may put it on inactive menu }
- {
- * new structure for manipulating TEXT properties; used with WM_NAME,
- * WM_ICON_NAME, WM_CLIENT_MACHINE, and WM_COMMAND.
- }
- type
- TXTextProperty = record
- value : pchar; { same as Property routines }
- encoding : TAtom; { prop type }
- format : Integer ; { prop data format: 8, 16, or 32 }
- nitems : Cardinal; { number of data items in value }
- end;
- PXTextProperty = ^TXTextProperty;
- Const
- XNoMemory =-1;
- XLocaleNotSupported =-2;
- XConverterNotFound =-3;
- Type
- TXICCEncodingStyle = Integer;
- Const
- XStringStyle = 0; { STRING }
- XCompoundTextStyle = 1; { COMPOUND_TEXT }
- XTextStyle = 2; { text in owner's encoding (current locale)}
- XStdICCTextStyle = 3; { STRING, else COMPOUND_TEXT }
- Type
- TXIconSize = record
- min_width, min_height,
- max_width, max_height,
- width_inc, height_inc : Integer;
- end;
- PXIconSize = ^TXIconSize;
- type
- TXClassHint = record
- res_name,
- res_class : pchar;
- end;
- PXClassHint = ^TXClassHint;
- {
- * These macros are used to give some sugar to the image routines so that
- * naive people are more comfortable with them.
- }
-
- {
- XDestroyImage(ximage) \
- ((*((ximage)->f.destroy_image))((ximage)))
- XGetPixel(ximage, x, y) \
- ((*((ximage)->f.get_pixel))((ximage), (x), (y)))
- XPutPixel(ximage, x, y, pixel) \
- ((*((ximage)->f.put_pixel))((ximage), (x), (y), (pixel)))
- XSubImage(ximage, x, y, width, height) \
- ((*((ximage)->f.sub_image))((ximage), (x), (y), (width), (height)))
- XAddPixel(ximage, value) \
- ((*((ximage)->f.add_pixel))((ximage), (value)))
- }
- {
- * Compose sequence status structure, used in calling XLookupString.
- }
- TXComposeStatus = record
- compose_ptr : TXPointer ; { state table pointer }
- chars_matched : Integer ; { match state }
- end;
- PTXComposeStatus = ^TXComposeStatus;
- {
- * Keysym macros, used on Keysyms to test for classes of symbols
- }
- {
- IsKeypadKey(keysym) \
- (((KeySym)(keysym) >= XK_KP_Space) && ((KeySym)(keysym) <= XK_KP_Equal))
- IsPrivateKeypadKey(keysym) \
- (((KeySym)(keysym) >= 0x11000000) && ((KeySym)(keysym) <= 0x1100FFFF))
- IsCursorKey(keysym) \
- (((KeySym)(keysym) >= XK_Home) && ((KeySym)(keysym) < XK_Select))
- IsPFKey(keysym) \
- (((KeySym)(keysym) >= XK_KP_F1) && ((KeySym)(keysym) <= XK_KP_F4))
- IsFunctionKey(keysym) \
- (((KeySym)(keysym) >= XK_F1) && ((KeySym)(keysym) <= XK_F35))
- IsMiscFunctionKey(keysym) \
- (((KeySym)(keysym) >= XK_Select) && ((KeySym)(keysym) <= XK_Break))
- IsModifierKey(keysym) \
- ((((KeySym)(keysym) >= XK_Shift_L) && ((KeySym)(keysym) <= XK_Hyper_R)) \
- or or ((KeySym)(keysym) == XK_Mode_switch) \
- or or ((KeySym)(keysym) == XK_Num_Lock))
- }
- {
- * opaque reference to Region data type
- }
- {
- typedef struct _XRegion *Region;
- }
- { Return values from XRectInRegion() }
- Const
- RectangleOut =0;
- RectangleIn =1;
- RectanglePart=2;
-
- {
- * Information used by the visual utility routines to find desired visual
- * type from the many visuals a display may support.
- }
- Type
- TXVisualInfo = record
- visual : PVisual;
- visualid : TVisualID ;
- screen : Integer;
- depth : Integer;
- c_class : Integer;
- red_mask : cardinal;
- green_mask : cardinal;
- blue_mask : Cardinal;
- colormap_size : Integer;
- bits_per_rgb : Integer;
- end;
- PXVisualInfo = ^TXVisualInfo;
- Const
- VisualNoMask = $0;
- VisualIDMask = $1;
- VisualScreenMask = $2;
- VisualDepthMask = $4;
- VisualClassMask = $8;
- VisualRedMaskMask = $10;
- VisualGreenMaskMask = $20;
- VisualBlueMaskMask = $40;
- VisualColormapSizeMask = $80;
- VisualBitsPerRGBMask = $100;
- VisualAllMask = $1FF;
- {
- * This defines a window manager property that clients may use to
- * share standard color maps of type RGB_COLOR_MAP:
- }
- Type
- TXStandardColormap = record
- colormap : TColormap ;
- red_max : Cardinal;
- red_mult : Cardinal;
- green_max : Cardinal;
- green_mult : Cardinal;
- blue_max : Cardinal;
- blue_mult : Cardinal;
- base_pixel : Cardinal;
- visualid : TVisualID; { added by ICCCM version 1 }
- killid : TXID ; { added by ICCCM version 1 }
- end;
- PXStandardColormap= ^TXStandardColormap;
- Const
- ReleaseByFreeingColormap = 1; { for killid field above }
- {
- * return codes for XReadBitmapFile and XWriteBitmapFile
- }
- BitmapSuccess =0;
- BitmapOpenFailed =1;
- BitmapFileInvalid =2;
- BitmapNoMemory =3;
- {***************************************************************
- *
- * Context Management
- *
- ***************************************************************}
- { Associative lookup table return codes }
- XCSUCCESS =0; { No error. }
- XCNOMEM =1; { Out of memory }
- XCNOENT =2; { No entry in table }
- type TXContext = Integer;
- {
- XUniqueContext() ((XContext) XrmUniqueQuark())
- XStringToContext(string) ((XContext) XrmStringToQuark(string))
- }
- const _xlib = 'X11';
- function XGetVisualInfo(display: PDisplay; vinfo_mask: LongInt;
- vinfo_template: PXVisualInfo; var nitems_return: Integer): PXVisualInfo;
- cdecl; external _xlib;
- Implementation
- end.
- {
- _XFUNCPROTOBEGIN
- { The following declarations are alphabetized. }
- extern XClassHInteger *XAllocClassHInteger (
- #if NeedFunctionPrototypes
- void
- #endif
- );
- extern XIconSize *XAllocIconSize (
- #if NeedFunctionPrototypes
- void
- #endif
- );
- extern XSizeHints *XAllocSizeHints (
- #if NeedFunctionPrototypes
- void
- #endif
- );
- extern XStandardColormap *XAllocStandardColormap (
- #if NeedFunctionPrototypes
- void
- #endif
- );
- extern XWMHints *XAllocWMHints (
- #if NeedFunctionPrototypes
- void
- #endif
- );
- extern XClipBox(
- #if NeedFunctionPrototypes
- Region { r },
- XRectangle* { rect_return }
- #endif
- );
- extern Region XCreateRegion(
- #if NeedFunctionPrototypes
- void
- #endif
- );
- extern char *XDefaultString(
- #if NeedFunctionPrototypes
- void
- #endif
- );
- extern Integer XDeleteContext(
- #if NeedFunctionPrototypes
- Display* { display },
- XID { rid },
- XContext { context }
- #endif
- );
- extern XDestroyRegion(
- #if NeedFunctionPrototypes
- Region { r }
- #endif
- );
- extern XEmptyRegion(
- #if NeedFunctionPrototypes
- Region { r }
- #endif
- );
- extern XEqualRegion(
- #if NeedFunctionPrototypes
- Region { r1 },
- Region { r2 }
- #endif
- );
- extern Integer XFindContext(
- #if NeedFunctionPrototypes
- Display* { display },
- XID { rid },
- XContext { context },
- XPointer* { data_return }
- #endif
- );
- extern Status XGetClassHint(
- #if NeedFunctionPrototypes
- Display* { display },
- Window { w },
- XClassHint* { class_hints_return }
- #endif
- );
- extern Status XGetIconSizes(
- #if NeedFunctionPrototypes
- Display* { display },
- Window { w },
- XIconSize** { size_list_return },
- int* { count_return }
- #endif
- );
- extern Status XGetNormalHints(
- #if NeedFunctionPrototypes
- Display* { display },
- Window { w },
- XSizeHints* { hints_return }
- #endif
- );
- extern Status XGetRGBColormaps(
- #if NeedFunctionPrototypes
- Display* { display },
- Window { w },
- XStandardColormap** { stdcmap_return },
- int* { count_return },
- Atom { property }
- #endif
- );
- extern Status XGetSizeHints(
- #if NeedFunctionPrototypes
- Display* { display },
- Window { w },
- XSizeHints* { hints_return },
- Atom { property }
- #endif
- );
- extern Status XGetStandardColormap(
- #if NeedFunctionPrototypes
- Display* { display },
- Window { w },
- XStandardColormap* { colormap_return },
- Atom { property }
- #endif
- );
- extern Status XGetTextProperty(
- #if NeedFunctionPrototypes
- Display* { display },
- Window { window },
- XTextProperty* { text_prop_return },
- Atom { property }
- #endif
- );
- extern XVisualInfo *XGetVisualInfo(
- #if NeedFunctionPrototypes
- Display* { display },
- long { vinfo_mask },
- XVisualInfo* { vinfo_template },
- int* { nitems_return }
- #endif
- );
- extern Status XGetWMClientMachine(
- #if NeedFunctionPrototypes
- Display* { display },
- Window { w },
- XTextProperty* { text_prop_return }
- #endif
- );
- extern XWMHints *XGetWMHints(
- #if NeedFunctionPrototypes
- Display* { display },
- Window { w }
- #endif
- );
- extern Status XGetWMIconName(
- #if NeedFunctionPrototypes
- Display* { display },
- Window { w },
- XTextProperty* { text_prop_return }
- #endif
- );
- extern Status XGetWMName(
- #if NeedFunctionPrototypes
- Display* { display },
- Window { w },
- XTextProperty* { text_prop_return }
- #endif
- );
- extern Status XGetWMNormalHints(
- #if NeedFunctionPrototypes
- Display* { display },
- Window { w },
- XSizeHints* { hints_return },
- long* { supplied_return }
- #endif
- );
- extern Status XGetWMSizeHints(
- #if NeedFunctionPrototypes
- Display* { display },
- Window { w },
- XSizeHints* { hints_return },
- long* { supplied_return },
- Atom { property }
- #endif
- );
- extern Status XGetZoomHints(
- #if NeedFunctionPrototypes
- Display* { display },
- Window { w },
- XSizeHints* { zhints_return }
- #endif
- );
- extern XIntersectRegion(
- #if NeedFunctionPrototypes
- Region { sra },
- Region { srb },
- Region { dr_return }
- #endif
- );
- extern void XConvertCase(
- #if NeedFunctionPrototypes
- KeySym { sym },
- KeySym* { lower },
- KeySym* { upper }
- #endif
- );
- extern Integer XLookupString(
- #if NeedFunctionPrototypes
- XKeyEvent* { event_struct },
- char* { buffer_return },
- int { bytes_buffer },
- KeySym* { keysym_return },
- XComposeStatus* { status_in_out }
- #endif
- );
- extern Status XMatchVisualInfo(
- #if NeedFunctionPrototypes
- Display* { display },
- int { screen },
- int { depth },
- int { class },
- XVisualInfo* { vinfo_return }
- #endif
- );
- extern XOffsetRegion(
- #if NeedFunctionPrototypes
- Region { r },
- int { dx },
- int { dy }
- #endif
- );
- extern Bool XPointInRegion(
- #if NeedFunctionPrototypes
- Region { r },
- int { x },
- int { y }
- #endif
- );
- extern Region XPolygonRegion(
- #if NeedFunctionPrototypes
- XPoint* { points },
- int { n },
- int { fill_rule }
- #endif
- );
- extern Integer XRectInRegion(
- #if NeedFunctionPrototypes
- Region { r },
- int { x },
- int { y },
- unsigned int { width },
- unsigned int { height }
- #endif
- );
- extern Integer XSaveContext(
- #if NeedFunctionPrototypes
- Display* { display },
- XID { rid },
- XContext { context },
- _Xconst char* { data }
- #endif
- );
- extern XSetClassHint(
- #if NeedFunctionPrototypes
- Display* { display },
- Window { w },
- XClassHint* { class_hints }
- #endif
- );
- extern XSetIconSizes(
- #if NeedFunctionPrototypes
- Display* { display },
- Window { w },
- XIconSize* { size_list },
- int { count }
- #endif
- );
- extern XSetNormalHints(
- #if NeedFunctionPrototypes
- Display* { display },
- Window { w },
- XSizeHints* { hints }
- #endif
- );
- extern void XSetRGBColormaps(
- #if NeedFunctionPrototypes
- Display* { display },
- Window { w },
- XStandardColormap* { stdcmaps },
- int { count },
- Atom { property }
- #endif
- );
- extern XSetSizeHints(
- #if NeedFunctionPrototypes
- Display* { display },
- Window { w },
- XSizeHints* { hints },
- Atom { property }
- #endif
- );
- extern XSetStandardProperties(
- #if NeedFunctionPrototypes
- Display* { display },
- Window { w },
- _Xconst char* { window_name },
- _Xconst char* { icon_name },
- Pixmap { icon_pixmap },
- char** { argv },
- int { argc },
- XSizeHints* { hints }
- #endif
- );
- extern void XSetTextProperty(
- #if NeedFunctionPrototypes
- Display* { display },
- Window { w },
- XTextProperty* { text_prop },
- Atom { property }
- #endif
- );
- extern void XSetWMClientMachine(
- #if NeedFunctionPrototypes
- Display* { display },
- Window { w },
- XTextProperty* { text_prop }
- #endif
- );
- extern XSetWMHints(
- #if NeedFunctionPrototypes
- Display* { display },
- Window { w },
- XWMHints* { wm_hints }
- #endif
- );
- extern void XSetWMIconName(
- #if NeedFunctionPrototypes
- Display* { display },
- Window { w },
- XTextProperty* { text_prop }
- #endif
- );
- extern void XSetWMName(
- #if NeedFunctionPrototypes
- Display* { display },
- Window { w },
- XTextProperty* { text_prop }
- #endif
- );
- extern void XSetWMNormalHints(
- #if NeedFunctionPrototypes
- Display* { display },
- Window { w },
- XSizeHints* { hints }
- #endif
- );
- extern void XSetWMProperties(
- #if NeedFunctionPrototypes
- Display* { display },
- Window { w },
- XTextProperty* { window_name },
- XTextProperty* { icon_name },
- char** { argv },
- int { argc },
- XSizeHints* { normal_hints },
- XWMHints* { wm_hints },
- XClassHint* { class_hints }
- #endif
- );
- extern void XmbSetWMProperties(
- #if NeedFunctionPrototypes
- Display* { display },
- Window { w },
- _Xconst char* { window_name },
- _Xconst char* { icon_name },
- char** { argv },
- int { argc },
- XSizeHints* { normal_hints },
- XWMHints* { wm_hints },
- XClassHint* { class_hints }
- #endif
- );
- extern void XSetWMSizeHints(
- #if NeedFunctionPrototypes
- Display* { display },
- Window { w },
- XSizeHints* { hints },
- Atom { property }
- #endif
- );
- extern XSetRegion(
- #if NeedFunctionPrototypes
- Display* { display },
- GC { gc },
- Region { r }
- #endif
- );
- extern void XSetStandardColormap(
- #if NeedFunctionPrototypes
- Display* { display },
- Window { w },
- XStandardColormap* { colormap },
- Atom { property }
- #endif
- );
- extern XSetZoomHints(
- #if NeedFunctionPrototypes
- Display* { display },
- Window { w },
- XSizeHints* { zhints }
- #endif
- );
- extern XShrinkRegion(
- #if NeedFunctionPrototypes
- Region { r },
- int { dx },
- int { dy }
- #endif
- );
- extern Status XStringListToTextProperty(
- #if NeedFunctionPrototypes
- char** { list },
- int { count },
- XTextProperty* { text_prop_return }
- #endif
- );
- extern XSubtractRegion(
- #if NeedFunctionPrototypes
- Region { sra },
- Region { srb },
- Region { dr_return }
- #endif
- );
- extern Integer XmbTextListToTextProperty(
- #if NeedFunctionPrototypes
- Display* { display },
- char** { list },
- int { count },
- XICCEncodingStyle { style },
- XTextProperty* { text_prop_return }
- #endif
- );
- extern Integer XwcTextListToTextProperty(
- #if NeedFunctionPrototypes
- Display* { display },
- wchar_t** { list },
- int { count },
- XICCEncodingStyle { style },
- XTextProperty* { text_prop_return }
- #endif
- );
- extern void XwcFreeStringList(
- #if NeedFunctionPrototypes
- wchar_t** { list }
- #endif
- );
- extern Status XTextPropertyToStringList(
- #if NeedFunctionPrototypes
- XTextProperty* { text_prop },
- char*** { list_return },
- int* { count_return }
- #endif
- );
- extern Integer XmbTextPropertyToTextList(
- #if NeedFunctionPrototypes
- Display* { display },
- XTextProperty* { text_prop },
- char*** { list_return },
- int* { count_return }
- #endif
- );
- extern Integer XwcTextPropertyToTextList(
- #if NeedFunctionPrototypes
- Display* { display },
- XTextProperty* { text_prop },
- wchar_t*** { list_return },
- int* { count_return }
- #endif
- );
- extern XUnionRectWithRegion(
- #if NeedFunctionPrototypes
- XRectangle* { rectangle },
- Region { src_region },
- Region { dest_region_return }
- #endif
- );
- extern XUnionRegion(
- #if NeedFunctionPrototypes
- Region { sra },
- Region { srb },
- Region { dr_return }
- #endif
- );
- extern Integer XWMGeometry(
- #if NeedFunctionPrototypes
- Display* { display },
- int { screen_number },
- _Xconst char* { user_geometry },
- _Xconst char* { default_geometry },
- unsigned int { border_width },
- XSizeHints* { hints },
- int* { x_return },
- int* { y_return },
- int* { width_return },
- int* { height_return },
- int* { gravity_return }
- #endif
- );
- extern XXorRegion(
- #if NeedFunctionPrototypes
- Region { sra },
- Region { srb },
- Region { dr_return }
- #endif
- );
- _XFUNCPROTOEND
- #endif { _XUTIL_H_ }
- }
|