Buchempfehlung
Windows-Programmierung. Das Entwicklerhandbuch zur WIN32-API
Windows-Programmierung. Das Entwicklerhandbuch zur WIN32-API
"Der" Petzold, das über 1000 Seiten starke Standardwerk zum Win32-API - besonders nützlich u. a. bei der GUI-Programmierung in FreeBASIC! [Mehr Infos...]
FreeBASIC-Chat
Es sind Benutzer im FreeBASIC-Chat online.
(Stand:  )
FreeBASIC bei Twitter
Twitter FreeBASIC-Nachrichten jetzt auch über Twitter erhalten. Follow us!

fb:porticula NoPaste

Info
Info / Hilfe
Liste
Übersicht / Liste
Neu
Datei hochladen
Suche
Quellcode suchen
Download
Dateidownload

X11.bi

Uploader:MitgliedThePuppetMaster
Datum/Zeit:09.03.2016 14:31:04

' An X Windows XLib framework for the open source FreeBASIC compiler.
'
' Translated by Detlef J�rgen Peters (Joshy)
'
' This software is provided 'as-is', without any express or implied warranty.
' In no event will the authors be held liable for any damages
' arising from the use of this software.
'
' 1. This notice may not be removed or altered from any source distribution.
'
' D.J.Peters@web.de

#ifndef __FB_X11_BI__
#define __FB_X11_BI__

#inclib "X11"

#ifndef NULL
#define NULL  0
#endif

#define XlibSpecificationRelease 6
#define X_PROTOCOL               11 ' current protocol version
#define X_PROTOCOL_REVISION      0  ' current minor version

enum XBOOLEAN
  XFalse = 0
  XTrue  = 1
end enum

' Resources
type Mask      as uinteger
type ATOM      as uinteger
type XTIME     as uinteger

type XID       as uinteger
type VISUALID  as XID
type WINDOWID  as XID
type DRAWABLE  as XID
type FONT      as XID
type PIXMAP    as XID
type CURSOR    as XID
type COLORMAP  as XID
type GCONTEXT  as XID
type KEYSYM    as XID
type KEYCODE   as ubyte
type XPOINTER  as byte ptr
type XCONTEXT  as integer
#Ifndef WCHAR_T
    type WCHAR_T   as short
#endif

'**********************************************
'* RESERVED RESOURCE AND CONSTANT DEFINITIONS *
'**********************************************
#define None                    0 ' universal null resource or null atom
#define ParentRelative          1 ' background pixmap in CreateWindow and ChangeWindowAttributes

'*********************
'* EVENT DEFINITIONS *
'*********************
' Input Event Masks.
' Used as event-mask window attribute and as arguments to Grab requests.
enum EVENTMASKS
  NoEventMask                   = 0
  KeyPressMask                  = ( 1 shl 0)
  KeyReleaseMask                = ( 1 shl 1)
  ButtonPressMask               = ( 1 shl 2)
  ButtonReleaseMask             = ( 1 shl 3)
  EnterWindowMask               = ( 1 shl 4)
  LeaveWindowMask               = ( 1 shl 5)
  PointerMotionMask             = ( 1 shl 6)
  PointerMotionHintMask         = ( 1 shl 7)
  Button1MotionMask             = ( 1 shl 8)
  Button2MotionMask             = ( 1 shl 9)
  Button3MotionMask             = ( 1 shl 10)
  Button4MotionMask             = ( 1 shl 11)
  Button5MotionMask             = ( 1 shl 12)
  ButtonMotionMask              = ( 1 shl 13)
  KeymapStateMask               = ( 1 shl 14)
  ExposureMask                  = ( 1 shl 15)
  VisibilityChangeMask          = ( 1 shl 16)
  StructureNotifyMask           = ( 1 shl 17)
  ResizeRedirectMask            = ( 1 shl 18)
  SubstructureNotifyMask        = ( 1 shl 19)
  SubstructureRedirectMask      = ( 1 shl 20)
  FocusChangeMask               = ( 1 shl 21)
  PropertyChangeMask            = ( 1 shl 22)
  ColormapChangeMask            = ( 1 shl 23)
  OwnerGrabButtonMask           = ( 1 shl 24)
  AllEventsMask                 = &HFFFFFF
end enum

' Event names.  Used in "type" field in structures
' They start from 2 because 0 and 1 are reserved in the protocol for errors and replies.
enum EVENTTYPES
  KeyPress         = 2
  KeyRelease       = 3
  ButtonPress      = 4
  ButtonRelease    = 5
  MotionNotify     = 6
  EnterNotify      = 7
  LeaveNotify      = 8
  FocusIn          = 9
  FocusOut         = 10
  KeymapNotify     = 11
  Expose           = 12
  GraphicsExpose   = 13
  NoExpose         = 14
  VisibilityNotify = 15
  CreateNotify     = 16
  DestroyNotify    = 17
  UnmapNotify      = 18
  MapNotify        = 19
  MapRequest       = 20
  ReparentNotify   = 21
  ConfigureNotify  = 22
  ConfigureRequest = 23
  GravityNotify    = 24
  ResizeRequest    = 25
  CirculateNotify  = 26
  CirculateRequest = 27
  PropertyNotify   = 28
  SelectionClear   = 29
  SelectionRequest = 30
  SelectionNotify  = 31
  ColormapNotify   = 32
  ClientMessage    = 33
  MappingNotify    = 34
  LASTEvent         ' 35 must be bigger than any event #
end enum

' Key masks. Used as modifiers to GrabButton and GrabKey, results of QueryPointer,
' state in various key-, mouse-, and button-related events
enum KEYMASKS
  ShiftMask    = ( 1 shl 0)
  LockMask     = ( 1 shl 1)
  ControlMask  = ( 1 shl 2)
  Mod1Mask     = ( 1 shl 3)
  Mod2Mask     = ( 1 shl 4)
  Mod3Mask     = ( 1 shl 5)
  Mod4Mask     = ( 1 shl 6)
  Mod5Mask     = ( 1 shl 7)
end enum

' modifier names.  Used to build a SetModifierMapping request or to read a GetModifierMapping request.
' These correspond to the masks defined above.
enum KEYINDEXES
  ShiftMapIndex
  LockMapIndex
  ControlMapIndex
  Mod1MapIndex
  Mod2MapIndex
  Mod3MapIndex
  Mod4MapIndex
  Mod5MapIndex
end enum

' button masks.  Used in same manner as Key masks above
enum BUTTONMASKS
  Button1Mask   =(1 shl 8)
  Button2Mask   =(1 shl 9)
  Button3Mask   =(1 shl 10)
  Button4Mask   =(1 shl 11)
  Button5Mask   =(1 shl 12)
  AnyModifier   =(1 shl 15)  ' used in GrabButton, GrabKey
end enum
' button names. Used as arguments to GrabButton and as detail in ButtonPress
' and ButtonRelease events.  Not to be confused with button masks above.
' Note that 0 is already defined above as "AnyButton"
#define Button1        1
#define Button2        2
#define Button3        3
#define Button4        4
#define Button5        5

' Notify modes
#define NotifyNormal           0
#define NotifyGrab             1
#define NotifyUngrab           2
#define NotifyWhileGrabbed     3
#define NotifyHint             1 ' for MotionNotify events

' Notify detail
#define NotifyAncestor                  0
#define NotifyVirtual                   1
#define NotifyInferior                  2
#define NotifyNonlinear                 3
#define NotifyNonlinearVirtual          4
#define NotifyPointer                   5
#define NotifyPointerRoot               6
#define NotifyDetailNone                7

' Visibility notify
#define VisibilityUnobscured            0
#define VisibilityPartiallyObscured     1
#define VisibilityFullyObscured         2

' Circulation request
#define PlaceOnTop                      0
#define PlaceOnBottom                   1

' protocol families
#define FamilyInternet                  0       ' IPv4
#define FamilyDECnet                    1
#define FamilyChaos                     2
#define FamilyInternet6                 6       ' IPv6

' authentication families not tied to a specific protocol
#define FamilyServerInterpreted         5

' Property notification
#define PropertyNewValue                0
#define PropertyDelete                  1

' Color Map notification
#define ColormapUninstalled             0
#define ColormapInstalled               1

' GrabPointer, GrabButton, GrabKeyboard, GrabKey Modes
#define GrabModeSync                    0
#define GrabModeAsync                   1

' GrabPointer, GrabKeyboard reply status
#define GrabSuccess                     0
#define AlreadyGrabbed                  1
#define GrabInvalidTime                 2
#define GrabNotViewable                 3
#define GrabFrozen                      4

' AllowEvents modes
#define AsyncPointer                    0
#define SyncPointer                     1
#define ReplayPointer                   2
#define AsyncKeyboard                   3
#define SyncKeyboard                    4
#define ReplayKeyboard                  5
#define AsyncBoth                       6
#define SyncBoth                        7

' Used in SetInputFocus, GetInputFocus
#define RevertToNone                    None
#define RevertToPointerRoot             PointerRoot
#define RevertToParent                  2

'***************
'* ERROR CODES *
'***************
#define Success                 0       ' everything's okay
#define BadRequest              1       ' bad request code
#define BadValue                2       ' int parameter out of range
#define BadWindow               3       ' parameter not a Window
#define BadPixmap               4       ' parameter not a Pixmap
#define BadAtom                 5       ' parameter not an Atom
#define BadCursor               6       ' parameter not a Cursor
#define BadFont                 7       ' parameter not a Font
#define BadMatch                8       ' parameter mismatch
#define BadDrawable             9       ' parameter not a Pixmap or Window
#define BadAccess               10      ' depending on context:
' key/button already grabbed
' attempt to free an illegal cmap entry
' attempt to store into a read-only color map entry.
' attempt to modify the access control list from other than the local host.
#define BadAlloc                11      ' insufficient resources
#define BadColor                12      ' no such colormap
#define BadGC                   13      ' parameter not a GC
#define BadIDChoice             14      ' choice not in range or already used
#define BadName                 15      ' font or color name doesn't exist
#define BadLength               16      ' Request length incorrect
#define BadImplementation       17      ' server is defective

#define FirstExtensionError     128
#define LastExtensionError      255

'**********************
'* WINDOW DEFINITIONS *
'**********************
' Window classes used by CreateWindow
enum WINDOWCLASSES
  CopyFromParent=0
  InputOutput=1
  InputOnly=2
end enum

' border pixmap in CreateWindow and ChangeWindowAttributes1
' special VisualID and special window class passed to CreateWindow
#define PointerWindow          0 ' destination window in SendEvent
#define InputFocus             1 ' destination window in SendEvent
#define PointerRoot            1 ' focus window in SetInputFocus
#define AnyPropertyType        0 ' special Atom, passed to GetProperty
#define AnyKey                 0 ' special Key Code, passed to GrabKey
#define AnyButton              0 ' special Button Code, passed to GrabButton
#define AllTemporary           0 ' special Resource ID passed to KillClient
#define CurrentTime            0 ' special XTIME
#define NoSymbol               0 ' special KeySym

' Window attributes for CreateWindow and ChangeWindowAttributes
enum WINDOWATTRIBUTEMASKS
  CWBackPixmap         = (1 shl 0)
  CWBackPixel          = (1 shl 1)
  CWBorderPixmap       = (1 shl 2)
  CWBorderPixel        = (1 shl 3)
  CWBitGravity         = (1 shl 4)
  CWWinGravity         = (1 shl 5)
  CWBackingStore       = (1 shl 6)
  CWBackingPlanes      = (1 shl 7)
  CWBackingPixel       = (1 shl 8)
  CWOverrideRedirect   = (1 shl 9)
  CWSaveUnder          = (1 shl 10)
  CWEventMask          = (1 shl 11)
  CWDontPropagate      = (1 shl 12)
  CWColormap           = (1 shl 13)
  CWCursor             = (1 shl 14)
end enum

' ConfigureWindow structure
enum CONFIGUREWINDOWVALUES
  CWX                  = (1 shl 0)
  CWY                  = (1 shl 1)
  CWWidth              = (1 shl 2)
  CWHeight             = (1 shl 3)
  CWBorderWidth        = (1 shl 4)
  CWSibling            = (1 shl 5)
  CWStackMode          = (1 shl 6)
end enum

' Bit Gravity
enum BITGRAVITYS
  ForgetGravity
  NorthWestGravity
  NorthGravity
  NorthEastGravity
  WestGravity
  CenterGravity
  EastGravity
  SouthWestGravity
  SouthGravity
  SouthEastGravity
  StaticGravity
end enum

' Window gravity + bit gravity above
#define UnmapGravity                    0

' Used in CreateWindow for backing-store hint
enum BACKINGSTOREHINTS
  NotUseful
  WhenMapped
  Always
end enum

' Used in GetWindowAttributes reply
enum MAPSTATES
  IsUnmapped
  IsUnviewable
  IsViewable
end enum

' Used in ChangeSaveSet
#define SetModeInsert          0
#define SetModeDelete          1

' Used in ChangeCloseDownMode
#define DestroyAll             0
#define RetainPermanent        1
#define RetainTemporary        2

' Window stacking method (in configureWindow)
#define Above                  0
#define Below                  1
#define TopIf                  2
#define BottomIf               3
#define Opposite               4

' Circulation direction
#define RaiseLowest            0
#define LowerHighest           1

' Property modes
#define PropModeReplace        0
#define PropModePrepend        1
#define PropModeAppend         2

'************************
'* GRAPHICS DEFINITIONS *
'************************
' graphics functions, as in GC.alu
enum GCFUNCTIONS
  GXclear        = 0
  GXand          = 1' src AND dst
  GXandReverse   = 2' src AND NOT dst
  GXcopy         = 3' src
  GXandInverted  = 4' NOT src AND dst
  GXnoop         = 5' dst
  GXxor          = 6' src XOR dst
  GXor           = 7' src OR dst
  GXnor          = 8' NOT src AND NOT dst
  GXequiv        = 9' NOT src XOR dst
  GXinvert       =10' NOT dst
  GXorReverse    =11' src OR NOT dst
  GXcopyInverted =12' NOT src
  GXorInverted   =13' NOT src OR dst
  GXnand         =14' NOT src OR NOT dst
  GXset          =15' 1
end enum

enum LINESTYLES
  LineSolid
  LineOnOffDash
  LineDoubleDash
end enum

enum CAPSTYLES
  CapNotLast
  CapButt
  CapRound
  CapProjecting
end enum

enum  JOINSTYLES
  JoinMiter
  JoinRound
  JoinBevel
end enum

enum FILLSTYLES
  FillSolid
  FillTiled
  FillStippled
  FillOpaqueStippled
end enum

enum FILLRULES
  EvenOddRule
  WindingRule
end enum

enum SUBWINDOWMODES
  ClipByChildren
  IncludeInferiors
end enum

' SetClipRectangles ordering
enum CLIPORDERINGS
  Unsorted
  YSorted
  YXSorted
  YXBanded
end enum

' CoordinateMode for drawing routines
enum COORDMODES
  CoordModeOrigin              ' relative to the origin
  CoordModePrevious            ' relative to previous point
end enum

enum POLYGONESHAPES
  Complex                      ' paths may intersect
  Nonconvex                    ' no paths intersect, but not convex
  Convex                       ' wholly convex
end enum

enum  ARCMODES
  ArcChord                     ' join endpoints of arc
  ArcPieSlice                  ' join endpoints to center of arc
end enum

' GC components: masks used in CreateGC, CopyGC, ChangeGC, GC.stateChanges
enum GCVALUEMASKS
  GCFunction           = (1 shl 0)
  GCPlaneMask          = (1 shl 1)
  GCForeground         = (1 shl 2)
  GCBackground         = (1 shl 3)
  GCLineWidth          = (1 shl 4)
  GCLineStyle          = (1 shl 5)
  GCCapStyle           = (1 shl 6)
  GCJoinStyle          = (1 shl 7)
  GCFillStyle          = (1 shl 8)
  GCFillRule           = (1 shl 9)
  GCTile               = (1 shl 10)
  GCStipple            = (1 shl 11)
  GCTileStipXOrigin    = (1 shl 12)
  GCTileStipYOrigin    = (1 shl 13)
  GCFont               = (1 shl 14)
  GCSubwindowMode      = (1 shl 15)
  GCGraphicsExposures  = (1 shl 16)
  GCClipXOrigin        = (1 shl 17)
  GCClipYOrigin        = (1 shl 18)
  GCClipMask           = (1 shl 19)
  GCDashOffset         = (1 shl 20)
  GCDashList           = (1 shl 21)
  GCArcMode            = (1 shl 22)
  GCLastBit            = 22
end enum

'*********
'* FONTS *
'*********
' used in QueryFont -- draw direction
enum QUERYFONTDIRECTIONS
  FontLeftToRight      = 0
  FontRightToLeft      = 1
  FontChange           = 255
end enum

'************
'*  IMAGING *
'************
' ImageFormat -- PutImage, GetImage
enum IMAGEFORMATS
  XYBitmap             = 0 ' depth 1, XYFormat
  XYPixmap             = 1 ' depth = drawable depth
  ZPixmap              = 2 ' depth = drawable depth
end enum

type XPixmapFormatValues
  depth          as integer
  bits_per_pixel as integer
  scanline_pad   as integer
end type

'********************
'*  COLOR MAP STUFF *
'********************
' For CreateColormap
#define AllocNone      0 ' create map with no entries
#define AllocAll       1 ' allocate entire map writeable

' Flags used in StoreNamedColor, StoreColors
const Do_Red   = 1
const Do_Green = 2
const Do_Blue  = 4

'****************
'* CURSOR STUFF *
'****************
' QueryBestSize Class
#define CursorShape            0 ' largest size that can be displayed
#define TileShape              1 ' size tiled fastest
#define StippleShape           2 ' size stippled fastest

'**************************
'* KEYBOARD/POINTER STUFF *
'**************************
#define AutoRepeatModeOff      0
#define AutoRepeatModeOn       1
#define AutoRepeatModeDefault  2

#define LedModeOff             0
#define LedModeOn              1

' masks for ChangeKeyboardControl
#define KBKeyClickPercent      (1 shl 0)
#define KBBellPercent          (1 shl 1)
#define KBBellPitch            (1 shl 2)
#define KBBellDuration         (1 shl 3)
#define KBLed                  (1 shl 4)
#define KBLedMode              (1 shl 5)
#define KBKey                  (1 shl 6)
#define KBAutoRepeatMode       (1 shl 7)

#define MappingSuccess         0
#define MappingBusy            1
#define MappingFailed          2

#define MappingModifier        0
#define MappingKeyboard        1
#define MappingPointer         2

'**********************
'* SCREEN SAVER STUFF *
'**********************
#define DontPreferBlanking      0
#define PreferBlanking          1
#define DefaultBlanking         2

#define DisableScreenSaver      0
#define DisableScreenInterval   0

#define DontAllowExposures      0
#define AllowExposures          1
#define DefaultExposures        2

' for ForceScreenSaver
#define ScreenSaverReset        0
#define ScreenSaverActive       1

'*************************
'* HOSTS AND CONNECTIONS *
'*************************
' for ChangeHosts
#define HostInsert              0
#define HostDelete              1

' for ChangeAccessControl
#define EnableAccess            1
#define DisableAccess           0

' Display classes  used in opening the connection
' Note that the statically allocated ones are even numbered and the
' dynamically changeable ones are odd numbered
#define StaticGray              0
#define StaticColor             2
#define TrueColor               4

#define GrayScale               1
#define PseudoColor             3
#define DirectColor             5

' Byte order  used in imageByteOrder and bitmapBitOrder
#define LSBFirst                0
#define MSBFirst                1

#define QueuedAlready           0
#define QueuedAfterReading      1
#define QueuedAfterFlush        2

type _XExtData
  number             as integer
  lpnext             as _XExtData ptr
  free_private       as function cdecl(byval as _XExtData ptr) as integer
  private_data       as XPointer
end type
type XExtData as _XExtData

type XExtCodes
  extension          as integer
  major_opcode       as integer
  first_event        as integer
  first_error        as integer
end type ' 4 * 4 = 16

' Data structure for retrieving info about pixmap formats.
type XPixmapFormat
  depth              as integer
  bits_per_pixel     as integer
  scanline_pad       as integer
end type ' 3 * 4 = 12


' Data structure for setting graphics context.
type XGCVALUES
  function           as GCFUNCTIONS    ' logical operation
  plane_mask         as integer        ' plane mask
  foreground         as integer        ' foreground pixel
  background         as integer        ' background pixel
  line_width         as integer        ' line width
  line_style         as LINESTYLES     ' LineSolid, LineOnOffDash, LineDoubleDash
  cap_style          as CAPSTYLES      ' CapNotLast, CapButt, CapRound, CapProjecting
  join_style         as JOINSTYLES     ' JoinMiter, JoinRound, JoinBevel
  fill_style         as FILLSTYLES     ' FillSolid, FillTiled, FillStippled, FillOpaeueStippled
  fill_rule          as FILLRULES      ' EvenOddRule, WindingRule
  arc_mode           as ARCMODES       ' ArcChord, ArcPieSlice
  tile               as XID            ' Pixmap ID tile pixmap for tiling operations
  stipple            as XID            ' Pixmap ID stipple 1 plane pixmap for stipping
  ts_x_origin        as integer        ' offset for tile or stipple operations
  ts_y_origin        as integer
  Font               as XID            ' Font ID default text font for text operations
  subwindow_mode     as SUBWINDOWMODES ' ClipByChildren, IncludeInferiors
  graphics_exposures as XBoolean        'XBoolean, should exposures be generated
  clip_x_origin      as integer        ' origin for clipping
  clip_y_origin      as integer
  clip_mask          as XID            ' Pixmap ID bitmap clipping; other calls for rects
  dash_offset        as integer        ' patterned/dashed line information
  dashes             as byte
  '!!!
  'reserved1        as byte
  'reserved2        as byte
  'reserved3        as byte
end type ' 22*4=88 + 1 = 89 !!!

' Visual structure contains information about colormapping possible.
type VISUAL
  XExtData           as XExtData ptr ' hook for extension to hang data
  visualID           as VISUALID     ' visual id of this visual
  class              as integer      ' class of screen (monochrome, etc.)
  red_mask           as integer
  green_mask         as integer
  blue_mask          as integer      ' mask values
  bits_per_rgb       as integer      ' log base 2 of distinct color values
  map_entries        as integer      ' color map entries
end type ' 8 * 4 = 32

' Depth structure contains information for each possible depth.
type DEPTH
  depth              as integer    ' this depth (Z) of the depth
  nvisuals           as integer    ' number of Visual types at this depth
  visuals            as VISUAL ptr ' list of visuals possible at this depth
end type ' 3 * 4 = 12

'Information about the screen.
'The contents of this structure are implementation dependent.
'A Screen should be treated as opaque by application code.

type _XDisplay as DISPLAY ' Forward declare
type GC        as _XGC 'ptr
type XScreen
  ext_data           as XExtData ptr  ' hook for extension to hang data
  display            as _XDisplay ptr ' back pointer to display structure
  root               as XID           ' Root window id
  width              as integer       ' width and height of screen
  height             as integer
  mwidth             as integer       ' width and height of  in millimeters
  mheight            as integer
  ndepths            as integer       ' number of depths possible
  depths             as Depth ptr     ' list of allowable depths on the screen
  root_depth         as integer       ' bits per pixel
  root_visual        as Visual ptr    ' root visual
  default_gc         as GContext      ' GC for the root root visual
  cmap               as Colormap      ' default color map
  white_pixel        as uinteger      ' White and Black pixel values
  black_pixel        as uinteger
  max_maps           as integer       ' max and min color maps
  min_maps           as integer
  backing_store      as integer       ' Never, WhenMapped, Always
  save_unders        as XBoolean
  root_input_mask    as integer       ' initial root input mask
end type

' Format structure  describes ZFormat data the screen will understand.
type ScreenFormat
  ext_data              as XExtData ptr ' hook for extension to hang data
  depth                 as integer      ' depth of this image format
  bits_per_pixel        as integer      ' bits/pixel at this depth
  scanline_pad          as integer      ' scanline must padded to this multiple
end type ' 4 * 4 =16

' Data structure for setting window attributes.
type XSETWINDOWATTRIBUTES
  background_pixmap      as XID     ' Pixmap ID background or None or ParentRelative
  background_pixel       as integer ' background pixel
  border_pixmap          as XID     ' Pixmap ID border of the window
  border_pixel           as integer ' border pixel value
  bit_gravity            as integer ' one of bit gravity values
  win_gravity            as integer ' one of the window gravity values
  backing_store          as BACKINGSTOREHINTS ' NotUseful, WhenMapped, Always
  backing_planes         as integer ' planes to be preseved if possible
  backing_pixel          as integer ' value to use in restoring planes
  save_under             as XBoolean 'XBoolean should bits under be saved? (popups)
  event_mask             as integer ' set of events that should be saved
  do_not_propagate_mask  as integer ' set of events that should not propagate
  override_redirect      as XBoolean ' XBoolean value for override-redirect
  colormap               as XID     ' Colormap ID to be associated with window
  cursor                 as XID     ' Cursor ID to be displayed (or None)
end type '15 * 4 = 60

'Data to get window attributes
type XWINDOWATTRIBUTES
  x                      as integer      ' location of window
  y                      as integer      ' width and height of window
  width                  as integer
  height                 as integer
  border_width           as integer      ' border width of window
  depth                  as integer      ' depth of window
  visual                 as VISUAL ptr   ' the associated visual structure
  root                   as XID          ' root of screen containing window
  winclass               as WINDOWCLASSES ' InputOutput, InputOnly
  bit_gravity            as integer      ' one of bit gravity values
  win_gravity            as integer      ' one of the window gravity values
  backing_store          as BACKINGSTOREHINTS ' NotUseful, WhenMapped, Always
  backing_planes         as integer      ' planes to be preserved if possible
  backing_pixel          as integer      ' value to be used when restoring planes
  save_under             as XBoolean      'XBoolean, should bits under be saved?
  colormap               as XID          ' color map to be associated with window
  map_installed          as XBoolean      'XBoolean is color map currently installed
  map_state              as MAPSTATES    ' IsUnmapped, IsUnviewable, IsViewable
  all_event_masks        as integer      ' set of events all people have interest in
  your_event_mask        as integer      ' my event mask
  do_not_propagate_mask  as integer      ' set of events that should not propagate
  override_redirect      as XBoolean     ' XBoolean value for override-redirect
  screen                 as XSCREEN ptr  ' back pointer to correct screen
end type '23 * 4 = 92

' Data structure for host setting getting routines.
type XHostAddress
  family       as integer     ' for example FamilyInternet
  length       as integer     ' length of address, in bytes
  char_address as zstring ptr ' pointer to where to find the bytes
end type

' Data structure for ServerFamilyInterpreted addresses in host routines
type XServerInterpretedAddress
  typelength   as integer     ' length of type string, in bytes
  valuelength  as integer     ' length of value string, in bytes
  char_type    as zstring ptr ' pointer to where to find the type string
  char_value   as zstring ptr ' pointer to where to find the address
end type

' Data structure for "image" data, used by image manipulation routines.
type XIMAGE as _XImage
type _XImage
  width                 as integer ' size of image
  height                as integer
  xoffset               as integer ' number of pixels offset in X direction
  format                as integer ' XYBitmap, XYPixmap, ZPixmap
  lpdata                as byte ptr '  pointer to image data
  byte_order            as integer ' data byte order, LSBFirst, MSBFirst
  bitmap_unit           as integer ' quant. of scanline 8, 16, 32
  bitmap_bit_order      as integer ' LSBFirst, MSBFirst
  bitmap_pad            as integer ' 8, 16, 32 either XY or ZPixmap
  depth                 as integer ' depth of image
  bytes_per_line        as integer ' accelarator to next line
  bits_per_pixel        as integer ' bits per pixel (ZPixmap)
  red_mask              as integer ' bits in z arrangment
  green_mask            as integer
  blue_mask             as integer
  obdata                as XPOINTER ' hook for the object routines to hang on

  create_image          as function cdecl ( _
    byval display as _XDisplay ptr, _
    byval visual  as VISUAL    ptr, _
    byval depth   as uinteger     , _
    byval format  as integer      , _
    byval offset  as integer      , _
    byval lpDatat as byte ptr     , _
    byval width   as uinteger     , _
    byval height  as uinteger     , _
    byval bitmap_pad as integer   , _
    byval bytes_per_lineas as  integer) as _XImage ptr

  destroy_image as function cdecl (byval as _XImage ptr) as integer

  get_pixel   as function cdecl ( _
    byval img as _XImage ptr, _
    byval x   as integer, _
    byval y   as integer) as uinteger

  put_pixel        as function cdecl ( _
    byval img      as _XImage ptr, _
    byval x        as integer    , _
    byval y        as integer    , _
    byval pixelcol as uinteger) as integer

  sub_image      as function cdecl ( _
    byval img    as   _XImage ptr, _
    byval x      as integer , _
    byval y      as integer , _
    byval width  as uinteger, _
    byval height as uinteger) as _XImage ptr

  add_pixel     as function cdecl ( _
    byval img   as _XImage ptr, _
    byval pixel as integer    ) as integer
end type ' 22 * 4 = 88

' Data structure for XReconfigureWindow
type XWindowChanges
  x            as integer
  y            as integer
  width        as integer
  height       as integer
  border_width as integer
  sibling      as XID ' Window ID
  stack_mode   as integer
end type '7 * 4 =28

' Data structure used by color operations
type XCOLOR field = 1
  pixel        as integer
  red          as short
  green        as short
  blue         as short
  flags        as byte ' do_red, do_green, do_blue
  pad          as byte
end type ' 14

' Data structures for graphics operations.  On most machines, these are
' congruent with the wire protocol structures, so reformatting the data
' can be avoided on these architectures.
type XSegment
  x1 as short
  y1 as short
  x2 as short
  y2 as short
end type

type XPoint
  x  as short
  y  as short
end type

type XRectangle
  x      as short
  y      as short
  width  as ushort
  height as ushort
end type

type XArc
  x      as short
  y      as short
  width  as ushort
  height as ushort
  angel1 as short
  angle2 as short
end type

' Data structure for XChangeKeyboardControl
type XKeyboardControl
  key_click_percent   as integer
  bell_percent        as integer
  bell_pitch          as integer
  bell_duration       as integer
  led                 as integer
  led_mode            as integer
  key                 as integer
  auto_repeat_mode    as integer   ' On, Off, Default
end type ' 8 * 4 = 32

' Data structure for XGetKeyboardControl
type XKeyboardState
  key_click_percent   as integer
  bell_percent        as integer
  bell_pitch          as integer
  bell_duration       as integer
  led_mask            as integer
  global_auto_repeat  as integer
  auto_repeats(32)    as byte
end type  '24 + 32 =56

' Data structure for XGetMotionEvents.
type XTimeCoord
  t  as XTIME
  x  as short
  y  as short
end type ' 8

' Data structure for X{Set,Get}ModifierMapping
type XModifierKeymap
  max_keypermod as integer  ' The server's max # of keys per modifier
  modifiermap   as byte ptr ' An 8 by max_keypermod array of modifiers
end type

'Display datatype maintaining display specific data.
'The contents of this structure are implementation dependent.
'A Display should be treated as opaque by application code.
type _XPrivate as XPrivate ' Forward declare before use
type _XrmHashBucketRec as XrmHashBucketRec

type Display
  XExtData         as XExtData ptr ' hook for extension to hang data
  private1         as _XPrivate ptr
  fd               as integer      ' Network socket.
  private2         as integer
  proto_major_version as integer ' major version of server's X protocol
  proto_minor_version as integer ' minor version of servers X protocol
  vendor           as zstring ptr    ' vendor of the server hardware
  private3         as XID
  private4         as XID
  private5         as XID
  private6         as integer
  resource_alloc   as function cdecl (byval as _XDisplay ptr) as XID

  byte_order       as integer          ' screen byte order, LSBFirst, MSBFirst
  bitmap_unit      as integer          ' padding and data requirements
  bitmap_pad       as integer          ' padding requirements on bitmaps
  bitmap_bit_order as integer          ' LeastSignificant or MostSignificant
  nformats         as integer          ' number of pixmap formats in list
  pixmap_format    as ScreenFormat ptr ' pixmap format list
  private8         as integer
  release          as integer          ' release of the server
  private9         as _XPrivate ptr
  private10        as _XPrivate ptr
  qlen             as integer          ' Length of input event queue
  last_request_read as uinteger        ' seq number of last event read
  request          as uinteger         ' sequence number of last request.
  private11        as XPointer
  private12        as XPointer
  private13        as XPointer
  private14        as XPointer
  max_request_size as uinteger         ' maximum number 32 bit words in request
  db               as _XrmHashBucketRec ptr
  private15        as function cdecl(byval as Display ptr) as integer
  display_name     as zstring ptr      ' "host:display" string used on this connect
  default_screen   as integer          ' default screen for operations
  nscreens         as integer          ' number of screens on this server
  screens          as XSCREEN ptr      ' pointer to list of screens
  motion_buffer    as uinteger         ' size of motion buffer
  private16        as uinteger
  min_keycode      as integer          ' minimum defined keycode
  max_keycode      as integer          ' maximum defined keycode
  private17        as XPointer
  private18        as XPointer
  private19        as XPointer
  xdefaults        as zstring ptr      ' contents of defaults from server
  'there is more to this structure, but it is private to Xlib
end type

type dpystruc
  fd                    as integer ' fd of X socket
  info                  as integer ' pointer to connection reply from server
  maxRequestSize        as integer ' maximum request size (bytes)

  resource_id           as integer
  resource_base         as integer
  resource_shift        as integer
  resource_mask         as integer
  resource_max          as integer

  major_version         as integer
  minor_version         as integer
  vendor                as integer ' pointer to vendor string
  vendor_size           as integer ' length of verndor string (4 padded)

  nformats              as integer ' number of formats
  pformats              as integer ' pointer to format structs
  nscreens              as integer ' number of screens
  pscreens              as integer ' pointer to screen structs

  error_handler         as integer ' pointer to error_handler (0: use std handler)
  event_handler         as integer ' pointer to event_handler (0: use std handler)

  default_screen_nr     as integer ' default screen number
  default_screen        as integer ' pointer to default screen structure
  default_root          as integer ' default root window ID
  default_visualID      as integer ' root visual ID
  default_visualtype    as integer ' pointer to default visualtype of default screen
  default_depth         as integer ' default depth of default screen
  default_colormap      as integer ' default colormap of default screen

  ImageByteOrder        as integer ' LSBFirst, MSBFirst: Image byte order
  bitmapBitOrder        as integer ' LeastSignificant, MostSign...
  bitmapScanlineUnit    as integer ' 8, 16, 32
  bitmapScanlinePad     as integer ' 8, 16, 32
  XC_MISC_opcode        as integer ' Opcode for XC-Misc Extension
  MIT_SHM_opcode        as integer ' Opcode for MIT-SHM Extension
end type ' 32 * 4 = 128

#define ConnectionNumber(dpy)          (dpy->fd)
#define RootWindow(dpy, s)             (dpy->screens[s].root)
#define DefaultScreen(dpy)             (dpy->default_screen)
#define DefaultRootWindow(dpy)         (dpy->screens[dpy->default_screen].root)
#define DefaultVisual(dpy, s)          (dpy->screens[s].root_visual)
#define DefaultGC(dpy, s)              (dpy->screens[s].default_gc)
#define BlackPixel(dpy, s)             (dpy->screens[s].black_pixel)
#define WhitePixel(dpy, s)             (dpy->screens[s].white_pixel)
#define AllPlanes                      (&HFFFFFFFFL)
#define QLength(dpy)                   (dpy->qlen)
#define DisplayWidth(dpy,s)            (dpy->screens[s].width)
#define DisplayHeight(dpy, s)          (dpy->screens[s].height)
#define DisplayWidthMM(dpy, s)         (dpy->screens[s].mwidth)
#define DisplayHeightMM(dpy, s)        (dpy->screens[s].mheight)
#define DisplayPlanes(dpy, s)          (dpy->screens[s].root_depth)
#define DisplayCells(dpy, s)           (dpy->screens[s].root_visual.map_entries)
#define ScreenCount(dpy)               (dpy->nscreens)
#define ServerVendor(dpy)              (dpy->vendor)
#define ProtocolVersion(dpy)           (dpy->proto_major_version)
#define ProtocolRevision(dpy)          (dpy->proto_minor_version)
#define VendorRelease(dpy)             (dpy->release)
#define DisplayString(dpy)             (dpy->display_name)
#define DefaultDepth(dpy, s)           (dpy->screens[s].root_depth)
#define DefaultColormap(dpy, s)        (dpy->screens[s].cmap)
#define BitmapUnit(dpy)                (dpy->bitmap_unit)
#define BitmapBitOrder(dpy)            (dpy->bitmap_bit_order)
#define BitmapPad(dpy)                 (dpy->bitmap_pad)
#define ImageByteOrder(dpy)            (dpy->byte_order)
#define NextRequest(dpy)               (dpy->request + 1)
#define LastKnownRequestProcessed(dpy) (dpy->last_request_read)

' macros for screen oriented applications (toolkit)
#define ScreenOfDisplay(dpy, s)        (dpy->screens[s])
#define DefaultScreenOfDisplay(dpy)    ScreenOfDisplay(dpy,DefaultScreen(dpy))
#define DisplayOfScreen(scr)           (scr.display)
#define RootWindowOfScreen(scr)        (scr.root)
#define BlackPixelOfScreen(scr)        (scr.black_pixel)
#define WhitePixelOfScreen(scr)        (scr.white_pixel)
#define DefaultColormapOfScreen(scr)   (scr.cmap)
#define DefaultDepthOfScreen(scr)      (scr.root_depth)
#define DefaultGCOfScreen(scr)         (scr.default_gc)
#define DefaultVisualOfScreen(scr)     (scr.root_visual)
#define WidthOfScreen(scr)             (scr.width)
#define HeightOfScreen(scr)            (scr.height)
#define WidthMMOfScreen(scr)           (scr.mwidth)
#define HeightMMOfScreen(scr)          (scr.mheight)
#define PlanesOfScreen(scr)            (scr.root_depth)
#define CellsOfScreen(s)               (dpy->screens[s].root_visual.map_entries)
#define MinCmapsOfScreen(scr)          (scr.min_maps)
#define MaxCmapsOfScreen(scr)          (scr.max_maps)
#define DoesSaveUnders(scr)            (scr.save_unders)
#define DoesBackingStore(scr)          (scr.backing_store)
#define EventMaskOfScreen(scr)         (scr.root_input_mask)

' Definitions of specific events.
type XKEYEVENT
  EventType      as EVENTTYPES  ' enum  of event
  serial         as integer     ' # of last request processed by server
  send_event     as XBoolean     ' true if this came from a SendEvent request
  display        as Display ptr     ' Display the event was read from

  window         as XID         ' "event" window it is reported relative to
  root           as XID         ' Window ID root window that the event occurred on
  subwindow      as XID         ' Window ID child window
  t              as uinteger    ' milliseconds
  x              as integer     ' pointer x, y coordinates in event window
  y              as integer
  x_root         as integer     ' coordinates relative to root
  y_root         as integer
  state          as integer     ' key or button mask
  keycode        as integer     ' detail
  same_screen    as XBoolean     ' same screen flag
end type ' 15*4=60 bytes
type XKeyPressedEvent  as XKEYEVENT
type XKeyReleasedEvent as XKEYEVENT

type XBUTTONEVENT
  EventType      as EVENTTYPES  ' enum  of event
  serial         as integer     ' # of last request processed by server
  send_event     as XBoolean    ' true if this came from a SendEvent request
  display        as Display ptr     ' Display the event was read from

  window         as XID         ' "event" window it is reported relative to
  root           as XID         ' Window ID root window that the event occurred on
  subwindow      as XID         ' Window ID child window
  t              as uinteger    ' milliseconds
  x              as integer     ' pointer x, y coordinates in event window
  y              as integer
  x_root         as integer     ' coordinates relative to root
  y_root         as integer
  state          as integer     ' key or button mask
  button         as integer     ' detail
  same_screen    as XBoolean     ' same screen flag
end type ' 15*4 = 60 bytes
type XButtonPressedEvent  as XBUTTONEVENT
type XButtonReleasedEvent as XBUTTONEVENT

type XMOTIONEVENT
  EventType      as EVENTTYPES  ' enum  of event
  serial         as integer     ' # of last request processed by server
  send_event     as XBoolean     ' true if this came from a SendEvent request
  Disaplay       as Display ptr     ' Display the event was read from

  window         as XID         ' "event" window it is reported relative to
  root           as XID         ' Window ID root window that the event occurred on
  subwindow      as XID         ' Window ID child window
  t              as uinteger    ' milliseconds
  x              as integer     ' pointer x, y coordinates in event window
  y              as integer
  x_root         as integer     ' coordinates relative to root
  y_root         as integer
  state          as integer     ' key or button mask
  is_hint        as byte        ' !!! char detail
  same_screen    as integer     ' same screen flag
end type        ' 14*4+1=57 '60
type XPointerMovedEvent as XMOTIONEVENT

type XCROSSINGEVENT
  EventType      as EVENTTYPES  ' enum  of event
  serial         as integer     ' # of last request processed by server
  send_event     as XBoolean     ' true if this came from a SendEvent request
  display        as Display ptr ' Display the event was read from

  window         as XID         ' "event" window it is reported relative to
  root           as XID         ' Window ID root window that the event occurred on
  subwindow      as XID         ' Window ID child window
  t              as uinteger    ' milliseconds
  x              as integer     ' pointer x, y coordinates in event window
  y              as integer
  x_root         as integer     ' coordinates relative to root
  y_root         as integer
  mode           as integer     ' NotifyNormal, NotifyGrab, NotifyUngrab
  detail         as integer     ' NotifyAncestor, NotifyVirtual, NotifyInferior
                                ' NotifyNonlinear, NotifyNonlinearVirtual
  same_screen    as integer     ' same screen flag
  focus          as XBoolean     'XBoolean focus
  state          as integer     ' key or button mask
end type        ' 17*4=68
type XEnterWindowEvent as XCROSSINGEVENT
type XLeaveWindowEvent as XCROSSINGEVENT

type XFocusChangeEvent
  EventType      as EVENTTYPES  ' FocusIn or FocusOut
  serial         as integer     ' # of last request processed by server
  send_event     as XBoolean     ' true if this came from a SendEvent request
  display        as Display ptr ' Display the event was read from

  window         as XID         ' window of event
  mode           as integer     ' NotifyNormal, NotifyGrab, NotifyUngrab
  detail         as integer     ' NotifyAncestor, NotifyVirtual, NotifyInferior,
                                ' NotifyNonlinear,NotifyNonlinearVirtual, NotifyPointer,
                                ' NotifyPointerRoot, NotifyDetailNone
end type '7 * 4 = 28
type XFocusInEvent  as XFocusChangeEvent
type XFocusOutEvent as XFocusChangeEvent

' generated on EnterWindow and FocusIn when KeyMapState selected
type XKeymapEvent
  EventType  as EVENTTYPES
  serial     as integer   ' # of last request processed by server
  send_event as XBoolean   ' true if this came from a SendEvent request
  display    as Display ptr   ' Display the event was read from

  window     as XID       ' window of event
  key_vector(32) as byte
end type ' 4 * 5 = 20 + 32 = 52

type XExposeEvent
  EventType  as EVENTTYPES
  serial     as integer   ' # of last request processed by server
  send_event as XBoolean   ' true if this came from a SendEvent request
  display    as Display ptr   ' Display the event was read from

  window     as XID       ' window of event
  x          as integer
  y          as integer
  width      as integer
  height     as integer
  count      as integer   ' if non-zero, at least this many more
end type '10 * 4 = 40

type XGraphicsExposeEvent
  EventType  as EVENTTYPES
  serial     as integer   ' # of last request processed by server
  send_event as XBoolean   ' true if this came from a SendEvent request
  display    as Display ptr   ' Display the event was read from

  drawable   as XID       ' window of event
  x          as integer
  y          as integer
  width      as integer
  height     as integer
  count      as integer   ' if non-zero, at least this many more
  major_code as integer   ' core is CopyArea or CopyPlane
  minor_code as integer   ' not defined in the core
end type '12 * 4 = 48

type XNoExposeEvent
  EventType  as EVENTTYPES
  serial     as integer   ' # of last request processed by server
  send_event as XBoolean   ' true if this came from a SendEvent request
  display    as Display ptr   ' Display the event was read from

  drawable   as XID       ' window of event
  major_code as integer   ' core is CopyArea or CopyPlane
  minor_code as integer   ' not defined in the core
end type '7 * 4 = 26

type XVisibilityEvent
  EventType  as EVENTTYPES
  serial     as integer   ' # of last request processed by server
  send_event as XBoolean   ' true if this came from a SendEvent request
  display    as Display ptr   ' Display the event was read from

  window     as XID       ' window of event
  state      as integer   ' Visibility state
end type ' 6 * 4 = 24

type XCreateWindowEvent
  EventType         as EVENTTYPES
  serial            as integer   ' # of last request processed by server
  send_event        as XBoolean   ' true if this came from a SendEvent request
  display           as Display ptr   ' Display the event was read from

  parent            as XID       ' parent of the window
  window            as XID       ' windowid of created window
  x                 as integer
  y                 as integer
  width             as integer
  height            as integer
  border_width      as integer   ' border width
  override_redirect as integer   ' creation should be overridden
end type '12 * 4=48

type XDestroyWindowEvent
  EventType         as EVENTTYPES
  serial            as integer   ' # of last request processed by server
  send_event        as XBoolean   ' true if this came from a SendEvent request
  Display           as Display ptr   ' Display the event was read from

  event             as integer
  window            as XID
end type ' 6 * 4 = 24

type XUnmapEvent
  EventType         as EVENTTYPES
  serial            as integer   ' # of last request processed by server
  send_event        as XBoolean   ' true if this came from a SendEvent request
  Display           as Display ptr   ' Display the event was read from

  event             as integer
  window            as XID
  from_configure as integer
end type ' 7 * 4 = 28

type XMapEvent
  EventType         as EVENTTYPES
  serial            as integer   ' # of last request processed by server
  send_event        as XBoolean   ' true if this came from a SendEvent request
  Display           as Display ptr   ' Display the event was read from

  event             as XID
  window            as XID
  override_redirect as XBoolean   'XBoolean, is override set...
end type ' 7 * 4 = 28

type XMapRequestEvent
  EventType         as EVENTTYPES
  serial            as integer   ' # of last request processed by server
  send_event        as XBoolean   ' true if this came from a SendEvent request
  Display           as Display ptr   ' Display the event was read from

  parent            as XID
  window            as XID
end type '6 * 4 = 24

type XReparentEvent
  EventType         as EVENTTYPES
  serial            as integer   ' # of last request processed by server
  send_event        as XBoolean   ' true if this came from a SendEvent request
  Display           as Display ptr   ' Display the event was read from

  event             as integer
  window            as XID
  parent            as XID
  x                 as integer
  y                 as integer
  override_redirect as XBoolean
end type ' 10 * 4 = 40

type XConfigureEvent
  EventType         as EVENTTYPES
  serial            as integer   ' # of last request processed by server
  send_event        as XBoolean   ' true if this came from a SendEvent request
  Display           as Display ptr   ' Display the event was read from

  event             as XID
  window            as XID
  x                 as integer
  y                 as integer
  width             as integer
  height            as integer
  border_width      as integer
  abovewindow       as XID
  override_redirect as XBoolean
end type '12 * 4 = 52

type XGravityEvent
  EventType         as EVENTTYPES
  serial            as integer   ' # of last request processed by server
  send_event        as XBoolean   ' true if this came from a SendEvent request
  Display           as Display ptr   ' Display the event was read from

  event             as integer
  window            as XID
  x                 as integer
  y                 as integer
end type '8 * 4 = 32

type XResizeRequestEvent
  EventType         as EVENTTYPES
  serial            as integer   ' # of last request processed by server
  send_event        as XBoolean   ' true if this came from a SendEvent request
  Display           as Display ptr   ' Display the event was read from

  window            as XID
  width             as integer
  height            as integer
end type ' 7 * 4 = 28

type XConfigureRequestEvent
  EventType         as EVENTTYPES
  serial            as integer
  send_event        as XBoolean
  Display           as Display ptr

  parent            as XID
  window            as XID
  x                 as integer
  y                 as integer
  width             as integer
  height            as integer
  border_width      as integer
  abovewindow       as XID
  detail            as integer   ' Above, Below, TopIf, BottomIf, Opposite
  value_mask        as uinteger
end type

type XCirculateEvent
  EventType         as EVENTTYPES
  serial            as integer
  send_event        as XBoolean
  Display           as Display ptr

  event             as integer
  window            as XID
  place             as integer   ' PlaceOnTop, PlaceOnBottom
end type

type XCirculateRequestEvent
  EventType         as EVENTTYPES
  serial            as integer
  send_event        as XBoolean
  Display           as Display ptr

  parent            as XID
  window            as XID
  place             as integer   ' PlaceOnTop, PlaceOnBottom
end type

type XPropertyEvent
  EventType         as EVENTTYPES
  serial            as integer
  send_event        as XBoolean
  Display           as Display ptr

  Window            as XID
  atom              as Atom
  t                 as XTIME
  state             as integer   ' NewValue, Deleted
end type

type XSelectionClearEvent
  EventType         as EVENTTYPES
  serial            as integer
  send_event        as XBoolean
  Display           as Display ptr

  Window            as XID
  atom              as Atom
  t                 as XTIME
end type

type XSelectionRequestEvent
  EventType         as EVENTTYPES
  serial            as integer
  send_event        as XBoolean
  Display           as Display ptr

  owner             as XID       ' window
  requestor         as XID       ' window
  selection         as Atom
  target            as Atom
  property          as Atom
  t                 as XTIME
end type

type XSelectionEvent
  EventType         as EVENTTYPES
  serial            as integer
  send_event        as XBoolean
  Display           as Display ptr

  requestor         as XID       ' window
  selection         as Atom
  target            as Atom
  property          as Atom      ' ATOM or None
  t                 as XTIME
end type

type XColormapEvent
  EventType         as EVENTTYPES
  serial            as integer
  send_event        as XBoolean
  Display           as Display ptr

  Window            as XID
  colormap          as integer   ' COLORMAP or None
  _new              as integer
  state             as integer   ' ColormapInstalled, ColormapUninstalled
end type '8 * 4 = 32

type XClientMessageEvent
  EventType         as EVENTTYPES
  serial            as integer
  send_event        as XBoolean
  Display           as Display ptr

  Window            as XID
  message_type      as Atom
  format            as integer
  union
    b(20) as byte
    s(10) as short
    l(5)  as integer
  end union
end type

type XMappingEvent
  EventType         as EVENTTYPES
  serial            as integer
  send_event        as XBoolean
  Display           as Display ptr

  Window            as XID       ' unused
  request           as integer   ' one of MappingModifier, MappingKeyboard, MappingPointer
  first_keycode     as integer   ' first keycode
  count             as integer   ' defines range of change w. first_keycode
end type        ' 8 * 4 = 32

type XErrorEvent
  EventType         as EVENTTYPES
  Display           as Display ptr
  resourceid        as integer   ' resource id
  serial            as integer   ' serial number of failed request
  error_code        as byte      ' char error code of failed request
  request_code      as byte      ' char Major op-code of failed request
  minor_code        as byte      ' char Minor op-code of failed request
end type        '4*4=16+3=19

' !!!
type XAnyEvent
  EventType         as EVENTTYPES
  serial            as integer
  sennd_event       as XBoolean
  display           as Display ptr
  Window            as XID
end type ' 4*5=20

union XEvent
  EventType         as integer              ' must not be changed first element
  xany              as XAnyEvent
  xkey              as XKeyEvent
  xbutton           as XButtonEvent
  xmotion           as XMotionEvent
  xcossing          as XCrossingEvent
  xfocus            as XFocusChangeEvent
  xexpose           as XExposeEvent
  xgraphicsexpose   as XGraphicsExposeEvent
  xnoexpose         as XNoExposeEvent
  xvisibility       as XVisibilityEvent
  xcreatewindow     as XCreateWindowEvent
  xdestroywindow    as XDestroyWindowEvent
  xunmap            as XUnmapEvent
  xmap              as XMapEvent
  xmaprequest       as XMapRequestEvent
  xreparent         as XReparentEvent
  xconfigure        as XConfigureEvent
  xgravity          as XGravityEvent
  xresizerequest    as XResizeRequestEvent
  xconfigurerequest as XConfigureRequestEvent
  xcirculate        as XCirculateEvent
  xcirculaterequest as XCirculateRequestEvent
  xproperty         as XPropertyEvent
  xselectionclear   as XSelectionClearEvent
  xselectionrequest as XSelectionRequestEvent
  xselection        as XSelectionEvent
  xcolormap         as XColormapEvent
  xclient           as XClientMessageEvent
  xmapping          as XMappingEvent
  xerror            as XErrorEvent
  xkeymap           as XKeymapEvent
  pad(24)           as integer
end union


' per character font metric information.
type XCharStruct
  lbearing          as short ' origin to left edge of raster
  rbearing          as short ' origin to right edge of raster
  width             as short ' advance to next char's origin
  ascent            as short ' baseline to top edge of raster
  descent           as short ' baseline to bottom edge of raster
  attributes        as short ' per char flags (not predefined)
end type ' 6 * 2 = 12

' To allow arbitrary information with fonts, there are additional properties returned.
type XFontProp
  name              as Atom
  card32            as integer
end type

type XFontStruct field = 1
  XExtData          as XExtData ptr    ' hook for extension to hang data
  fid               as XID             ' Font id for this font
  direction         as byte            ' !!! unsigned hint about direction the font is painted
  min_char_or_byte2 as byte            ' !!! unsigned first character
  max_char_or_byte2 as byte            ' !!! unsigned last character
  min_byte1         as byte            ' !!! unsigned first row that exists
  max_byte1         as byte            ' !!! unsigned last row that exists
  all_chars_exist   as XBoolean         ' Bool flag if all characters have non-zero size
  default_char      as ubyte           ' !!! unsigned char to print for undefined character
  n_properties      as integer         ' how many properties there are
  properties        as XFONTPROP ptr   ' XFontProp pointer to array of additional properties
  min_bounds        as XCharStruct     ' XCharStruct minimum bounds over all existing char
  max_bounds        as XCharStruct     ' XCharStruct maximum bounds over all existing char
  per_char          as XCharStruct ptr ' pointer XCharStruct first_char to last_char information
  ascent            as integer         ' log. extent above baseline for spacing
  descent           as integer         ' log. descent below baseline for spacing
end type ' 8*4 + 6*1 + 12*1 + 12*1 = 62

' PolyText routines take these as arguments.
type XTextItem
  chars             as integer      ' pointer to string
  nchars            as integer      ' number of characters
  delta             as integer      ' delta between strings
  font              as XID ' font ID to print it in, None don't change
end type ' 4 * 4 = 16

type XChar2b ' normal 16 bit characters are two bytes
  byte1         as ubyte
  byte2         as ubyte
end type

type XTextItem16
  chars         as XChar2b ptr ' two byte characters
  nchars        as integer     ' number of characters
  delta         as integer     ' delta between strings
  font          as XID         ' font to print it in, None don't change
end type

union XEDataObject
  display       as display      ptr
  gc            as GCONTEXT
  visual        as VISUAL       ptr
  screen        as XSCREEN      ptr
  pixmap_format as ScreenFormat ptr
  font          as XFontStruct  ptr
end union

type XFONTSETEXTENS
  max_ink_extent      as XRectangle
  max_logical_extent  as XRectangle
end type

'!!!
type xFontSet as any ptr

' unused:
'typedef void (*XOMProc)();

type XOM as _XOM ptr
type XOC as _XOC ptr
'typedef struct _XOC *XOC, *XFontSet;

type XmbTextItem
  chars    as zstring ptr
  nchars   as integer
  delta    as integer
  font_set as XFontSet
end type

type XwcTextItem
  cghars   as wchar_t ptr
  nchars   as integer
  delta    as integer
  font_set as XFontSet
end type

#define XNRequiredCharSet               "requiredCharSet"
#define XNQueryOrientation              "queryOrientation"
#define XNBaseFontName                  "baseFontName"
#define XNOMAutomatic                   "omAutomatic"
#define XNMissingCharSet                "missingCharSet"
#define XNDefaultString                 "defaultString"
#define XNOrientation                   "orientation"
#define XNDirectionalDependentDrawing   "directionalDependentDrawing"
#define XNContextualDrawing             "contextualDrawing"
#define XNFontInfo                      "fontInfo"

type XOMCharSetList
  charset_count as integer
  charset_list  as ubyte ptr ptr
end type

enum XOrientation
  XOMOrientation_LTR_TTB
  XOMOrientation_RTL_TTB
  XOMOrientation_TTB_LTR
  XOMOrientation_TTB_RTL
  XOMOrientation_Context
end enum

type XOMOrientation
  num_orientation as integer
  orientation     as XOrientation ptr ' Input Text description
end type

type XOMFontInfo
  num_font         as integer
  font_struct_list as XFontStruct ptr ptr
  font_name_list   as ubyte       ptr ptr
end type

type XIM      as _XIM ptr
type XIC      as _XIC ptr
type XIMProc  as sub      cdecl (byval as XIM, byval as XPointer, byval as XPointer)
type XICProc  as function cdecl (byval as XIC, byval as XPointer, byval as XPointer) as integer
type XIDProc  as sub      cdecl (byval as Display ptr, byval as XPointer, byval as XPointer)
type XIMStyle as uinteger
type _XrmHushBucketRec as any ptr '!!!

type XIMStyles
  count_styles     as ushort
  supported_styles as XIMStyle ptr
end type

#define XIMPreeditArea                  &H0001
#define XIMPreeditCallbacks             &H0002
#define XIMPreeditPosition              &H0004
#define XIMPreeditNothing               &H0008
#define XIMPreeditNone                  &H0010
#define XIMStatusArea                   &H0100
#define XIMStatusCallbacks              &H0200
#define XIMStatusNothing                &H0400
#define XIMStatusNone                   &H0800

#define XNVaNestedList                  "XNVaNestedList"
#define XNQueryInputStyle               "queryInputStyle"
#define XNClientWindow                  "clientWindow"
#define XNInputStyle                    "inputStyle"
#define XNFocusWindow                   "focusWindow"
#define XNResourceName                  "resourceName"
#define XNResourceClass                 "resourceClass"
#define XNGeometryCallback              "geometryCallback"
#define XNDestroyCallback               "destroyCallback"
#define XNFilterEvents                  "filterEvents"
#define XNPreeditStartCallback          "preeditStartCallback"
#define XNPreeditDoneCallback           "preeditDoneCallback"
#define XNPreeditDrawCallback           "peeditDrawCallback"
#define XNPreeditCaretCallback          "preeditCaretCallback"
#define XNPreeditStateNotifyCallback    "preeditStateNotifyCallback"
#define XNPreeditAttributes             "preeditAttributes"
#define XNStatusStartCallback           "statusStartCallback"
#define XNStatusDoneCallback            "statusDoneCallback"
#define XNStatusDrawCallback            "statusDrawCallback"
#define XNStatusAttributes              "statusAttributes"
#define XNArea                          "area"
#define XNAreaNeeded                    "areaNeeded"
#define XNSpotLocation                  "spotLocation"
#define XNColormap                      "colorMap"
#define XNStdColormap                   "stdColorMap"
#define XNForeground                    "foreground"
#define XNBackground                    "background"
#define XNBackgroundPixmap              "backgroundPixmap"
#define XNFontSet                       "fontSet"
#define XNLineSpace                     "lineSpace"
#define XNCursor                        "cursor"

#define XNQueryIMValuesList             "queryIMValuesList"
#define XNQueryICValuesList             "queryICValuesList"
#define XNVisiblePosition               "visiblePosition"
#define XNR6PreeditCallback             "r6PreeditCallback"
#define XNStringConversionCallback      "stringConversionCallback"
#define XNStringConversion              "stringConversion"
#define XNResetState                    "resetState"
#define XNHotKey                        "hotKey"
#define XNHotKeyState                   "hotKeyState"
#define XNPreeditState                  "preeditState"
#define XNSeparatorofNestedList         "separatorofNestedList"

#define XBufferOverflow                -1
#define XLookupNone                     1
#define XLookupChars                    2
'#define XLookupKeySym                   3 '!!! conflict with same function proto type
#define XLookupBoth                     4

type XVaNestedList as any ptr
type XIMCallback
  client_data as XPointer
  callback    as XIMProc
end type

type XICCallback
  client_data as XPointer
  callback    as XICProc
end type

type XIMFeedback as uinteger

#define XIMReverse                      (1 shl 0)
#define XIMUnderline                    (1 shl 1)
#define XIMHighlight                    (1 shl 2)
#define XIMPrimary                      (1 shl 5)
#define XIMSecondary                    (1 shl 6)
#define XIMTertiary                     (1 shl 7)
#define XIMVisibleToForward             (1 shl 8)
#define XIMVisibleToBackword            (1 shl 9)
#define XIMVisibleToCenter              (1 shl 10)

type _XIMText
  length as ushort
  feedback as XIMFeedback ptr
  encoding_is_wchar as XBoolean
  union
    multi_byte as zstring ptr
    wide_char as wchar_t ptr
  end union
end type
type XIMText as _XIMText

type XIMPreeditState as uinteger

#define XIMPreeditUnKnown 0L
#define XIMPreeditEnable 1L
#define XIMPreeditDisable (1L shl 1)

type _XIMPreeditStateNotifyCallbackStruct
  state as XIMPreeditState
end type

type XIMPreeditStateNotifyCallbackStruct as _XIMPreeditStateNotifyCallbackStruct
type XIMResetState as uinteger

#define XIMInitialState 1L
#define XIMPreserveState (1L shl 1)

type XIMStringConversionFeedback as uinteger

#define XIMStringConversionLeftEdge   (&h00000001)
#define XIMStringConversionRightEdge  (&h00000002)
#define XIMStringConversionTopEdge    (&h00000004)
#define XIMStringConversionBottomEdge (&h00000008)
#define XIMStringConversionConcealed  (&h00000010)
#define XIMStringConversionWrapped    (&h00000020)

type _XIMStringConversionText
  length   as ushort
  feedback as XIMStringConversionFeedback ptr
  encoding_is_wchar as integer
  union
    mbs as zstring ptr
    wcs as wchar_t ptr
  end union
end type

type XIMStringConversionText     as _XIMStringConversionText
type XIMStringConversionPosition as ushort
type XIMStringConversionType     as ushort

#define XIMStringConversionBuffer (&h0001)
#define XIMStringConversionLine   (&h0002)
#define XIMStringConversionWord   (&h0003)
#define XIMStringConversionChar   (&h0004)

type XIMStringConversionOperation as ushort

#define XIMStringConversionSubstitution (&h0001)
#define XIMStringConversionRetrieval (&h0002)

enum XIMCaretDirection
  XIMForwardChar
  XIMBackwardChar
  XIMForwardWord
  XIMBackwardWord
  XIMCaretUp
  XIMCaretDown
  XIMNextLine
  XIMPreviousLine
  XIMLineStart
  XIMLineEnd
  XIMAbsolutePosition
  XIMDontChange
end enum

type _XIMStringConversionCallbackStruct
  position  as XIMStringConversionPosition
  direction as XIMCaretDirection
  operation as XIMStringConversionOperation
  factor    as ushort
  text      as XIMStringConversionText ptr
end type

type XIMStringConversionCallbackStruct as _XIMStringConversionCallbackStruct

type _XIMPreeditDrawCallbackStruct
  caret      as integer
  chg_first  as integer
  chg_length as integer
  text       as XIMText ptr
end type
type XIMPreeditDrawCallbackStruct as _XIMPreeditDrawCallbackStruct

enum XIMCaretStyle
  XIMIsInvisible
  XIMIsPrimary
  XIMIsSecondary
end enum

type _XIMPreeditCaretCallbackStruct
  position  as integer
  direction as XIMCaretDirection
  style     as XIMCaretStyle
end type
type XIMPreeditCaretCallbackStruct as _XIMPreeditCaretCallbackStruct

enum XIMStatusDataType
  XIMTextType
  XIMBitmapType
end enum

type _XIMStatusDrawCallbackStruct
  type as XIMStatusDataType
  union
    text as XIMText ptr
    bitmap as Pixmap
  end union
end type
type XIMStatusDrawCallbackStruct as _XIMStatusDrawCallbackStruct

type _XIMHotKeyTrigger
  keysym        as KeySym
  modifier      as integer
  modifier_mask as integer
end type

type XIMHotKeyTrigger as _XIMHotKeyTrigger
type _XIMHotKeyTriggers
  num_hot_key as integer
  key         as XIMHotKeyTrigger ptr
end type

type XIMHotKeyTriggers as _XIMHotKeyTriggers
type XIMHotKeyState    as uinteger

#define XIMHotKeyStateON  (&h0001)
#define XIMHotKeyStateOFF (&h0002)

type XIMValuesList
  count_values     as ushort
  supported_values as byte ptr ptr
end type

declare function XLoadQueryFont cdecl alias "XLoadQueryFont" ( _
  byval lpDisplay as Display ptr, _
  byval name as string) as XFONTSTRUCT ptr

declare function XQueryFont cdecl alias "XQueryFont" ( _
  byval lpDisplay as Display ptr, _
  byval font_ID   as XID) as XFONTSTRUCT ptr

declare function XGetMotionEvents cdecl alias "XGetMotionEvents" ( _
  byval lpDisplay  as Display ptr, _
  byval hWin       as WINDOWID   , _
  byval start_time as XTIME       , _
  byval stop_time  as XTIME       , _
  byref nevents_return as integer) as XTIMECOORD ptr


declare function XDeleteModifiermapEntry cdecl alias "XDeleteModifiermapEntry" ( _
  byref modmap        as XModifierKeymap, _
  byval keycode_entry as KEYCODE        , _
  byval modifier      as integer) as XModifierKeymap ptr

declare function XGetModifierMapping cdecl alias "XGetModifierMapping" ( _
  byval lpDisplay as Display ptr) as XModifierKeymap ptr

declare function XNewModifiermap cdecl alias "XNewModifiermap" ( _
  byval max_keys_per_mod as integer) as XModifierKeymap ptr



' X function declarations

declare sub      XrmInitialize cdecl alias "XrmInitialize"()

'The client must free this storage when finished with it by calling XFree().
declare function XFetchBytes   cdecl alias "XFetchBytes"   ( _
  byval lpDisplay           as Display ptr, _
  byref num_of_bytes_return as integer) as any ptr

declare function XFetchBuffer  cdecl alias "XFetchBuffer"  ( _
  byval lpDisplay           as Display ptr, _
  byref num_of_bytes_return as integer, _
  byval BufferID            as integer) as any ptr

declare function XGetAtomName  cdecl alias "XGetAtomName"  ( _
  byval lpDisplay as Display ptr, _
  byval from_atom as ATOM ) as zstring ptr

declare function XGetAtomNames cdecl alias "XGetAtomNames" ( _
  byval lpDisplay    as Display ptr, _
  byref from_atoms   as ATOM       , _
  byval count        as integer    , _
  byref names_return as zstring ptr ptr) as integer

declare function XGetDefault cdecl alias "XGetDefault" ( _
  byval lpDisplay  as Display ptr, _
  byval progname   as string     , _
  byval optionname as string) as zstring ptr
' or NULL
declare function XDisplayName cdecl alias "XDisplayName" ( _
  byval lpString as zstring ptr) as zstring ptr

'The XSynchronize() function returns the previous after function
declare function XSynchronize cdecl alias "XSynchronize" ( _
  byval lpDisplay as Display, _
  byval onoff     as XBoolean) as uinteger ptr

' The specified procedure is called with only a display pointer.
' XSetAfterFunction() returns the previous after function.
declare function XSetAfterFunction cdecl alias "XSetAfterFunction" ( _
  byval lpDisplay as Display ptr) as uinteger ptr

declare function XKeysymToString cdecl alias "XKeysymToString" ( _
  byval keySym as KEYSYM) as zstring ptr

declare function XInternAtom cdecl alias "XInternAtom" ( _
  byval lpDisplay as Display ptr, _
  byval atom_name as string, _
  byval bln_must_exist as XBoolean) as ATOM

declare function XInternAtoms cdecl alias "XInternAtoms" ( _
  byval lpDisplay      as Display ptr    , _
  byval atom_names     as zstring ptr ptr, _
  byval count          as integer        , _
  byval bln_must_exist as XBoolean        , _
  byref atoms_return   as ATOM ptr) as integer

declare function XCopyColormapAndFree cdecl alias "XCopyColormapAndFree"( _
  byval lpDisplay as Display ptr, _
  byval color_map as COLORMAP) as COLORMAP

declare function XCreateColormap cdecl alias "XCreateColormap" ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WindowID   , _
  byval visual    as VISUAL ptr , _
  byval alloc_num as integer) as COLORMAP

declare function XCreatePixmapCursor cdecl alias "XCreatePixmapCursor" ( _
  byval lpDisplay as Display ptr, _
  byval source    as PIXMAP     , _
  byval mask      as PIXMAP     , _
  byref forecolor as XCOLOR     , _
  byref backcolor as XCOLOR     , _
  byval x         as uinteger   , _
  byval y         as integer) as CURSOR

declare function XCreateGlyphCursor cdecl alias "XCreateGlyphCursor" ( _
  byval lpDisplay   as Display , _
  byval sourc_font  as FONT    , _
  byval mask_font   as FONT    , _
  byval source_char as uinteger, _
  byval mask_char   as uinteger, _
  byref forecolor   as XCOLOR  , _
  byref backcolor   as XCOLOR) as integer

declare function XCreateFontCursor cdecl alias "XCreateFontCursor" ( _
  byval lpDisplay as Display ptr, _
  byval shapenr   as uinteger) as CURSOR

declare function XLoadFont cdecl alias "XLoadFont" ( _
  byval lpDisplay as Display ptr, _
  byval font_name as string) as FONT

declare function XCreateGC cdecl alias "XCreateGC" ( _
  byval lpDisplay as Display ptr , _
  byval Drawable  as XID         , _
  byval valuemask as GCVALUEMASKS, _
  byref values    as XGCValues) as GContext

declare function XGContextFromGC cdecl alias "XGContextFromGC" ( _
  byval GC as GCONTEXT) as GCONTEXT

declare sub XFlushGC cdecl alias "XFlushGC" ( _
  byval lpDisplay as any ptr, _
  byval GC        as GContext)

declare function XCreatePixmap cdecl alias "XCreatePixmap" ( _
  byval lpDisplay as Display ptr, _
  byval drawable  as XID        , _
  byval w         as uinteger   , _
  byval h         as uinteger   , _
  byval depth     as uinteger) as PIXMAP

declare function XCreateBitmapFromData cdecl alias "XCreateBitmapFromData" ( _
  byval lpDisplay as Display ptr, _
  byval drawable  as XID        , _
  byval lpData    as any ptr    , _
  byval w         as uinteger   , _
  byval h         as uinteger) as PIXMAP

declare function XCreatePixmapFromBitmapData cdecl alias "XCreatePixmapFromBitmapData" ( _
  byval lpDisplay as Display ptr, _
  byval drawable  as XID        , _
  byval lpData    as any ptr    , _
  byval w         as uinteger   , _
  byval h         as uinteger   , _
  byval fgcolor   as uinteger   , _
  byval bgcolor   as uinteger   , _
  byval depth     as uinteger) as PIXMAP

declare function XGetSelectionOwner cdecl alias "XGetSelectionOwner" ( _
  byval lpDisplay as Display ptr, _
  byval selection as ATOM) as WindowID

declare function XListInstalledColormaps cdecl alias "XListInstalledColormaps" ( _
  byval lpDisplay  as Display ptr, _
  byval hWin       as WindowID   , _
  byref num_return as integer) as COLORMAP ptr

declare function XListProperties cdecl alias "XListProperties" ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WINDOWID   , _
  byref num_prop_return as integer) as ATOM ptr

declare function XListHosts cdecl alias "XListHosts" ( _
  byval lpDisplay     as Display ptr, _
  byref nhosts_return as integer    , _
  byref state_return  as XBoolean) as  XHostAddress ptr

declare function XKeycodeToKeysym cdecl alias "XKeycodeToKeysym" ( _
  byval lpDisplay as Display ptr, _
  byval keycode   as KEYCODE    , _
  byval index     as integer    ) as KEYSYM

declare function XLookupKeysym cdecl alias "XLookupKeysym" ( _
  byref key_event as XKEYEVENT, _
  byval index     as integer) as KEYSYM

declare function XGetKeyboardMapping cdecl alias "XGetKeyboardMapping" ( _
  byval lpDisplay     as Display ptr, _
  byval first_keycode as KEYCODE    , _
  byval keycode_count as integer    , _
  byref keysyms_per_keycode_return as integer) as KEYSYM

declare function XStringToKeysym cdecl alias "XStringToKeysym"         ( _
  byval thestring as string) as KEYSYM

declare function XMaxRequestSize cdecl alias "XMaxRequestSize" ( _
  byval lpDisplay as Display ptr) as integer

declare function XExtendedMaxRequestSize cdecl alias "XExtendedMaxRequestSize" ( _
  byval lpDisplay as Display ptr) as integer

declare function XResourceManagerString cdecl alias "XResourceManagerString"  ( _
  byval lpDisplay as Display ptr) as zstring ptr

declare function XScreenResourceString cdecl alias "XScreenResourceString" ( _
  byref screen as XSCREEN) as zstring ptr

declare function XDisplayMotionBufferSize cdecl alias "XDisplayMotionBufferSize" ( _
  byval lpDisplay as display ptr) as uinteger

declare function XVisualIDFromVisual cdecl alias "XVisualIDFromVisual" ( _
  byval visual as VISUAL ptr) as VISUALID

' multithread routines
declare function XInitThreads   cdecl alias "XInitThreads"   () as integer

declare sub      XLockDisplay   cdecl alias "XLockDisplay"   ( _
  byval lpDisplay as Display ptr)

declare sub      XUnlockDisplay cdecl alias "XUnlockDisplay" ( _
  byval lpDisplay as Display ptr)


' routines for dealing with extensions
declare function XInitExtension cdecl alias "XInitExtension" ( _
  byval lpDisplay as Display ptr,byval name as string) as XExtCodes ptr

declare function XAddExtension cdecl alias "XAddExtension" ( _
  byval lpDisplay as Display ptr) as XExtCodes ptr

'XExtData *XFindOnExtensionList(structure, number)
'      struct _XExtData **structure;
'      int number;
declare function XFindOnExtensionList  cdecl alias "XFindOnExtensionList"  ( _
  byval structure as XExtData ptr ptr, _
  byval number    as integer) as XExtData ptr

declare function XEHeadOfExtensionList cdecl alias "XEHeadOfExtensionList" ( _
  byval object    as XEDataObject) as XExtData ptr ptr

declare function XListFonts cdecl alias "XListFonts" ( _
  byval lpDisplay as Display ptr, _
  byval pattern   as string     , _
  byval maxnames  as integer    , _
  byref actualcount_return as integer) as zstring ptr ptr

declare function XListFontsWithInfo cdecl alias "XListFontsWithInfo" ( _
  byval lpDisplay          as Display ptr, _
  byval pattern            as string     , _
  byval maxnames           as integer    , _
  byref actualcount_return as integer, _
  byref info_return        as XFONTSTRUCT ptr ptr) as zstring ptr ptr

declare function XGetFontPath cdecl alias "XGetFontPath" ( _
  byval lpDisplay     as Display ptr, _
  byref npaths_return as integer) as zstring ptr ptr

' ! must be deallocted with XFreeExtensionList !
declare function XListExtensions cdecl alias "XListExtensions" ( _
  byval lpDisplay         as Display ptr, _
  byval nExtension_return as integer ptr) as zstring ptr ptr


declare function XDefaultRootWindow cdecl alias "XRootWindow" ( _
  byval lpDisplay as Display ptr) as XID

declare function XRootWindow cdecl alias "XRootWindow" ( _
  byval lpDisplay     as Display ptr, _
  byval screen_number as integer) as XID

declare function XDefaultGC cdecl alias "XDefaultGC" ( _
  byval lpDisplay     as Display ptr, _
  byval screen_number as integer) as integer

declare function XBlackPixel cdecl alias "XBlackPixel" ( _
  byval lpDisplay     as Display ptr, _
  byval screen_number as integer) as uinteger

declare function XWhitePixel cdecl alias "XWhitePixel" ( _
  byval lpDisplay     as Display ptr, _
  byval screen_number as integer) as uinteger

'get visual
declare function XDefaultVisual cdecl alias "XDefaultVisual" ( _
  byval lpDisplay     as Display ptr, _
  byval screen_number as integer) as Visual ptr


declare function XAllPlanes cdecl alias "XAllPlanes" () as uinteger

declare function XNextRequest cdecl alias "XNextRequest" ( _
  byval lpDisplay as Display ptr) as uinteger

declare function XServerVendor cdecl alias "XServerVendor" ( _
  byval lpDisplay as Display ptr) as zstring ptr

declare function XDisplayString cdecl alias "XDisplayString" ( _
  byval lpDisplay as Display ptr) as zstring ptr

declare function XDefaultColormap cdecl alias "XDefaultColormap" ( _
  byval lpDisplay as Display ptr,byval screen_number as integer) as Colormap

declare function XDefaultScreenOfDisplay cdecl alias "XDefaultScreenOfDisplay" ( _
  byval lpDisplay as Display ptr) as XScreen ptr

declare function XScreenOfDisplay cdecl alias "XScreenOfDisplay" ( _
  byval lpDisplay      as Display ptr, _
  byval screen_number as integer) as XScreen ptr

'get values of screen
declare function XDefaultDepthOfScreen cdecl alias "XDefaultDepthOfScreen" ( _
  byval lpScreen as XScreen ptr) as integer

declare function XRootWindowOfScreen cdecl alias "XRootWindowOfScreen" ( _
  byval lpScreen as XScreen ptr) as WindowID

declare function XDefaultColormapOfScreen cdecl alias "XDefaultColormapOfScreen" ( _
  byval lpScreen as XScreen ptr) as Colormap

declare function XBlackPixelOfScreen cdecl alias "XBlackPixelOfScreen" ( _
  byval lpScreen as XScreen ptr) as uinteger

declare function XWhitePixelOfScreen cdecl alias "XWhitePixelOfScreen" ( _
  byval lpScreen as XScreen ptr) as uinteger

declare function XDisplayOfScreen cdecl alias "XDisplayOfScreen" ( _
  byval lpScreen as XScreen ptr) as Display ptr

declare function XEventMaskOfScreen cdecl alias "XEventMaskOfScreen" ( _
  byval lpScreen as XScreen ptr) as integer

declare function XScreenNumberOfScreen cdecl alias "XScreenNumberOfScreen" ( _
  byval lpScreen as XScreen ptr) as integer

declare function XDefaultGCOfScreen cdecl alias "XDefaultGCOfScreen" ( _
  byval lpScreen as XScreen ptr) as GContext

declare function XDefaultVisualOfScreen cdecl alias "XDefaultVisualOfScreen" ( _
  byval lpScreen as XScreen ptr) as Visual ptr

declare function XAllocColor cdecl alias "XAllocColor" ( _
  byval lpDisplay  as Display ptr, _
  byval color_map  as Colormap   , _
  byval lpXColor   as XColor ptr) as integer

declare function XAllocNamedColor cdecl alias "XAllocNamedColor" ( _
  byval lpDisplay  as Display ptr, _
  byval color_map  as Colormap   , _
  byval col_name   as string     , _
  byval col_return as XCOLOR ptr , _
  byref exact_def_return as XCOLOR) as integer


declare function XListPixmapFormats  cdecl alias "XListPixmapFormats" ( _
  byval lpDisplay    as Display ptr , _
  byref count_return as integer) as XPixmapFormatValues ptr

declare function XListDepths cdecl alias "XListDepths" ( _
  byval lpDisplay    as Display ptr, _
  byval screen_num   as integer    , _
  byref count_return as integer) as  integer ptr

declare function XIconifyWindow  cdecl alias "XIconifyWindow" ( _
  byval lpDisplay  as Display ptr, _
  byval hWin       as WindowID   , _
  byval screen_num as integer) as integer

declare function XWithdrawWindow cdecl alias "XWithdrawWindow" ( _
  byval lpDisplay  as Display ptr, _
  byval hWin       as WindowID   , _
  byval screen_num as integer) as integer

' char*** argv_return !!!
declare function XGetCommand cdecl alias "XGetCommand" ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WindowID   , _
  byref argv      as zstring ptr ptr, _
  byref argc      as integer) as integer

declare function XReconfigureWMWindow cdecl alias "XReconfigureWMWindow" ( _
  byval lpDisplay  as Display ptr, _
  byval hWin       as WindowID   , _
  byval screen_num as integer    , _
  byval mask       as uinteger   , _
  byref changes    as XWINDOWCHANGES) as integer


declare function XFreeStringList cdecl alias "XFreeStringList" ( _
  byval lplpList as zstring ptr ptr) as integer

declare function XSetTransientForHint  cdecl alias "XSetTransientForHint"  ( _
  byval lpDisplay  as Display ptr, _
  byval hWin       as WindowID   , _
  byval prp_window as WINDOWID) as integer

'The following are given in alphabetical order
declare function XActivateScreenSaver cdecl alias "XActivateScreenSaver" ( _
  byval lpDisplay as Display ptr) as integer

declare function XAddHost cdecl alias "XAddHost" ( _
  byval lpDisplay as Display ptr, _
  byref host      as XHOSTADDRESS) as integer

declare function XAddHosts cdecl alias "XAddHosts" ( _
  byval lpDisplay as Display ptr, _
  byref hosts     as XHOSTADDRESS, _
  byval num_hosts as integer) as integer

declare function XAddToSaveSet cdecl alias "XAddToSaveSet" ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WindowID) as integer

declare function XAddToExtensionList cdecl alias "XAddToExtensionList" ( _
  byval lplpExtData as any ptr ptr, _
  byval   lpExtData as any ptr) as integer

declare function XAllocColorCells cdecl alias "XAllocColorCells" ( _
  byval lpDisplay          as Display ptr, _
  byval color_map          as COLORMAP   , _
  byval config             as XBoolean    , _
  byref plane_masks_return as uinteger, _
  byval nplans             as uinteger, _
  byref pixels_return      as uinteger, _
  byval npixel             as uinteger) as integer

declare function XAllocColorPlanes cdecl alias "XAllocColorPlanes" ( _
  byval lpDisplay     as Display ptr, _
  byval color_map     as COLORMAP   , _
  byval config        as XBoolean    , _
  byref pixels_return as uinteger   , _
  byval ncolors       as integer    , _
  byval nreds         as integer    , _
  byval ngreens       as integer    , _
  byval nblues        as integer    , _
  byref rmask_ret     as uinteger   , _
  byref gmask_ret     as uinteger   , _
  byref bmask_ret     as uinteger) as integer

declare function XAllowEvents    cdecl alias "XAllowEvents"    ( _
  byval lpDisplay  as Display ptr, _
  byval event_mode as integer    , _
  byval t          as XTIME) as integer

declare function XAutoRepeatOff  cdecl alias "XAutoRepeatOff"  ( _
  byval lpDisplay as Display ptr) as integer

declare function XAutoRepeatOn   cdecl alias "XAutoRepeatOn"   ( _
  byval lpDisplay as Display ptr) as integer

declare function XBell           cdecl alias "XBell"           ( _
  byval lpDisplay as Display ptr, _
  byval percent   as integer) as integer

declare function XBitmapBitOrder cdecl alias "XBitmapBitOrder" ( _
  byval lpDisplay as Display ptr) as integer

declare function XBitmapPad      cdecl alias "XBitmapPad"      ( _
  byval lpDisplay as Display ptr) as integer

declare function XBitmapUnit     cdecl alias "XBitmapUnit"     ( _
  byval lpDisplay as Display ptr) as integer

declare function XCellsOfScreen  cdecl alias "XCellsOfScreen" ( _
  byval lpDisplay as Display ptr, _
  byval lpScreen  as XSCREEN) as integer

declare function XChangeActivePointerGrab cdecl alias "XChangeActivePointerGrab" ( _
  byval lpDisplay  as Display ptr, _
  byval event_mask as uinteger, _
  byval cursor     as CURSOR, _
  byval t          as XTIME) as integer

declare function XChangeGC cdecl alias "XChangeGC" ( _
  byval lpDisplay as Display ptr, _
  byval GC        as GCONTEXT   , _
  byval valuemask as GCVALUEMASKS, _
  byref values    as XGCVALUES) as integer

declare function XChangeKeyboardControl cdecl alias "XChangeKeyboardControl" ( _
  byval lpDisplay  as Display ptr, _
  byval value_mask as uinteger   , _
  byref values     as XKEYBOARDCONTROL) as integer

declare function XChangeKeyboardMapping cdecl alias "XChangeKeyboardMapping" ( _
  byval lpDisplay           as Display ptr, _
  byval first_keycode       as integer    , _
  byval keysyms_per_keycode as integer    , _
  byref keysmys             as KEYSYM     , _
  byval num_codes           as integer) as integer

declare function XChangePointerControl cdecl alias "XChangePointerControl" ( _
  byval lpDisplay         as Display ptr, _
  byval do_accel          as XBoolean, _
  byval do_threshold      as XBoolean, _
  byval accel_numerator   as integer, _
  byval accel_denominator as integer, _
  byval threshold         as integer) as integer

declare function XChangeProperty cdecl alias "XChangeProperty" ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WINDOWID   , _
  byval property  as ATOM       , _
  byval typ       as ATOM       , _
  byval format    as integer    , _
  byval mode      as integer    , _
  byval lpdatat   as any ptr    , _
  byval nitems    as integer) as integer

declare function XChangeSaveSet cdecl alias "XChangeSaveSet" ( _
  byval lpDisplay   as Display ptr, _
  byval hWin        as WINDOWID   , _
  byval change_mode as integer) as integer

declare function XCheckMaskEvent cdecl alias "XCheckMaskEvent" ( _
  byval lpDisplay    as Display ptr, _
  byval event_mask   as integer    , _
  byref event_return as XEVENT) as XBoolean

declare function XCheckTypedEvent cdecl alias "XCheckTypedEvent" ( _
  byval lpDisplay    as Display ptr, _
  byval event_type   as integer    , _
  byref event_return as XEVENT     ) as XBoolean

declare function XCheckTypedWindowEvent cdecl alias "XCheckTypedWindowEvent" ( _
  byval lpDisplay    as Display ptr, _
  byval hWin         as WINDOWID   , _
  byval event_type   as integer    , _
  byref event_return as XEVENT     ) as XBoolean


declare function XCheckWindowEvent cdecl alias "XCheckWindowEvent" ( _
  byval lpDisplay    as Display ptr, _
  byval hWin         as WINDOWID   , _
  byval event_mask   as integer    , _
  byref event_return as XEVENT) as XBoolean

declare function XCirculateSubwindows cdecl alias "XCirculateSubwindows" ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WINDOWID   , _
  byval direction as integer) as integer

declare function XCirculateSubwindowsDown cdecl alias "XCirculateSubwindowsDown" ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WINDOWID) as integer

declare function XCirculateSubwindowsUp cdecl alias "XCirculateSubwindowsUp" ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WINDOWID) as integer

declare function XClearArea cdecl alias "XClearArea" ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WINDOWID   , _
  byval x         as integer    , _
  byval y         as integer    , _
  byval w         as uinteger   , _
  byval h         as uinteger   , _
  byval exposure  as XBoolean    ) as XBoolean

declare function XClearWindow cdecl alias "XClearWindow" ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WindowID) as integer

declare function XCloseDisplay cdecl alias "XCloseDisplay" ( _
  byval lpDisplay as Display ptr) as integer

declare function XConfigureWindow  cdecl alias "XConfigureWindow" ( _
  byval lpDisplay  as Display ptr, _
  byval hWin       as WindowID   , _
  byval value_mask as integer    , _
  byref changes    as XWINDOWCHANGES) as integer

declare function XConnectionNumber  cdecl alias "XConnectionNumber"  ( _
  byval lpDisplay as Display ptr) as integer

declare function XConvertSelection cdecl alias "XConvertSelection" ( _
  byval lpDisplay as Display ptr, _
  byval selection as ATOM       , _
  byval target    as ATOM       , _
  byval property  as ATOM       , _
  byval requester as WindowID   , _
  byval t         as XTIME) as integer

declare function XCopyArea cdecl alias "XCopyArea" ( _
  byval lpDisplay as Display ptr, _
  byval scr       as DRAWABLE   , _
  byval des       as DRAWABLE   , _
  byval GC        as GCONTEXT   , _
  byval src_x     as integer    , _
  byval src_y     as integer    , _
  byval w         as uinteger   , _
  byval h         as uinteger   , _
  byval des_x     as integer    , _
  byval des_y     as integer) as integer

declare function XCopyGC cdecl alias "XCopyGC" ( _
  byval lpDisplay as Display ptr, _
  byval src_gc    as GCONTEXT   , _
  byval valuemask as uinteger   , _
  byval des_gc    as GCONTEXT) as integer

declare function XCopyPlane cdecl alias "XCopyPlane"( _
  byval lpDisplay as Display ptr, _
  byval scr       as DRAWABLE, _
  byval des       as DRAWABLE, _
  byval GC        as GCONTEXT,_
  byval src_x     as integer , _
  byval src_y     as integer , _
  byval w         as uinteger, _
  byval height    as uinteger, _
  byval des_x     as integer , _
  byval des_y     as integer , _
  byval plane     as uinteger) as integer

declare function XDefaultDepth cdecl alias "XDefaultDepth" ( _
  byval lpDisplay     as Display ptr, _
  byval screen_number as integer) as integer

declare function XDefineCursor cdecl alias "XDefineCursor" ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WindowID   , _
  byval cursor    as Cursor) as integer

declare function XDeleteProperty cdecl alias "XDeleteProperty"  ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WindowID   , _
  byval property  as Atom) as integer

declare function XDefaultScreen cdecl alias "XDefaultScreen" ( _
  byval lpDisplay as Display ptr) as integer

declare function XDisplayHeight cdecl alias "XDisplayHeight" ( _
  byval lpDisplay     as Display ptr, _
  byval screen_number as integer) as integer

declare function XDisplayWidth cdecl alias "XDisplayWidth" ( _
  byval lpDisplay     as Display ptr, _
  byval screen_number as integer) as integer

declare function XDestroyWindow     cdecl alias "XDestroyWindow"     ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WindowID) as integer

declare function XDestroySubwindows cdecl alias "XDestroySubwindows" ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WindowID) as integer

declare function XDisableAccessControl cdecl alias "XDisableAccessControl" ( _
  byval lpDisplay as Display ptr) as integer

declare function XDisplayCells cdecl alias "XDisplayCells" ( _
  byval lpDisplay     as Display ptr, _
  byval screen_number as integer) as integer

declare function XDisplayHeightMM   cdecl alias "XDisplayHeightMM" ( _
  byval lpDisplay     as Display ptr, _
  byval screen_number as integer) as integer

declare function XDisplayKeycodes   cdecl alias "XDisplayKeycodes" ( _
  byval lpDisplay      as Display ptr, _
  byref min_key_return as integer    , _
                                                                      byref max_keyc_return as integer)  as integer
declare function XDisplayPlanes     cdecl alias "XDisplayPlanes" ( _
  byval lpDisplay     as Display ptr, _
  byval screen_number as integer) as integer

declare function XDisplayWidthMM    cdecl alias "XDisplayWidthMM" ( _
  byval lpDisplay     as Display ptr, _
  byval screen_number as integer) as integer

declare function XDrawImageString   cdecl alias "XDrawImageString"   ( _
  byval lpDisplay as Display ptr, _
  byval Drawable  as XID        , _
  byval GC        as GContext   , _
  byval x         as integer    , _
  byval y         as integer    , _
  byval text      as string     , _
  byval length    as integer    ) as integer

declare function XDrawString cdecl alias "XDrawString" ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as XID        , _
  byval GC        as GContext   , _
  byval x         as integer    , _
  byval y         as integer    , _
  byval Text      as string     , _
  byval length    as integer) as integer

declare function XDoesBackingStore cdecl alias "XDoesBackingStore" ( _
  byval lpScreen as XScreen ptr) as integer

declare function XDoesSaveUnders cdecl alias "XDoesSaveUnders" ( _
  byval lpScreen as XScreen ptr) as XBoolean

declare function XEnableAccessControl cdecl alias "XEnableAccessControl" ( _
  byval lpDisplay as Display ptr) as integer

declare function XEventsQueued cdecl alias "XEventsQueued" ( _
  byval lpDisplay as Display ptr, _
  byval mode      as integer) as integer

declare function XFetchName cdecl alias "XFetchName" ( _
  byval lpDisplay   as Display ptr, _
  byval hWin        as WINDOWID, _
  byval name_return as zstring ptr ptr) as integer

'Drawing
declare function XDrawRectangle cdecl alias "XDrawRectangle" ( _
  byval lpDisplay as Display ptr, _
  byval Drawable  as XID        , _
  byval GC        as GContext   , _
  byval x         as integer    , _
  byval y         as integer    , _
  byval w         as integer    , _
  byval h         as integer) as integer

declare function XDrawRectangles cdecl alias "XDrawRectangles" ( _
  byval lpDisplay   as Display ptr, _
  byval Drawable    as XID        , _
  byval GC          as GContext   , _
  byref rectangles  as XRectangle , _
  byval nrectangles as integer    ) as integer

declare function XDrawSegments cdecl alias "XDrawSegments" ( _
  byval lpDisplay as Display ptr, _
  byval Drawable  as XID        , _
  byval GC        as GContext   , _
  byref segments  as XSegment   , _
  byval nsegments as integer) as integer

declare function XFillArc cdecl alias "XFillArc" ( _
  byval lpDisplay as Display ptr, _
  byval Drawable  as XID        , _
  byval GC        as GContext   , _
  byval x         as integer    , _
  byval y         as integer    , _
  byval w         as integer    , _
  byval h         as integer    , _
  byval angle1    as integer    , _
  byval angle2    as integer) as integer

declare function XFillArcs cdecl alias "XFillArcs" ( _
  byval lpDisplay as Display ptr, _
  byval Drawable  as XID     , _
  byval GC        as GContext, _
  byref arcs      as XArc    , _
  byval narcs     as integer) as integer

declare function XFillPolygon cdecl alias "XFillPolygon" ( _
  byval lpDisplay as Display ptr, _
  byval Drawable  as XID        , _
  byval GC        as GContext   , _
  byref points    as XPoint     , _
  byval npoints   as integer    , _
  byval shape     as integer    , _
  byval mode      as integer) as integer

declare function XFillRectangle  cdecl alias "XFillRectangle" ( _
  byval lpDisplay as Display ptr, _
  byval Drawable  as XID        , _
  byval GC        as GContext   , _
  byval x         as integer    , _
  byval y         as integer    , _
  byval w         as integer    , _
  byval h         as integer) as integer

declare function XFillRectangles cdecl alias "XFillRectangles" ( _
  byval lpDisplay   as Display ptr, _
  byval Drawable    as XID        , _
  byval GC          as GContext   , _
  byref rectangles  as XRectangle , _
  byval nrectangles as integer    ) as integer

declare function XDrawArc cdecl alias "XDrawArc" ( _
  byval lpDisplay as Display ptr, _
  byval Drawable  as XID        , _
  byval GC        as GContext   , _
  byval x         as integer    , _
  byval y         as integer    , _
  byval w         as integer    , _
  byval h         as integer    , _
  byval angle1    as integer    , _
  byval angle2    as integer) as integer

declare function XDrawArcs cdecl alias "XDrawArcs" ( _
  byval lpDisplay as Display ptr, _
  byval Drawable  as XID        , _
  byref arcs      as XArc       , _
  byval narcs     as integer) as integer

declare function XDrawLine cdecl alias "XDrawLine" ( _
  byval lpDisplay as Display ptr, _
  byval Drawable  as XID        , _
  byval GC        as GContext   , _
  byval x1        as integer    , _
  byval y1        as integer    , _
  byval x2        as integer    , _
  byval y2        as integer) as integer

declare function XDrawLines  cdecl alias "XDrawLines" ( _
  byval lpDisplay as Display ptr, _
  byval Drawable  as XID, _
  byval GC        as GContext, _
  byref points    as XPoint, _
  byval npoints   as integer, _
  byval mode      as integer) as integer

declare function XDrawPoint  cdecl alias "XDrawPoint"  ( _
  byval lpDisplay as Display ptr, _
  byval Drawable  as XID        , _
  byval GC        as GContext   , _
  byval x         as integer    , _
  byval y         as integer) as integer

declare function XDrawPoints cdecl alias "XDrawPoints" ( _
  byval lpDisplay as Display ptr, _
  byval Drawable  as XID        , _
  byval GC        as GContext   , _
  byref points    as XPoint     , _
  byval npoints   as integer    , _
  byval mode      as integer    ) as integer

declare function XFlush cdecl alias "XFlush" ( _
  byval lpDisplay as Display ptr) as integer

declare function XFree cdecl alias "XFree" ( _
  byval lpAny     as any ptr) as integer

declare function XFreeGC cdecl alias "XFreeGC" ( _
  byval lpDisplay as Display ptr, _
  byval GC        as GContext) as integer

'mode = ScreenSaverActive or ScreenSaverReset
declare function XForceScreenSaver cdecl alias "XForceScreenSaver" ( _
  byval lpDisplay as Display ptr, _
  byval mode      as integer) as integer

declare function XFreeColormap cdecl alias "XFreeColormap" ( _
  byval lpDisplay as Display ptr, _
  byval colormap  as COLORMAP) as integer

declare function XFreeColors cdecl alias "XFreeColors" ( _
  byval lpDisplay as Display ptr, _
  byval colormap  as COLORMAP   , _
  byref pixels    as uinteger   , _
  byval npixels   as integer    , _
  byval planes    as uinteger   ) as integer

declare function XFreeCursor cdecl alias "XFreeCursor" ( _
  byval lpDisplay as Display ptr, _
  byval cursor    as CURSOR) as integer

declare function XFreeFont cdecl alias "XFreeFont" ( _
  byval lpDisplay as Display ptr    , _
  byval lpFont    as XFontStruct ptr) as integer

declare function XFreeExtensionList cdecl alias "XFreeExtensionList" ( _
  byval lplpList as zstring ptr ptr) as integer

declare function XFreeFontNames cdecl alias "XFreeFontNames" ( _
  byval lplpList as zstring ptr ptr) as integer

declare function XFreeFontPath cdecl alias "XFreeFontPath" ( _
  byval lplpList as zstring ptr ptr) as integer

declare function XFreeFontInfo cdecl alias "XFreeFontInfo" ( _
  byval lplpNames   as zstring ptr ptr, _
  byref free_infos  as XFontStruct    , _
  byval atual_count as integer        ) as integer

declare function XFreeModifiermap cdecl alias "XFreeModifiermap" ( _
  byref modmap as XModifierKeymap) as integer

declare function XFreePixmap cdecl alias "XFreePixmap" ( _
  byval lpDisplay as Display ptr, _
  byval pixmap    as PIXMAP     ) as integer

declare function XGeometry cdecl alias "XGeometry" ( _
  byval lpDisplay        as Display ptr, _
  byval screen_num       as integer, _
  byval position         as string     , _
  byval default_position as string, _
  byval bwidth           as uinteger   , _
  byval fwidth           as uinteger, _
  byval fheight          as uinteger, _
  byval xadder           as integer    , _
  byval yaddrt           as integer, _
  byref x_return         as integer    , _
  byref y_return         as integer, _
  byref width_return     as integer    , _
  byref height_return    as integer ) as integer

declare function XGetErrorDatabaseText cdecl alias "XGetErrorDatabaseText" ( _
  byval lpDisplay      as Display ptr, _
  byval name           as string     , _
  byval message        as string     , _
  byval default_string as string     , _
  byref buffer_return  as zstring ptr, _
  byval length         as integer    ) as integer

declare function XGetErrorText cdecl alias "XGetErrorText" ( _
  byval lpDisplay     as Display ptr, _
  byval code          as integer    , _
  byval buffer_return as string, _
  byval length        as integer) as integer

declare function XGetFontProperty cdecl alias "XGetFontProperty" ( _
  byref font_struct  as XFONTSTRUCT, _
  byval property     as ATOM       , _
  byref value_return as uinteger   ) as XBoolean

declare function XGetGCValues cdecl alias "XGetGCValues" ( _
  byval lpDisplay     as Display ptr , _
  byval gc            as GCONTEXT    , _
  byval vlauemask     as GCVALUEMASKS, _
  byref values_return as XGCVALUES   ) as integer

declare function  XGetGeometry cdecl alias "XGetGeometry" ( _
  byval lpDisplay       as Display ptr, _
  byval d               as DRAWABLE   , _
  byval hWin            as WINDOWID   , _
  byref x_return        as integer    , _
  byref y_return        as integer    , _
  byref width_return    as uinteger   , _
  byref height_return   as uinteger   , _
  byref borderwidth_return as uinteger, _
  byref depth_return as uinteger) as integer

declare function XGetIconName cdecl alias "XGetIconName" ( _
  byval lpDisplay       as Display ptr, _
  byval hWin            as WINDOWID   , _
  byref iconname_return as zstring ptr ptr) as integer

declare function XGetInputFocus cdecl alias "XGetInputFocus" ( _
  byval lpDisplay        as Display ptr, _
  byval hWin             as WINDOWID   , _
  byref revert_to_return as integer) as integer

declare function XGetKeyboardControl cdecl alias "XGetKeyboardControl" ( _
  byval lpDisplay     as Display ptr, _
  byref values_return as XKEYBOARDSTATE) as integer

declare function XGetPointerControl cdecl alias "XGetPointerControl" ( _
  byval lpDisplay                as Display ptr, _
  byref accel_numerator_return   as integer, _
  byref accel_denominator_return as integer, _
  byref threshold_return         as integer) as integer

declare function XGetPointerMapping cdecl alias "XGetPointerMapping" ( _
  byval lpDisplay  as Display ptr, _
  byref map_return as ubyte ptr  , _
  byval nmap       as integer    ) as integer

declare function XGetScreenSaver cdecl alias "XGetScreenSaver" ( _
  byval lpDisplay              as Display ptr, _
  byref timeout_return         as integer, _
  byref interval_return        as integer, _
  byref prefer_blanking_return as integer, _
  byref allow_exposures_return as integer) as integer

declare function XGetTransientForHint cdecl alias "XGetTransientForHint" ( _
  byval lpDisplay          as Display ptr, _
  byval hWin               as WINDOWID   , _
  byref prop_window_return as WINDOWID) as integer

declare function XGetWindowProperty cdecl alias "XGetWindowProperty" ( _
  byval lpDisplay            as Display ptr, _
  byval hWin                 as WINDOWID   , _
  byval property             as ATOM       , _
  byval offset               as integer    , _
  byval length               as integer    , _
  byval _delete              as XBoolean    , _
  byval req_type             as ATOM       , _
  byref actual_type_return   as ATOM       , _
  byref actual_format_return as integer    , _
  byref nitems_return        as uinteger   , _
  byref bytes_after_return   as uinteger   , _
  byref prop_return          as ubyte ptr ptr) as integer

declare function XGrabButton cdecl alias "XGrabButton" ( _
  byval lpDisplay     as Display ptr, _
  byval button        as uinteger   , _
  byval modifiers     as uinteger   , _
  byval grab_hWin     as WINDOWID   , _
  byval owner_events  as XBoolean    , _
  byval event_mask    as uinteger   , _
  byval pointer_mode  as integer    , _
  byval keyboard_mode as integer    , _
  byval confine_to    as WINDOWID   , _
  byval cursor        as CURSOR) as integer

declare function XGrabKey cdecl alias "XGrabKey" ( _
  byval lpDisplay     as Display ptr, _
  byval key_code      as integer    , _
  byval modifiers     as uinteger   , _
  byval grab_hWin     as WINDOWID   , _
  byval owner_events  as XBoolean    , _
  byval pointer_mode  as integer    , _
  byval keyboard_mode as integer) as integer

declare function XGrabKeyboard cdecl alias "XGrabKeyboard" ( _
  byval lpDisplay     as Display ptr, _
  byval grab_hWin     as WINDOWID   , _
  byval owner_events  as XBoolean    , _
  byval pointer_mode  as integer    , _
  byval keyboard_mode as integer    , _
  byval t             as XTIME) as integer

declare function XGrabPointer cdecl alias "XGrabPointer" ( _
  byval lpDisplay     as Display ptr, _
  byval grab_hWin     as WINDOWID   , _
  byval owner_events  as XBoolean    , _
  byval event_mask    as  uinteger  , _
  byval pointer_mode  as integer    , _
  byval keyboard_mode as integer    , _
  byval confine_to    as WINDOWID   , _
  byval cursor        as CURSOR     , _
  byval t             as XTIME) as integer

declare function XGrabServer cdecl alias "XGrabServer" ( _
  byval lpDisplay  as Display ptr) as integer

declare function XHeightMMOfScreen cdecl alias "XHeightMMOfScreen" ( _
  byval lpscreen as XSCREEN ptr) as integer

declare function XHeightOfScreen cdecl alias "XHeightOfScreen" ( _
  byval lpscreen as XSCREEN ptr) as integer

declare function XIfEvent cdecl alias "XIfEvent" ( _
  byval lpDisplay    as Display ptr, _
  byref event_return as XEVENT     , _
  byval predicate    as function cdecl ( _
    byval lpDisplay  as Display ptr, _
    byref event      as XEVENT     , _
    byval arg        as XPOINTER) as XBoolean , _
  byval arg          as XPOINTER) as integer


declare function XInstallColormap cdecl alias "XInstallColormap" ( _
  byval lpDisplay as Display ptr, _
  byval color_map as COLORMAP) as integer

declare function XKeysymToKeycode cdecl alias "XKeysymToKeycode" ( _
  byval lpDisplay as Display ptr, _
  byval ks        as KEYSYM) as KEYCODE

declare function XKillClient cdecl alias "XKillClient" ( _
  byval lpDisplay  as Display ptr, _
  byval resourceid as XID) as integer

declare function XLookupColor cdecl alias "XLookupColor" ( _
  byval lpDisplay     as Display ptr, _
  byval color_map     as COLORMAP   , _
  byval color_name    as string     , _
  byref exact_return  as XCOLOR     , _
  byref screen_return as XCOLOR) as integer

'X Server
declare function XOpenDisplay      cdecl alias "XOpenDisplay" ( _
  byval as string = "") as Display ptr

declare function XProtocolRevision cdecl alias "XProtocolRevision" ( _
  byval lpDisplay as Display ptr) as integer

declare function XProtocolVersion  cdecl alias "XProtocolVersion" ( _
  byval lpDisplay as Display ptr) as integer

declare function XLastKnownRequestProcessed cdecl alias "XLastKnownRequestProcessed" ( _
  byval lpDisplay as Display ptr) as uinteger

declare function XSync cdecl alias "XSync" ( _
  byval lpDisplay as Display ptr, _
  byval discard   as XBoolean) as integer

'### Window section ###
declare function XCreateSimpleWindow cdecl alias "XCreateSimpleWindow" ( _
  byval lpDisplay     as Display ptr, _
  byval parentwin     as WindowID   , _
  byval x             as integer    , _
  byval y             as integer    , _
  byval w             as integer    , _
  byval h             as integer    , _
  byval border_width  as integer    , _
  byval border_pixel  as uinteger   , _
  byval bground_pixel as uinteger ) as WindowID

declare function XCreateWindow cdecl alias "XCreateWindow" ( _
  byval lpDisplay    as Display ptr, _
  byval hRoot        as WindowID   , _
  byval x            as integer    , _
  byval y            as integer    , _
  byval w            as integer    , _
  byval h            as integer    , _
  byval border_width as integer    , _
  byval depth        as integer    , _
  byval class        as WINDOWCLASSES, _
  byval visual       as VISUAL ptr   , _
  byval valuemask    as WINDOWATTRIBUTEMASKS, _
  byref window_atb   as XSETWINDOWATTRIBUTES) as WindowID

declare function XChangeWindowAttributes cdecl alias "XChangeWindowAttributes" ( _
  byval lpDisplay      as Display ptr, _
  byval hWin           as WindowID   , _
  byval valuemask      as WINDOWATTRIBUTEMASKS, _
  byref new_attributes as XSETWINDOWATTRIBUTES) as integer

declare function XGetWindowAttributes cdecl alias "XGetWindowAttributes" ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WindowID   , _
  byval attribute as XWINDOWATTRIBUTES ptr) as integer

declare function XStoreName cdecl alias "XStoreName" ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WindowID   , _
  byval Caption   as string) as integer

declare function XMapRaised cdecl alias "XMapRaised" ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WindowID) as integer

declare function XMapWindow cdecl alias "XMapWindow" ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WindowID) as integer

declare function XMapSubwindows cdecl alias "XMapSubwindows" ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WindowID) as integer

declare function XLowerWindow cdecl alias "XLowerWindow" ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WindowID) as integer

declare function XRaiseWindow cdecl alias "XRaiseWindow" ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WindowID   ) as integer

declare function XMoveWindow cdecl alias "XMoveWindow" ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WindowID   , _
  byval x         as integer    , _
  byval y         as integer) as integer

declare function XResizeWindow cdecl alias "XResizeWindow" ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WindowID   , _
  byval w         as integer    , _
  byval h         as integer) as integer

declare function XMoveResizeWindow cdecl alias "XMoveResizeWindow" ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WindowID   , _
  byval x         as integer    , _
  byval y         as integer    , _
  byval w         as uinteger   , _
  byval h         as uinteger) as integer

declare function XSetForeground cdecl alias "XSetForeground" ( _
  byval lpDisplay as Display ptr, _
  byval GC        as GContext   , _
  byval fg        as uinteger) as integer

declare function XSetBackground cdecl alias "XSetBackground" ( _
  byval lpDisplay as Display ptr, _
  byval GC        as GContext   , _
  byval bg        as uinteger) as integer

declare function XSetLineAttributes cdecl alias "XSetLineAttributes"( _
  byval lpDisplay  as Display ptr, _
  byval GC         as GContext, _
  byval line_width as uinteger, _
  byval line_style as integer , _
  byval cap_style  as integer , _
  byval join_style as integer) as integer

declare function XSetFillStyle cdecl alias "XSetFillStyle" ( _
  byval lpDisplay  as Display ptr, _
  byval GC         as GContext   , _
  byval fill_style as integer) as integer

'Set / Register EventType
declare function XSelectInput cdecl alias "XSelectInput" ( _
  byval lpDisplay  as Display ptr, _
  byval hWin       as Windowid, _
  byval event_mask as EVENTMASKS) as integer

'Wait and Get Next Event
declare function XNextEvent cdecl alias "XNextEvent"         ( _
  byval lpDisplay    as Display ptr, _
  byref event_return as XEVENT) as integer

'Try to Get Event
declare function XPending cdecl alias "XPending" ( _
  byval lpDisplay as Display ptr) as integer

'Put Event Back
declare function XPutBackEvent cdecl alias "XPutBackEvent" ( _
  byval lpDisplay    as Display ptr, _
  byref event_to_put as XEVENT) as integer

declare function XMaskEvent cdecl alias "XMaskEvent" ( _
  byval lpDisplay    as Display ptr, _
  byval event_mask   as integer    , _
  byref event_return as XEVENT) as integer

declare function XMaxCmapsOfScreen cdecl alias "XMaxCmapsOfScreen" ( _
  byval lpscreen as XSCREEN) as integer

declare function XMinCmapsOfScreen cdecl alias "XMinCmapsOfScreen" ( _
  byval lpscreen as XSCREEN) as integer

declare function XNoOp cdecl alias "XNoOp" ( _
  byval lpDisplay as Display ptr) as integer

declare function XParseColor cdecl alias "XParseColor" ( _
  byval lpDisplay as Display ptr, _
  byval color_map as COLORMAP   , _
  byval spec      as byte ptr   , _
  byref exact_def_return as XCOLOR) as integer

declare function XParseGeometry cdecl alias "XParseGeometry" ( _
  byval parsestring   as string , _
  byref x_return      as integer, _
  byref y_return      as integer, _
  byref width_return  as uinteger, _
  byref height_return as uinteger ) as integer

declare function XPeekEvent cdecl alias "XPeekEvent" ( _
  byval lpDisplay    as Display ptr, _
  byref event_return as XEVENT) as integer

declare function XPeekIfEvent cdecl alias "XPeekIfEvent" ( _
  byval lpDisplay as Display ptr, _
  byref event_return as XEVENT  , _
  byval predicate as function cdecl ( _
    byval lpDisplay as Display ptr, _
    byref event     as XEVENT     , _
    byval arg       as XPOINTER) as XBoolean , _
  byval arg as XPOINTER) as integer

declare function XPlanesOfScreen cdecl alias "XPlanesOfScreen" ( _
  byval lpScreen as XSCREEN ptr) as integer

declare function XQLength cdecl alias "XQLength" ( _
  byval lpDisplay as Display ptr) as integer

declare function XQueryBestCursor cdecl alias "XQueryBestCursor" ( _
  byval lpDisplay as Display ptr, _
  byval d         as DRAWABLE   , _
  byval w         as uinteger   , _
  byval h         as uinteger   , _
  byref w_return  as uinteger   , _
  byref h_return  as uinteger) as integer

declare function XQueryBestSize cdecl alias "XQueryBestSize" ( _
  byval lpDisplay    as Display ptr, _
  byval class        as integer    , _
  byval which_screen as DRAWABLE   , _
  byval w            as uinteger   , _
  byval h            as uinteger   , _
  byref w_return     as uinteger   , _
  byref h_return     as uinteger) as integer

declare function XQueryBestStipple cdecl alias "XQueryBestStipple" ( _
  byval lpDisplay     as Display ptr, _
  byval which_screen  as DRAWABLE   , _
  byval w             as uinteger   , _
  byval h             as uinteger   , _
  byref width_return  as uinteger   , _
  byref height_return as uinteger) as integer

declare function XQueryBestTile cdecl alias "XQueryBestTile" ( _
  byval lpDisplay     as Display ptr, _
  byval which_screen  as DRAWABLE   , _
  byval width         as uinteger   , _
  byval height        as uinteger   , _
  byref width_return  as uinteger   , _
  byref height_return as uinteger) as integer

declare function XQueryColor  cdecl alias "XQueryColor" ( _
  byval lpDisplay  as Display ptr, _
  byval color_map  as COLORMAP   , _
  byref def_in_out as XCOLOR     ) as integer

declare function XQueryColors cdecl alias "XQueryColors" ( _
  byval lpDisplay   as Display ptr, _
  byval color_map   as COLORMAP   , _
  byref defs_in_out as XCOLOR     , _
  byval ncolors     as integer    ) as integer


declare function XQueryExtension cdecl alias "XQueryExtension" ( _
  byval lpDisplay           as Display ptr     , _
  byval ExtName             as string, _
  byref major_opcode_return as integer, _
  byref first_event_return  as integer, _
  byref first_error_return  as integer) as XBoolean

declare function XQueryKeymap cdecl alias "XQueryKeymap" ( _
  byval lpDisplay        as Display ptr, _
  byref keys_in_array32_return as byte) as integer

declare function XQueryPointer cdecl alias "XQueryPointer" ( _
  byval lpDisplay        as Display ptr, _
  byval hWin             as WINDOWID   , _
  byref hRootWin_return  as WINDOWID   , _
  byref hChildWin_return as WINDOWID   , _
  byref root_x_return    as integer    , _
  byref root_y_return    as integer    , _
  byref win_x_return     as integer    , _
  byref win_y_return     as integer    , _
  byref mask_return      as uinteger) as XBoolean

declare function XQueryTextExtents cdecl alias "XQueryTextExtents" ( _
  byval lpDisplay           as Display ptr, _
  byval fontid              as XID        , _
  byval strarg              as string     , _
  byval nchars              as integer    , _
  byref direction_return    as integer    , _
  byref font_ascent_return  as integer    , _
  byref font_descent_return as integer    , _
  byref overall_return      as XCHARSTRUCT) as integer

declare function XQueryTextExtents16 cdecl alias "XQueryTextExtents16" ( _
  byval lpDisplay           as Display ptr, _
  byval fontid              as XID        , _
  byval strarg              as XCHAR2b    , _
  byval nchars              as integer    , _
  byref direction_return    as integer    , _
  byref font_ascent_return  as integer    , _
  byref font_descent_return as integer    , _
  byref overall_return      as XCHARSTRUCT) as integer

declare function XQueryTree cdecl alias "XQueryTree" ( _
  byval lpDisplay       as Display ptr, _
  byval hWin            as WINDOWID   , _
  byref hRootWin_return as WINDOWID   , _
  byref hParentWin_return as WINDOWID , _
  byref hWinChildsWins    as WINDOWID ptr ptr, _
  byref xchilds_return    as uinteger) as integer

declare function XReadBitmapFile cdecl alias "XReadBitmapFile" ( _
  byval lpDisplay as Display ptr , _
  byval d         as DRAWABLE    , _
  byval filename  as string      , _
  byref width_return as uinteger , _
  byref height_return as uinteger, _
  byref bitmap_return as PIXMAP  , _
  byref x_hot_return  as integer , _
  byref y_hot_return  as integer) as integer

declare function XReadBitmapFileData cdecl alias "XReadBitmapFileData" ( _
  byval filename       as string   , _
  byref width_return   as uinteger , _
  byref height_return  as uinteger , _
  byref lpdatat_return as ubyte ptr, _
  byref x_hot_return   as integer  , _
  byref y_hot_return   as integer) as integer

declare function XRebindKeysym cdecl alias "XRebindKeysym" ( _
  byval lpDisplay as Display ptr, _
  byval keysym    as KEYSYM     , _
  byref list      as KEYSYM ptr , _
  byval mod_count as integer    , _
  byval strarg    as ubyte ptr  , _
  byval bytes_string as integer) as integer

declare function XRecolorCursor cdecl alias "XRecolorCursor" ( _
  byval lpDisplay         as Display ptr, _
  byval cursor            as CURSOR     , _
  byref foreground_return as XCOLOR     , _
  byref background_return as XCOLOR) as integer

declare function XRefreshKeyboardMapping cdecl alias "XRefreshKeyboardMapping" ( _
  byref event_map as XMAPPINGEVENT) as integer

declare function XRemoveFromSaveSet cdecl alias "XRemoveFromSaveSet" ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WINDOWID) as integer

declare function XRemoveHost cdecl alias "XRemoveHost" ( _
  byval lpDisplay as Display ptr, _
  byref host      as XHOSTADDRESS) as integer

declare function XRemoveHosts cdecl alias "XRemoveHosts" ( _
  byval lpDisplay as Display ptr , _
  byref hosts     as XHOSTADDRESS, _
  byval nhosts    as integer) as integer

declare function XReparentWindow cdecl alias "XReparentWindow" ( _
  byval lpDisplay  as Display ptr, _
  byval hWin       as WINDOWID   , _
  byval hParentWin as WINDOWID   , _
  byval x          as integer    , _
  byval y          as integer) as integer

declare function XResetScreenSaver cdecl alias "XResetScreenSaver" ( _
  byval lpDisplay as Display ptr) as integer

declare function XRestackWindows cdecl alias "XRestackWindows" ( _
  byval lpDisplay as Display  ptr, _
  byref hWin      as WINDOWID ptr, _ _
  byval nwindows  as integer) as integer

declare function XRotateBuffers cdecl alias "XRotateBuffers" ( _
  byval lpDisplay as Display ptr, _
  byval rotate    as integer) as integer

declare function XRotateWindowProperties cdecl alias "XRotateWindowProperties" ( _
  byval lpDisplay  as Display ptr, _
  byval hWin       as WINDOWID   , _
  byref properties as ATOM       , _
  byval num_prop   as integer    , _
  byval npositions as integer) as integer

declare function XScreenCount cdecl alias "XScreenCount" ( _
  byval lpDisplay as Display ptr) as integer

declare function XSendEvent cdecl alias "XSendEvent" ( _
  byval lpDisplay  as Display ptr, _
  byval hWin       as WINDOWID   , _
  byval propagate  as XBoolean    , _
  byval event_mask as integer    , _
  byref event_send as XEVENT) as integer

declare function XSetAccessControl cdecl alias "XSetAccessControl" ( _
  byval lpDisplay as Display ptr, _
  byval mode      as integer) as integer

declare function XSetArcMode cdecl alias "XSetArcMode" ( _
  byval lpDisplay as Display ptr, _
  byval gc        as GCONTEXT   , _
  byval arc_mode  as integer) as integer

declare function XSetClipMask cdecl alias "XSetClipMask" ( _
  byval lpDisplay     as Display ptr, _
  byval gc            as GCONTEXT   , _
  byval pix_map as PIXMAP) as integer

declare function XSetClipOrigin cdecl alias "XSetClipOrigin" ( _
  byval lpDisplay     as Display ptr, _
  byval gc            as GCONTEXT   , _
  byval clip_x_origin as integer    , _
  byval clip_y_origin as integer) as integer

declare function XSetClipRectangles cdecl alias "XSetClipRectangles" ( _
  byval lpDisplay     as Display ptr, _
  byval gc            as GCONTEXT   , _
  byval clip_x_origin as integer    , _
  byval clip_y_origin as integer    , _
  byref rectangles    as XRECTANGLE , _
  byval n             as integer    , _
  byval odering       as integer) as integer

declare function XSetCloseDownMode cdecl alias "XSetCloseDownMode" ( _
  byval lpDisplay as Display ptr, _
  byval closemode as integer) as integer

declare function XSetCommand cdecl alias "XSetCommand" ( _
  byval lpDisplay as Display ptr    , _
  byval hWin      as WINDOWID       , _
  byref argv      as zstring ptr ptr, _
  byref argc      as integer) as integer

declare function XSetDashes cdecl alias "XSetDashes" ( _
  byval lpDisplay   as Display ptr, _
  byval gc          as GCONTEXT   , _
  byval dash_offset as integer    , _
  byval dash_list   as byte ptr   , _
  byval n           as integer) as integer

declare function XSetFillRule cdecl alias "XSetFillRule" (byval fill_mode as integer) as integer

declare function XSetFont cdecl alias "XSetFont" ( _
  byval lpDisplay   as Display ptr, _
  byval gc          as GCONTEXT   , _
  byval font        as XID) as integer

declare function XSetFontPath cdecl alias "XSetFontPath" ( _
  byval lpDisplay   as Display ptr    , _
  byref directories as zstring ptr ptr, _
  byval ndirs       as integer) as integer

declare function XSetFunction cdecl alias "XSetFunction" ( _
  byval lpDisplay as Display ptr, _
  byval gc        as GCONTEXT   , _
  byval func      as integer) as integer

declare function XSetGraphicsExposures cdecl alias "XSetGraphicsExposures" ( _
  byval lpDisplay as Display ptr, _
  byval gc        as GCONTEXT   , _
  byval graphics_exposures as XBoolean) as integer

declare function XSetIconName cdecl alias "XSetIconName" ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WINDOWID   , _
  byval icon_name as string) as integer

declare function XSetInputFocus cdecl alias "XSetInputFocus" ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WINDOWID   , _
  byval revert_to as integer    , _
  byval t         as XTIME) as integer

declare function XSetModifierMapping cdecl alias "XSetModifierMapping" ( _
  byval lpDisplay as Display ptr, _
  byval modmap    as XMODIFIERKEYMAP ptr) as integer

declare function XSetPlaneMask cdecl alias "XSetPlaneMask" ( _
  byval lpDisplay  as Display ptr, _
  byval gc         as GCONTEXT   , _
  byval plane_mask as uinteger) as integer

declare function XSetPointerMapping cdecl alias "XSetPointerMapping" ( _
  byval lpDisplay as Display ptr, _
  byref map       as ubyte ptr  , _
  byval nmap      as integer) as integer

declare function XSetScreenSaver cdecl alias "XSetScreenSaver" ( _
  byval lpDisplay       as Display ptr, _
  byval timeout         as integer, _
  byval interval        as integer, _
  byval prefer_blanking as integer, _
  byval allow_exposures as integer) as integer

declare function XSetSelectionOwner cdecl alias "XSetSelectionOwner" ( _
  byval lpDisplay as Display ptr, _
  byval selection as ATOM       , _
  byval hOwnerWin as WINDOWID   , _
  byval t         as XTIME) as integer

declare function XSetState cdecl alias "XSetState" ( _
  byval lpDisplay  as Display ptr, _
  byval gc         as GCONTEXT   , _
  byval foreground as uinteger   , _
  byval background as uinteger   , _
  byval func       as integer    , _
  byval plane_mask as uinteger) as integer

declare function XSetStipple cdecl alias "XSetStipple" ( _
  byval lpDisplay as Display ptr, _
  byval gc        as GCONTEXT   , _
  byval stipple   as PIXMAP) as integer

declare function XSetSubwindowMode cdecl alias "XSetSubwindowMode" ( _
  byval lpDisplay      as Display ptr, _
  byval gc             as GCONTEXT   , _
  byval subwindow_mode as integer) as integer

declare function XSetTSOrigin cdecl alias "XSetTSOrigin" ( _
  byval lpDisplay   as Display ptr, _
  byval gc          as GCONTEXT   , _
  byval ts_x_origin as integer    , _
  byval ts_y_origin as integer) as integer

declare function XSetTile cdecl alias "XSetTile" ( _
  byval lpDisplay        as Display ptr, _
  byval gc               as GCONTEXT   , _
  byval tile             as PIXMAP) as integer

declare function XSetWindowBackground cdecl alias "XSetWindowBackground" ( _
  byval lpDisplay        as Display ptr, _
  byval hWin             as WINDOWID   , _
  byval background_pixel as uinteger) as integer

declare function XSetWindowBackgroundPixmap cdecl alias "XSetWindowBackgroundPixmap" ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WINDOWID   , _
  byval pix_map   as PIXMAP) as integer

declare function XSetWindowBorder cdecl alias "XSetWindowBorder" ( _
  byval lpDisplay    as Display ptr, _
  byval hWin         as WINDOWID   , _
  byval border_pixel as uinteger) as integer

declare function XSetWindowBorderPixmap cdecl alias "XSetWindowBorderPixmap" ( _
  byval lpDisplay     as Display ptr, _
  byval hWin          as WINDOWID   , _
  byval border_pixmap as PIXMAP) as integer

declare function XSetWindowBorderWidth cdecl alias "XSetWindowBorderWidth" ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WINDOWID   , _
  byval w         as uinteger) as integer


declare function XSetWindowColormap cdecl alias "XSetWindowColormap" ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WINDOWID   , _
  byval color_map as COLORMAP) as integer


declare function XStoreBuffer cdecl alias "XStoreBuffer" ( _
  byval lpDisplay           as Display ptr, _
  byval lpbytes             as byte ptr   , _
  byval nbytes              as integer    , _
  byval buffer              as integer) as integer

declare function XStoreBytes cdecl alias "XStoreBytes" ( _
  byval lpDisplay           as Display ptr, _
  byval lpbytes             as byte ptr   , _
  byval nbytes              as integer) as integer

declare function XStoreColor cdecl alias "XStoreColor" ( _
  byval lpDisplay           as Display ptr , _
  byval color_map           as COLORMAP    , _
  byref col                 as XCOLOR) as integer

declare function XStoreColors cdecl alias "XStoreColors" ( _
  byval lpDisplay           as Display ptr, _
  byval color_map           as COLORMAP   , _
  byref colord              as XCOLOR     , _
  byval ncolors             as integer ) as integer

declare function XStoreNamedColor cdecl alias "XStoreNamedColor" ( _
  byval lpDisplay           as Display ptr , _
  byval color_map           as COLORMAP    , _
  byval strcolor            as string      , _
  byval pixel               as uinteger    , _
  byval flags               as integer     ) as integer

declare function XTextExtents cdecl alias "XTextExtents" ( _
  byval font_struct         as XFONTSTRUCT ptr, _
  byval strarg              as string         , _
  byval nchars              as integer        , _
  byref direction_return    as integer        , _
  byref font_ascent_return  as integer        , _
  byref font_descent_return as integer        , _
  byval overall_return      as XCHARSTRUCT ptr) as integer

declare function XTextExtents16 cdecl alias "XTextExtents16" ( _
  byval font_struct         as XFONTSTRUCT ptr, _
  byval strarg              as XCHAR2B ptr    , _
  byval nchars              as integer        , _
  byref direction_return    as integer        , _
  byref font_ascent_return  as integer        , _
  byref font_descent_return as integer        , _
  byval overall_return      as XCHARSTRUCT ptr) as integer

declare function XTextWidth cdecl alias "XTextWidth" ( _
  byval font_struct as XFONTSTRUCT ptr, _
  byval strarg      as string         , _
  byval count       as integer) as integer

declare function XTextWidth16 cdecl alias "XTextWidth16" ( _
  byval font_struct as XFONTSTRUCT ptr, _
  byval strarg      as XCHAR2B ptr    , _
  byval count       as integer) as integer


declare function XTranslateCoordinates cdecl alias "XTranslateCoordinates" ( _
  byval lpDisplay as Display ptr, _
  byval src_hWin  as WINDOWID   , _
  byval dest_hWin as WINDOWID   , _
  byval src_x     as integer    , _
  byval src_y     as integer    , _
  byref dest_x_return as integer, _
  byref dest_y_return as integer, _
  byref hChildWin_return as WINDOWID) as integer

declare function XUndefineCursor    cdecl alias "XUndefineCursor" ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WINDOWID) as integer

declare function XUngrabButton      cdecl alias "XUngrabButton" ( _
  byval lpDisplay as Display ptr, _
  byval button    as uinteger   , _
  byval modifiers as uinteger   , _
  byval grab_hWin as WINDOWID) as integer

declare function XUngrabKey         cdecl alias "XUngrabKey" ( _
  byval lpDisplay as Display ptr, _
  byval key_code  as integer    , _
  byval modifiers as uinteger   , _
  byval grab_hWin as WINDOWID) as integer

declare function XUngrabKeyboard    cdecl alias "XUngrabKeyboard" ( _
  byval lpDisplay as Display ptr, _
  byval t         as XTIME) as integer

declare function XUngrabPointer     cdecl alias "XUngrabPointer" ( _
  byval lpDisplay as Display ptr, _
  byval t         as XTIME) as integer

declare function XUngrabServer      cdecl alias "XUngrabServer" ( _
  byval lpDisplay as Display ptr) as integer

declare function XUninstallColormap cdecl alias "XUninstallColormap" ( _
  byval lpDisplay as Display ptr, _
  byval color_map as COLORMAP) as integer

declare function XUnloadFont        cdecl alias "XUnloadFont" ( _
  byval lpDisplay as Display ptr, _
  byval font      as FONT) as integer

declare function XUnmapSubwindows   cdecl alias "XUnmapSubwindows" ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WINDOWID) as integer

declare function XUnmapWindow cdecl alias "XUnmapWindow" ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WINDOWID) as integer

declare function XVendorRelease cdecl alias "XVendorRelease" (byval lpDisplay as Display ptr) as integer

declare function XWarpPointer cdecl alias "XWarpPointer" ( _
  byval lpDisplay  as Display ptr, _
  byval src_hWin   as WINDOWID   , _
  byval dest_hWin  as WINDOWID   , _
  byval src_x      as integer    , _
  byval src_y      as integer    , _
  byval src_width  as uinteger   , _
  byval src_height as uinteger   , _
  byval dest_x     as integer    , _
  byval dest_y     as integer) as integer

declare function XWidthMMOfScreen cdecl alias "XWidthMMOfScreen" (byval lpscreen as XSCREEN) as integer

declare function XWidthOfScreen cdecl alias "XWidthOfScreen" (byval lpscreen as XSCREEN) as integer

declare function XWindowEvent cdecl alias "XWindowEvent" ( _
  byval lpDisplay    as Display ptr, _
  byval hWin         as WINDOWID   , _
  byval event_mask   as integer    , _
  byref event_return as XEVENT) as integer

declare function XWriteBitmapFile cdecl alias "XWriteBitmapFile" ( _
  byval lpDisplay as Display ptr, _
  byval filename  as string     , _
  byval pix_map   as PIXMAP     , _
  byval w         as uinteger   , _
  byval h         as uinteger   , _
  byval x_hot     as integer    , _
  byval y_hot     as integer) as integer

declare function XSupportsLocale     cdecl alias "XSupportsLocale" () as XBoolean

declare function XSetLocaleModifiers cdecl alias "XSetLocaleModifiers" ( _
  byval modifier_list as string ptr) as zstring ptr

'output methode
declare function XOpenOM      cdecl alias "XOpenOM"      ( _
  byval lpDisplay as Display           ptr, _
  byval rdb       as _XrmHashBucketRec ptr, _
  byval res_name  as string               , _
  byval res_class as string) as XOM

declare function XCloseOM     cdecl alias "XCloseOM"     (byval om as XOM) as integer
declare function XSetOMValues cdecl alias "XSetOMValues" (byval om as XOM, ...) as zstring ptr
declare function XGetOMValues cdecl alias "XGetOMValues" (byval om as XOM, ...) as zstring ptr
declare function XDisplayOfOM cdecl alias "XDisplayOfOM" (byval om as XOM) as Display ptr
declare function XLocaleOfOM  cdecl alias "XLocaleOfOM"  (byval om as XOM) as zstring ptr

'output context
declare function XCreateOC    cdecl alias "XCreateOC"    (byval om as XOM, ...) as XOC
declare sub      XDestroyOC   cdecl alias "XDestroyOC"   (byval oc as XOC)
declare function XOMOfOC      cdecl alias "XOMOfOC"      (byval oc as XOC) as XOM
declare function XSetOCValues cdecl alias "XSetOCValues" (byval oc as XOC, ...) as zstring ptr
declare function XGetOCValues cdecl alias "XGetOCValues" (byval oc as XOC, ...) as zstring ptr

declare function XCreateFontSet cdecl alias "XCreateFontSet" ( _
  byval lpDisplay                    as Display ptr    , _
  byval base_font_name               as string         , _
  byref missing_charset_list_return  as zstring ptr ptr, _
  byref missing_charset_count_return as integer        , _
  byref def_string_return            as zstring ptr) as XFONTSET

declare sub XFreeFontSet cdecl alias "XFreeFontSet" ( _
  byval lpDisplay        as Display ptr, _
  byval font_set         as XFONTSET)

declare function XFontsOfFontSet cdecl alias "XFontsOfFontSet" ( _
  byval font_set         as XFONTSET, _
  byref font_struct_list as XFONTSTRUCT ptr ptr, _
  byref font_name_list   as zstring ptr ptr) as integer

declare function XBaseFontNameListOfFontSet   cdecl alias "XBaseFontNameListOfFontSet"   (byval font_set as XFONTSET) as zstring ptr
declare function XLocaleOfFontSet             cdecl alias "XLocaleOfFontSet"             (byval font_set as XFONTSET) as zstring ptr
declare function XContextDependentDrawing     cdecl alias "XContextDependentDrawing"     (byval font_set as XFONTSET) as XBoolean
declare function XDirectionalDependentDrawing cdecl alias "XDirectionalDependentDrawing" (byval font_set as XFONTSET) as XBoolean
declare function XContextualDrawing           cdecl alias "XContextualDrawing"           (byval font_set as XFONTSET) as XBoolean
declare function XExtentsOfFontSet            cdecl alias "XExtentsOfFontSet"            (byval font_set as XFONTSET) as XFONTSETEXTENS

declare function XmbTextEscapement   cdecl alias "XmbTextEscapement"   ( _
  byval font_set as XFONTSET, _
  byval text     as string  , _
  byval nbytes   as integer) as integer

declare function XwcTextEscapement   cdecl alias "XwcTextEscapement"   ( _
  byval font_set as XFONTSET, _
  byval text     as wchar_t ptr, _
  byval nwchars  as integer) as integer

declare function Xutf8TextEscapement cdecl alias "Xutf8TextEscapement" ( _
  byval font_set as XFONTSET, _
  byval text     as string, _
  byval nchars   as integer) as integer

declare function XmbTextExtents cdecl alias "XmbTextExtents" ( _
  byval font_set               as XFONTSET, _
  byval text                   as string  , _
  byval nchars                 as integer , _
  byref overall_ink_return     as XRECTANGLE, _
  byref overall_logical_return as XRECTANGLE) as integer

declare function XwcTextExtents cdecl alias "XwcTextExtents" ( _
  byval font_set               as XFONTSET, _
  byval text                   as wchar_t ptr, _
  byval nwchars                as integer, _
  byref overall_ink_return     as XRECTANGLE, _
  byref overall_logical_return as XRECTANGLE) as integer

declare function Xutf8TextExtents cdecl alias "Xutf8TextExtents" ( _
  byval font_set               as XFONTSET, _
  byval text                   as string, _
  byval nchars                 as integer, _
  byref overall_ink_return     as XRECTANGLE, _
  byref overall_logical_return as XRECTANGLE) as integer

declare function XmbTextPerCharExtents cdecl alias "XmbTextPerCharExtents" ( _
  byval font_set             as XFontSet  , _
  byval text                 as string    , _
  byval num_bytes            as integer   , _
  byref ink_array_return     as XRectangle, _
  byref logical_array_return as XRectangle, _
  byval array_size           as integer   , _
  byref num_chars_return     as integer   , _
  byref overall_ink_return   as XRectangle, _
  byref overall_logical_return as  XRectangle) as integer

declare function XwcTextPerCharExtents cdecl alias "XwcTextPerCharExtents" ( _
  byval font_set               as XFontSet    , _
  byval text                   as wchar_t ptr , _
  byval num_wchars             as integer     , _
  byref ink_array_return       as XRectangle  , _
  byref logical_array_return   as XRectangle  , _
  byval array_size             as integer     , _
  byref num_chars_return       as integer     , _
  byref overall_ink_return     as XRectangle  , _
  byref overall_logical_return as XRectangle  ) as integer

declare function Xutf8TextPerCharExtents cdecl alias "Xutf8TextPerCharExtents"( _
  byval font_set               as XFontSet   , _
  byval text                   as string     , _
  byval num_bytes              as integer    , _
  byref ink_array_return       as XRectangle , _
  byref logical_array_return   as XRectangle , _
  byval array_size             as integer    , _
  byref num_chars_return       as integer    , _
  byref overall_ink_return     as XRectangle , _
  byref overall_logical_return as XRectangle) as integer

declare sub XmbDrawText cdecl alias "XmbDrawText" ( _
  byval lpDisplay as Display ptr, _
  byval d         as DRAWABLE   , _
  byval gc        as GCONTEXT   , _
  byval x         as integer    , _
  byval y         as integer    , _
  byref textitems as XmbTextItem, _
  byval nitems    as integer)

declare sub XwcDrawText cdecl alias "XwcDrawText" ( _
  byval lpDisplay as Display ptr, _
  byval d         as DRAWABLE   , _
  byval gc        as GCONTEXT   , _
  byval x         as integer    , _
  byval y         as integer    , _
  byref textitems as XwcTextItem, _
  byval nitems    as integer)

declare sub Xutf8DrawText cdecl alias "Xutf8DrawText" ( _
  byval lpDisplay as Display ptr, _
  byval d         as DRAWABLE   , _
  byval gc        as GCONTEXT   , _
  byval x         as integer    , _
  byval y         as integer    , _
  byref textitems as XmbTextItem, _
  byval nitems    as integer)

declare sub XmbDrawString cdecl alias "XmbDrawString" ( _
  byval lpDisplay as Display ptr, _
  byval d         as DRAWABLE   , _
  byval font_set  as XFONTSET   , _
  byval gc        as GCONTEXT   , _
  byval x         as integer    , _
  byval y         as integer    , _
  byval text      as string     , _
  byval nchars    as integer)

declare sub XwcDrawString cdecl alias "XwcDrawString" ( _
  byval lpDisplay as Display ptr, _
  byval d         as DRAWABLE   , _
  byval font_set  as XFONTSET   , _
  byval gc        as GCONTEXT   , _
  byval x         as integer    , _
  byval y         as integer    , _
  byval text      as wchar_t ptr, _
  byval nwchars   as integer)

declare sub Xutf8DrawString cdecl alias "Xutf8DrawString" ( _
  byval lpDisplay as Display ptr, _
  byval d         as DRAWABLE   , _
  byval font_set  as XFONTSET   , _
  byval gc        as GCONTEXT   , _
  byval x         as integer    , _
  byval y         as integer    , _
  byval text      as string     , _
  byval nchars    as integer)

declare sub XmbDrawImageString cdecl alias "XmbDrawImageString" ( _
  byval lpDisplay as Display ptr, _
  byval d         as DRAWABLE   , _
  byval font_set  as XFONTSET   , _
  byval gc        as GCONTEXT   , _
  byval x         as integer    , _
  byval y         as integer    , _
  byval text      as string     , _
  byval nchars    as integer)

declare sub XwcDrawImageString cdecl alias "XwcDrawImageString" ( _
  byval lpDisplay as Display ptr, _
  byval d         as DRAWABLE   , _
  byval font_set  as XFONTSET   , _
  byval gc        as GCONTEXT   , _
  byval x         as integer    , _
  byval y         as integer    , _
  byval text      as wchar_t ptr, _
  byval nwchars   as integer)

declare sub Xutf8DrawImageString cdecl alias "Xutf8DrawImageString" ( _
  byval lpDisplay as Display ptr , _
  byval d         as DRAWABLE    , _
  byval font_set  as XFONTSET    , _
  byval gc        as GCONTEXT    , _
  byval x         as integer     , _
  byval y         as integer     , _
  byval text      as string      , _
  byval nchars    as integer)

declare function XOpenIM cdecl alias "XOpenIM" ( _
  byval lpDisplay as display ptr, _
  byval rdb       as any ptr    , _
  byval res_name  as zstring ptr, _
  byval res_class as zstring ptr) as XIM

declare function XCloseIM      cdecl alias "XCloseIM"      (byval im as XIM) as integer
declare function XCreateIC     cdecl alias "XCreateIC"     (byval im as XIM, ...) as XIC
declare sub      XDestroyIC    cdecl alias "XDestroyIC"    (byval ic as XIC)
declare function XGetIMValues  cdecl alias "XGetIMValues"  (byval im as XIM, ...) as byte ptr
declare function XSetIMValues  cdecl alias "XGetIMValues"  (byval im as XIM, ...) as byte ptr
declare function XDisplayOfIM  cdecl alias "XDisplayOfIM"  (byval im as XIM) as Display ptr
declare function XLocaleOfIM   cdecl alias "XLocaleOfIM"   (byval im as XIM) as byte ptr
declare sub      XSetICFocus   cdecl alias "XSetICFocus"   (byval ic as XIC)
declare sub      XUnsetICFocus cdecl alias "XUnsetICFocus" (byval ic as XIC)
declare function XwcResetIC    cdecl alias "XwcResetIC"    (byval ic as XIC) as wchar_t ptr
declare function XmbResetIC    cdecl alias "XmbResetIC"    (byval ic as XIC) as byte ptr
declare function Xutf8ResetIC  cdecl alias "Xutf8ResetIC"  (byval ic as XIC) as byte ptr
declare function XSetICValues  cdecl alias "XSetICValues"  (byval ic as XIC) as byte ptr
declare function XGetICValues  cdecl alias "XGetICValues"  (byval ic as XIC) as byte ptr
declare function XIMOfIC       cdecl alias "XIMOfIC"       (byval ic as XIC) as XIM

declare function XFilterEvent cdecl alias "XFilterEvent" ( _
  byref event as XEVENT, _
  byval hWin  as WINDOWID) as XBoolean

declare function XmbLookupString cdecl alias "XmbLookupString" ( _
  byval ic            as XIC             , _
  byref event         as XKEYPRESSEDEVENT, _
  byref buffer_return as byte ptr        , _
  byval bytes_buffer  as integer         , _
  byref keysym_return as KEYSYM          , _
  byref status_return as integer) as integer

declare function XwcLookupString cdecl alias "XwcLookupString" ( _
  byval ic            as XIC             , _
  byref event         as XKEYPRESSEDEVENT, _
  byref buffer_return as wchar_t ptr     , _
  byval wchars_buffer as integer         , _
  byref keysym_return as KEYSYM          , _
  byref status_return as integer) as integer

declare function Xutf8LookupString cdecl alias "Xutf8LookupString" ( _
  byval ic            as XIC, _
  byref event         as XKEYPRESSEDEVENT, _
  byref buffer_return as byte ptr, _
  byval bytes_buffer  as integer, _
  byref keysym_return as KEYSYM, _
  byref status_return as integer) as integer

declare function XVaCreateNestedList cdecl alias "XVaCreateNestedList" ( _
  byval unused as integer, ...) as XVaNestedList ptr

'internal connections for IMs
declare function XRegisterIMInstantiateCallback cdecl alias "XRegisterIMInstantiateCallback" ( _
  byval lpDisplay   as Display ptr          , _
  byref rdb         as _XrmHushBucketRec ptr, _
  byval res_name    as string               , _
  byval res_class   as string               , _
  byval callback    as XIDPROC              , _
  byval client_data as XPOINTER ptr) as XBoolean

declare function XUnregisterIMInstantiateCallback cdecl alias "XUnregisterIMInstantiateCallback" ( _
  byval lpDisplay   as Display ptr          , _
  byref rdb         as _XrmHushBucketRec ptr, _
  byval res_name    as string               , _
  byval res_class   as string               , _
  byval callback    as XIDPROC              , _
  byval client_data as XPOINTER ptr) as XBoolean

type XConnectionWatchProc as sub ( _
  byval lpDisplay   as Display ptr, _
  byval client_data as XPOINTER   , _
  byval fd          as integer    , _
  byval opening     as XBoolean    , _
  byval watch_data as XPOINTER ptr)

' int** fd_return !!!
declare function XInternalConnectionNumbers cdecl alias "XInternalConnectionNumbers" ( _
  byval lpDisplay    as Display ptr, _
  byref fd_return    as integer ptr, _
  byref count_return as integer) as integer

declare sub XProcessInternalConnection cdecl alias "XProcessInternalConnection" ( _
  byval lpDisplay as Display ptr, _
  byval fd        as integer)

declare function XAddConnectionWatch cdecl alias "XAddConnectionWatch" ( _
  byval lpDisplay  as Display             , _
  byval callback   as XConnectionWatchProc, _
  byval clientdata as XPOINTER) as integer

declare sub XRemoveConnectionWatch cdecl alias "XRemoveConnectionWatch" ( _
  byval lpDisplay  as Display, _
  byval callback   as XConnectionWatchProc, _
  byval clientdata as XPOINTER)

declare sub XSetAuthorization cdecl alias "XSetAuthorization" ( _
  byval name     as string   , _
  byval name_len as integer  , _
  byval lpdata   as byte ptr , _
  byval datalen  as integer)

'!!!
declare function _Xmbtowc cdecl alias "_Xmbtowc" ( _
  byval wstr   as wchar_t ptr, _
  byval zstr   as zstring ptr, _
  byval length as integer    ) as integer

declare function _Xwctomb cdecl alias "_Xwctomb" ( _
  byval zstr as zstring ptr, _
  byval wc   as wchar_t) as integer


' Bitmask returned by XParseGeometry().  Each bit tells if the corresponding
' value (x, y, width, height) was found in the parsed string.
#define NoValue         &H0000
#define XValue          &H0001
#define YValue          &H0002
#define WidthValue      &H0004
#define HeightValue     &H0008
#define AllValues       &H000F
#define XNegative       &H0010
#define YNegative       &H0020

' The next block of definitions are for window manager properties
' that clients and applications use for communication.
enum SIZEHINTSFLAGS
  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)
end enum

type numerator_denominator
  x as integer
  y as integer
end type
' new version containing base_width, base_height, and win_gravity fields
' used with WM_NORMAL_HINTS.
type XSizeHints
  flags        as SIZEHINTSFLAGS        ' marks which fields in this structure are defined
  x            as integer
  y            as integer       ' obsolete for new window mgrs, but clients
  width        as integer
  height       as integer       ' should set so old wm's don't mess up
  min_width    as integer
  min_height   as integer
  max_width    as integer
  max_height   as integer
  width_inc    as integer
  height_inc   as integer
  max_aspect   as numerator_denominator
  min_aspect   as numerator_denominator
  base_width   as integer
  base_height  as integer       ' added by ICCCM version 1
  win_gravity1 as integer       ' added by ICCCM version 1
end type

' definition for flags of XWMHints
enum XWMHINTSFLAG
  InputHint        = (1 shl 0)
  StateHint        = (1 shl 1)
  IconPixmapHint   = (1 shl 2)
  IconWindowHint   = (1 shl 3)
  IconPositionHint = (1 shl 4)
  IconMaskHint     = (1 shl 5)
  WindowGroupHint  = (1 shl 6)
  AllHints         = (InputHint or StateHint or IconPixmapHint or IconWindowHint or IconPositionHint or IconMaskHint or WindowGroupHint)
  XUrgencyHint     = (1 shl 8)
end enum

enum INITIALWINDOWSTATES
  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
end enum

type XWMHints
  flags         as XWMHINTSFLAG         ' marks which fields in this structure are defined
  input         as integer              ' does this application rely on the window manager to get keyboard input?
  initial_state as INITIALWINDOWSTATES  ' see below
  icon_pixmap   as XID                  ' PixmapID to be used as icon
  icon_window   as XID                  ' WindowID to be used as icon
  icon_x        as integer              ' initial position of icon
  icon_y        as integer
  icon_mask     as integer              '  PixmapID icon mask bitmap
  window_group  as XID                  ' ID of related window group
end type

' Obsolete states no longer defined by ICCCM
#define DontCareState          0       ' don't know or care
#define ZoomState              2       ' application wants to start zoomed
#define 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 XTEXTPROPERTY
  value    as zstring ptr ' same as Property routines
  encoding as ATom         ' prop type
  format   as integer      ' prop data format: 8, 16, or 32
  nitems   as uinteger     ' number of data items in value
end type

#define XNoMemory           -1
#define XLocaleNotSupported -2
#define XConverterNotFound  -3

enum XICCEncodingStyle
  XStringStyle                  ' STRING
  XCompoundTextStyle            ' COMPOUND_TEXT
  XTextStyle                    ' text in owner's encoding (current locale)
  XStdICCTextStyle              ' STRING, else COMPOUND_TEXT
  XUTF8StringStyle              ' UTF8_STRING
end enum

type XIconSize
  min_width  as integer
  min_height as integer
  max_width  as integer
  max_height as integer
  width_inc  as integer
  height_inc as integer
end type

type XClassHint
  res_name  as zstring ptr '!!!
  res_class as zstring ptr '!!!
end type

'### IMAGE SECTION ###
declare function XImageByteOrder  cdecl alias "XImageByteOrder"  ( _
  byval lpDisplay as Display ptr) as integer

' visual can be CopyFromParent
' format can be YPixmap or ZPixmap
' offset from begining 0
' lpData is in client memory
' bits_pad can be 8,16 or 32
' bytes per line can be 0
declare function XCreateImage cdecl alias "XCreateImage" ( _
  byval lpDisplay as Display ptr, _
  byval visual    as VISUAL ptr , _
  byval depth     as integer    , _
  byval format    as integer    , _
  byval offset    as integer    , _
  byval lpData    as any ptr    , _
  byval w         as uinteger   , _
  byval height    as uinteger   , _
  byval bits_pad  as integer    , _
  byval bytes_per_line as integer) as XImage ptr

declare function XInitImage   cdecl alias "XInitImage"   ( _
  byval img        as XIMAGE ptr) as integer

declare function XGetImage    cdecl alias "XGetImage"    ( _
  byval lpDisplay  as Display ptr, _
  byval Drawable   as XID        , _
  byval x          as integer    , _
  byval y          as integer    , _
  byval w          as integer    , _
  byval h          as integer    , _
  byval plane_mask as uinteger   , _
  byval format     as integer    ) as XImage ptr

declare function XSubImage     cdecl alias "XSubImage"     ( _
  byval img as XImage ptr, _
  byval x   as integer   , _
  byval y   as integer   , _
  byval w   as uinteger  , _
  byval h   as uinteger  ) as XImage ptr


declare function XGetSubImage cdecl alias "XGetSubImage" ( _
  byval lpDisplay  as Display ptr, _
  byval Drawable   as XID        , _
  byval x          as integer    , _
  byval y          as integer    , _
  byval w          as integer    , _
  byval h          as integer    , _
  byval plane_mask as uinteger   , _
  byval format     as integer    , _
  byval dest_image as XImage ptr , _
  byval xdest      as integer    , _
  byval ydest      as integer) as XImage ptr

declare function XPutImage cdecl alias "XPutImage" ( _
  byval lpDisplay as Display ptr, _
  byval d         as DRAWABLE   , _
  byval gc        as GCONTEXT   , _
  byval image     as XIMAGE ptr , _
  byval src_x     as integer    , _
  byval src_y     as integer    , _
  byval des_x     as integer    , _
  byval des_y     as integer    , _
  byval width     as uinteger   , _
  byval height    as uinteger) as integer


declare function XGetPixel     cdecl alias "XGetPixel"     ( _
  byval img as XImage ptr, _
  byval x   as integer   , _
  byval y   as integer) as uinteger

declare function XPutPixel     cdecl alias "XPutPixel"     ( _
  byval img as XImage ptr, _
  byval x   as integer   , _
  byval y   as integer   , _
  byval pixelcol as uinteger) as integer

declare function XAddPixel     cdecl alias "XAddPixel"     ( _
  byval img   as XImage ptr, _
  byval pixel as integer) as integer

declare function XDestroyImage cdecl alias "XDestroyImage" ( _
  byval as XImage ptr) as integer


' Compose sequence status structure, used in calling XLookupString.
type XComposeStatus
  compose_ptr   as XPointer ptr     ' state table pointer
  chars_matched as integer          ' match state
end type

'!!!
' Keysym macros, used on Keysyms to test for classes of symbols
'#define IsKeypadKey(keysym)            (((KeySym)(keysym) >= XK_KP_Space) and  ((KeySym)(keysym) <= XK_KP_Equal))
'#define IsPrivateKeypadKey(keysym)     (((KeySym)(keysym) >= 0x11000000)  and  ((KeySym)(keysym) <= 0x1100FFFF))
'#define IsCursorKey(keysym)            (((KeySym)(keysym) >= XK_Home)     and  ((KeySym)(keysym) <  XK_Select))
'#define IsPFKey(keysym)                (((KeySym)(keysym) >= XK_KP_F1)    and  ((KeySym)(keysym) <= XK_KP_F4))
'#define IsFunctionKey(keysym)          (((KeySym)(keysym) >= XK_F1)       and ((KeySym)(keysym) <= XK_F35))
'#define IsMiscFunctionKey(keysym)      (((KeySym)(keysym) >= XK_Select)   and  ((KeySym)(keysym) <= XK_Break))

'#ifdef XK_XKB_KEYS
'#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))
'#else
'#define IsModifierKey(keysym) \
'  ((((KeySym)(keysym) >= XK_Shift_L) && ((KeySym)(keysym) <= XK_Hyper_R)) || ((KeySym)(keysym) == XK_Mode_switch) \
'   || ((KeySym)(keysym) == XK_Num_Lock))
'#endif

' opaque reference to Region data type
type Region as _XRegion ptr

' Return values from XRectInRegion()
#define RectangleOut  0
#define RectangleIn   1
#define RectanglePart 2

' Information used by the visual utility routines to find desired visual
' type from the many visuals a display may support.
type XVISUALINFO
  visual        as VISUAL ptr
  visualid      as XID
  screen        as integer
  depth         as integer
  class         as integer
  red_mask      as uinteger
  green_mask    as uinteger
  blue_mask     as uinteger
  colormap_size as integer
  bits_per_rgb  as integer
end type

enum VISUALINFOMASKS
  VisualNoMask           = &H0
  VisualIDMask           = &H1
  VisualScreenMask       = &H2
  VisualDepthMask        = &H4
  VisualClassMask        = &H8
  VisualRedMaskMask      = &H10
  VisualGreenMaskMask    = &H20
  VisualBlueMaskMask     = &H40
  VisualColormapSizeMask = &H80
  VisualBitsPerRGBMask   = &H100
  VisualAllMask          = &H1FF
end enum

' This defines a window manager property that clients may use to
' share standard color maps of type RGB_COLOR_MAP:
type XStandardColormap
  colormap   as XID
  red_max    as uinteger
  red_mult   as uinteger
  green_max  as uinteger
  green_mult as uinteger
  blue_max   as uinteger
  blue_mult  as uinteger
  base_pixel as uinteger
  visualid   as XID             ' added by ICCCM version 1
  killid     as XID             ' added by ICCCM version 1
end type
'#define ReleaseByFreeingColormap ((XID) 1)  ; for killid field above

' return codes for XReadBitmapFile and XWriteBitmapFile
#define BitmapSuccess           0
#define BitmapOpenFailed        1
#define BitmapFileInvalid       2
#define BitmapNoMemory          3

'**********************
'* Context Management *
'**********************
' Associative lookup table return codes
#define XCSUCCESS 0 ' No error
#define XCNOMEM   1 ' Out of memory
#define XCNOENT   2 ' No entry in table

'#define XUniqueContext() ((XContext) XrmUniqueQuark())
'#define XStringToContext(string)((XContext) XrmStringToQuark(string))

declare function XDeleteContext cdecl alias "XDeleteContext" (_
  byval lpDisplay as Display ptr, _
  byval rid      as XID        , _
  byval context  as XContext   ) as integer

'The following declarations are alphabetized.
declare function XAllocClassHint        cdecl alias "XAllocClassHint"        () as XClassHint ptr
declare function XAllocIconSize         cdecl alias "XAllocIconSize"         () as XIconSize ptr
declare function XAllocSizeHints        cdecl alias "XAllocSizeHints"        () as XSizeHints ptr
declare function XAllocStandardColormap cdecl alias "XAllocStandardColormap" () as XStandardColormap ptr

declare function XClipBox cdecl alias "XClipBox" ( _
  byval r   as Region    ,  _
  byref rec as XRectangle) as integer

declare function XDefaultString         cdecl alias "XDefaultString"         () as zstring ptr

declare function XFindContext cdecl alias "XFindContext" ( _
  byval lpDisplay   as Display ptr, _
  byval resourceid  as XID        , _
  byval context     as XContext   , _
  byref data_return as XPOINTER   ) as integer

declare function XGetClassHint cdecl alias "XGetClassHint" ( _
  byval lpDisplay as Display ptr        , _
  byval hWin      as WINDOWID           , _
  byref class_hints_return as XClassHint) as integer

declare function XGetIconSizes cdecl alias "XGetIconSizes"    ( _
  byval lpDisplay        as Display ptr      , _
  byval hWin             as WINDOWID         , _
  byref size_list_return as XIconSize ptr ptr, _
  byref count_return     as integer          ) as integer

declare function XGetNormalHints cdecl alias "XGetNormalHints"  ( _
  byval lpDisplay    as Display ptr, _
  byval hWin         as WINDOWID   , _
  byref hints_return as XSizeHints) as integer

declare function XGetRGBColormaps cdecl alias "XGetRGBColormaps" ( _
  byval lpDisplay    as Display ptr, _
  byval hWin         as WINDOWID   , _
  byref stdcmap_ret  as XStandardColormap ptr ptr,_
  byref count_return as integer, _
  byval property     as Atom) as integer

declare function XGetSizeHints cdecl alias "XGetSizeHints" ( _
  byval lpDisplay    as Display ptr, _
  byval hWin         as WINDOWID, _
  byref hints_return as XSizeHints, _
  byval property as Atom) as integer

declare function XGetStandardColormaps  cdecl alias "XGetStandardColormaps" ( _
  byval lpDisplay      as Display ptr, _
  byval hWin           as WINDOWID, _
  byref stdcmap_return as XStandardColormap ptr, _
  byval property       as Atom) as integer

declare function XGetTextProperty       cdecl alias "XGetTextProperty"      ( _
  byval lpDisplay        as Display ptr, _
  byval hWin             as WINDOWID, _
  byref text_prop_return as XtextProperty, _
  byval property         as Atom) as integer

declare function XGetVisualInfo         cdecl alias "XGetVisualInfo"        ( _
  byval lpDisplay      as Display ptr    , _
  byval vinfo_mask     as VISUALINFOMASKS, _
  byref vinfo_template as XVisualInfo    , _
  byref nitems_return  as integer) as XVISUALINFO

declare function XGetZoomHints cdecl alias "XGetZoomHints"     ( _
  byval lpDisplay    as Display ptr, _
  byval hWin         as WindowID, _
  byref hints_return as XSIZEHINTS) as integer

declare sub XConvertCase cdecl alias "XConvertCase" ( _
  byval sym   as KEYSYM, _
  byref lower as KEYSYM, _
  byref upper as KEYSYM)

'You can pass XKeyPressedEvent or XKeyReleasedEvent
'status_in_out   Specifies or returns the XComposeStatus structure or NULL.
declare function XLookupString cdecl alias "XLookupString" ( _
  byref event_struct    as XKeyEvent  , _
  byref buffer_return   as zstring ptr, _
  byval max_size        as integer    , _
  byref keysym_return   as KEYSYM     , _
  byref lpStatus_in_out as XComposeStatus ptr) as integer

declare function XMatchVisualInfo cdecl alias "XMatchVisualInfo" ( _
  byval lpDisplay    as Display ptr, _
  byval screen_num   as integer    , _
  byval depth        as integer    , _
  byval class        as integer    , _
  byref vinfo_return as XVisualInfo ptr) as integer

declare function XSaveContext cdecl alias "XSaveContext"   ( _
  byval lpDisplay  as Display ptr, _
  byval resourceid as XID        , _
  byval context    as XCONTEXT   , _
  byref lpdatat    as XPointer ptr ) as integer

declare function XSetClassHint cdecl alias "XSetClassHint"    ( _
  byval lpDisplay   as Display ptr, _
  byval hWin        as WindowID   , _
  byref class_hints as XCLASSHINT) as integer

declare function XSetIconSizes cdecl alias "XSetIconSizes"    ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WindowID   , _
  byref size_list as XICONSIZE  , _
  byval count     as integer) as integer

declare function XSetNormalHints cdecl alias "XSetNormalHints"  ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WindowID, _
  byref hints     as XSIZEHINTS) as integer

declare function XSetRGBColormaps cdecl alias "XSetRGBColormaps" ( _
  byval lpDisplay as Display ptr      , _
  byval hWin      as WindowID         , _
  byref stdcmaps  as XStandardColormap, _
  byval count     as integer          , _
  byval property  as ATOM             ) as integer

declare function XSetSizeHints cdecl alias "XSetSizeHints" ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WindowID   , _
  byref hints     as XSIZEHINTS , _
  byval property  as ATOM) as integer

declare function XSetStandardProperties cdecl alias "XSetStandardProperties" ( _
  byval lpDisplay   as Display ptr    , _
  byval hWin        as WindowID       , _
  byval window_name as string         , _
  byval icon_name   as string         , _
  byval icon_pixmap as PIXMAP         , _
  byval lpargv      as zstring ptr ptr, _
  byval argv        as integer        , _
  byref hints       as XSIZEHINTS     ) as integer

declare sub XSetTextProperty cdecl alias "XSetTextProperty" ( _
  byval lpDisplay as Display ptr  , _
  byval hWin      as WindowID     , _
  byref text_prop as XTEXTPROPERTY, _
  byval property  as ATOM)

'### WM section ###
declare function XGetWMProtocols cdecl alias "XGetWMProtocols"      ( _
  byval lpDisplay        as Display ptr , _
  byval hWin             as WindowID    , _
  byref protocols_return as ATOM ptr ptr, _
  byref count_return     as integer     ) as integer

declare function XSetWMProtocols cdecl alias "XSetWMProtocols"      ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WindowID   , _
  byref protocols as ATOM       , _
  byval count     as integer    ) as integer

declare function XGetWMColormapWindows cdecl alias "XGetWMColormapWindows" ( _
  byval lpDisplay      as Display ptr     , _
  byval hWin           as WindowID        , _
  byval windows_return as WINDOWID ptr ptr, _
  byref count_return   as integer         ) as integer

declare function XSetWMColormapWindows cdecl alias "XSetWMColormapWindows" ( _
  byval lpDisplay as Display ptr    , _
  byval hWin      as WindowID       , _
  byref colormap_windows as WindowID, _
  byval count     as integer        ) as integer

declare function XGetWMHints            cdecl alias "XGetWMHints"           ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WindowID) as XWMHINTS ptr

declare function XGetWMClientMachine    cdecl alias "XGetWMClientMachine" ( _
  byval lpDisplay            as Display ptr, _
  byval hWin                 as WindowID   , _
  byref text_property_return as XTEXTPROPERTY) as integer

declare function XGetWMIconName         cdecl alias "XGetWMIconName"    ( _
  byval lpDisplay            as Display ptr, _
  byval hWin                 as WindowID   , _
  byref text_property_return as XTEXTPROPERTY) as integer

declare function XGetWMName             cdecl alias "XGetWMName"        ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WindowID   , _
  byref text_property_return as XTEXTPROPERTY) as integer

declare function XGetWMNormalHints cdecl alias "XGetWMNormalHints" ( _
  byval lpDisplay       as Display ptr, _
  byval hWin            as WindowID   , _
  byref hints_return    as XSIZEHINTS , _
  byref supplied_return as integer) as integer

declare function XGetWMSizeHints cdecl alias "XGetWMSizeHints"   ( _
  byval lpDisplay       as Display ptr, _
  byval hWin            as WindowID   , _
  byref hints_return    as XSIZEHINTS , _
  byref supplied_return as integer    , _
  byval Property        as ATOM) as integer

declare sub      XSetWMClientMachine cdecl alias "XSetWMClientMachine" ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WindowID   , _
  byref text_prop as XTEXTPROPERTY)

declare sub      XSetWMIconName      cdecl alias "XSetWMIconName"      ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WindowID   , _
  byref text_prop as XTEXTPROPERTY)

declare sub      XSetWMName          cdecl alias "XSetWMName"          ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WindowID   , _
  byref text_prop as XTEXTPROPERTY)

declare function XAllocWMHints       cdecl alias "XAllocWMHints"       () as XWMHints ptr

declare function XSetWMHints         cdecl alias "XSetWMHints"         ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WindowID   , _
  byref wm_hints  as XWMHINTS) as integer

declare sub      XSetWMNormalHints   cdecl alias "XSetWMNormalHints"   ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WindowID, _
  byref hints     as XSIZEHINTS)

declare sub XSetWMProperties cdecl alias "XSetWMProperties" ( _
  byval lpDisplay    as Display ptr     , _
  byval hWin         as WindowID        , _
  byref window_name  as XTEXTPROPERTY   , _
  byref icon_name    as XTEXTPROPERTY   , _
  byval lpargv       as zstring ptr ptr , _
  byval argc         as integer         , _
  byref normal_hints as XSIZEHINTS      , _
  byref wm_hints     as XWMHINTS        , _
  byref class_hint   as XCLASSHINT      )

declare function XWMGeometry cdecl alias "XWMGeometry" ( _
  byval lpDisplay        as Display ptr, _
  byval screen_num       as integer   , _
  byval user_geometry    as string    , _
  byval default_geometry as string    , _
  byval border_width     as uinteger  , _
  byref hints            as XSIZEHINTS, _
  byref x_ret            as integer   , _
  byref y_ret            as integer   , _
  byref width_ret        as integer   , _
  byref height_ret       as integer   , _
  byref gravity_return   as integer   ) as integer

declare sub Xutf8SetWMProperties cdecl alias "Xutf8SetWMProperties" ( _
  byval lpDisplay    as Display ptr    , _
  byval hWin         as WINDOWID       , _
  byval window_name  as string         , _
  byval icon_name    as string         , _
  byval lpargv       as zstring ptr ptr, _
  byval argc         as integer        , _
  byref normal_hints as XSIZEHINTS     , _
  byref wm_hints     as XWMHINTS       , _
  byref class_hint   as XCLASSHINT)

declare sub XSetWMSizeHints cdecl alias "XSetWMSizeHints" ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WINDOWID   , _
  byref hints     as XSIZEHINTS , _
  byval property  as ATOM)


'### union section ###
declare function XCreateRegion cdecl alias "XCreateRegion" () as Region
declare function XDestroyRegion cdecl alias "XDestroyRegion" ( _
  byval r as Region) as integer

declare function XEmptyRegion cdecl alias "XEmptyRegion" ( _
  byval r as Region) as integer

declare function XEqualRegion cdecl alias "XEqualRegion" ( _
  byval r1 as Region, _
  byval r2 as Region) as integer

declare function XIntersectRegion cdecl alias "XIntersectRegion"  ( _
  byval source_a as REGION ptr, _
  byval source_b as Region ptr , _
  byref region_return as Region ptr) as integer

declare function XOffsetRegion  cdecl alias "XOffsetRegion"  ( _
  byval r  as REGION, _
  byval dx as integer, _
  byval dy as integer) as integer

declare function XPointInRegion cdecl alias "XPointInRegion" ( _
  byval r as REGION, _
  byval x as integer, _
  byval y as integer) as integer

'You can pass EvenOddRule or WindingRule
declare function XPolygonRegion cdecl alias "XPolygonRegion" ( _
  byref points    as XPoint  , _
  byval count     as integer , _
  byval fill_rule as integer) as integer

declare function XRectInRegion  cdecl alias "XRectInRegion"  ( _
  byval r  as REGION  , _
  byval x  as integer , _
  byval y  as integer , _
  byval w  as uinteger, _
  byval h  as uinteger) as integer

declare function XUnionRectWithRegion cdecl alias "XUnionRectWithRegion" ( _
  byref rectangle   as XRECTANGLE, _
  byval src_region  as Region    , _
  byref dest_region as Region) as integer

declare function XUnionRegion cdecl alias "XUnionRegion" ( _
  byval src_a as Region, _
  byval src_b as Region, _
  byref region_return as Region) as integer

declare function XXorRegion cdecl alias "XXorRegion"   ( _
  byval src_a as Region, _
  byval src_b as Region, _
  byref region_return as Region ptr) as integer

declare function XSetRegion cdecl alias "XSetRegion"      ( _
  byval lpDisplay as Display ptr, _
  byval GC        as GCONTEXT, _
  byval r         as Region) as integer

declare function XShrinkRegion cdecl alias "XShrinkRegion" ( _
  byval r  as Region, _
  byval dx as integer, _
  byval dy as integer) as integer

declare sub XSetStandardColormap cdecl alias "XSetStandardColormap" ( _
  byval lpDisplay as Display ptr      , _
  byval hWin      as WINDOWID         , _
  byref colormap  as XSTANDARDCOLORMAP, _
  byval property  as ATOM)

declare function XSetZoomHints cdecl alias "XSetZoomHints"  ( _
  byval lpDisplay as Display ptr, _
  byval hWin      as WINDOWID   , _
  byref zhints    as XSIZEHINTS) as integer

declare function XStringListToTextProperty cdecl alias "XStringListToTextProperty" ( _
  byval list      as zstring ptr ptr, _
  byval count     as integer        , _
  byref text_prop as XTEXTPROPERTY) as integer

declare function XSubtractRegion cdecl alias "XSubtractRegion" ( _
  byval src_a     as Region, _
  byval src_b     as Region, _
  byref r_return  as region) as integer

declare function XmbTextListToTextProperty cdecl alias "XmbTextListToTextProperty" ( _
  byval lpDisplay as Display ptr    , _
  byval list      as zstring ptr ptr, _
  byval count     as integer        , _
  byval style     as XICCEncodingStyle, _
  byref text_prop as XTEXTPROPERTY) as integer

declare function XwcTextListToTextProperty cdecl alias "XwcTextListToTextProperty" ( _
  byval lpDisplay as Display ptr      , _
  byval list      as wchar_t ptr ptr  , _
  byval count     as integer          , _
  byval style     as XICCEncodingStyle, _
  byref text_property_return as XTEXTPROPERTY) as integer

declare function Xutf8TextListToTextProperty cdecl alias "Xutf8TextListToTextProperty" ( _
  byval lpDisplay as Display ptr      , _
  byval list      as wchar_t ptr ptr  , _
  byval count     as integer          , _
  byval style     as XICCEncodingStyle, _
  byref text_property_return as XTEXTPROPERTY) as integer

declare sub      XwcFreeStringList         cdecl alias "XwcFreeStringList"         ( _
  byval list as wchar_t ptr ptr)

declare function XTextPropertyToStringList cdecl alias "XTextPropertyToStringList" ( _
  byref text_property  as XTEXTPROPERTY      , _
  byref list           as zstring ptr ptr ptr, _
  byref count_return   as integer            ) as integer

declare sub XmbSetWMProperties cdecl alias "XmbSetWMProperties" ( _
  byval lpDisplay    as Display ptr    , _
  byval hWin         as WindowID       , _
  byval window_name  as string         , _
  byval icon_name    as string         , _
  byval lpargv       as zstring ptr ptr, _
  byval argc         as integer        , _
  byref normal_hints as XSIZEHINTS     , _
  byref wm_hints     as XWMHINTS       , _
  byref class_hint   as XCLASSHINT     )

declare function XmbTextPropertyToTextList cdecl alias "XmbTextPropertyToTextList" ( _
  byval lpDisplay     as Display ptr        , _
  byval text_property as XTEXTPROPERTY      , _
  byref list_return   as zstring ptr ptr ptr, _
  byref count_return  as integer            ) as integer

declare function XwcTextPropertyToTextList cdecl alias "XwcTextPropertyToTextList" ( _
  byval lpDisplay    as Display ptr         , _
  byval text_prop    as XTEXTPROPERTY       , _
  byref list_return  as wchar_t ptr ptr ptr , _
  byref count_return as integer           ) as integer

declare function Xutf8TextPropertyToTextList cdecl alias "Xutf8TextPropertyToTextList" ( _
  byval lpDisplay    as Display ptr        , _
  byval text_prop    as XTEXTPROPERTY      , _
  byref list_return  as zstring ptr ptr ptr, _
  byref count_return as integer            ) as integer

#endif ' __FB_X11_BI__