; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "BSD 2-clause" license."          |
;|_______________________________________________________________________________________|
;
;  Description: XLib specific constants and structures.
;
;  Target OS: Linux
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________


; X Protocol
 X_PROTOCOL              =       11
 X_PROTOCOL_REVISION     =       0

;X Constants

None            =       0
ParentRelative  =       1
CopyFromParent  =       0
PointerWindow   =       0
InputFocus      =       1
PointerRoot     =       1
AnyPropertyType =       0
AnyKey          =       0
AnyButton       =       0
AllTemporary    =       0
CurrentTime     =       0
NoSymbol        =       0

;Event Masks

NoEventMask              =       0h
KeyPressMask             =       1h
KeyReleaseMask           =       2h
ButtonPressMask          =       4h
ButtonReleaseMask        =       8h
EnterWindowMask          =      10h
LeaveWindowMask          =      20h
PointerMotionMask        =      40h
PointerMotionHintMask    =      80h
Button1MotionMask        =     100h
Button2MotionMask        =     200h
Button3MotionMask        =     400h
Button4MotionMask        =     800h
Button5MotionMask        =    1000h
ButtonMotionMask         =    2000h
KeymapStateMask          =    4000h
ExposureMask             =    8000h
VisibilityChangeMask     =   10000h
StructureNotifyMask      =   20000h
ResizeRedirectMask       =   40000h
SubstructureNotifyMask   =   80000h
SubstructureRedirectMask =  100000h
FocusChangeMask          =  200000h
PropertyChangeMask       =  400000h
ColormapChangeMask       =  800000h
OwnerGrabButtonMask      = 1000000h

AllEventsMask            = 1fbff7fh   ;1ffffffh


QueuedAlready           = 0
QueuedAfterReading      = 1
QueuedAfterFlush        = 2


;Event           Names

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

;Key             Masks

ShiftMask       =       1h
LockMask        =       2h
ControlMask     =       4h
Mod1Mask        =       8h
Mod2Mask        =       10h
Mod3Mask        =       20h
Mod4Mask        =       40h
Mod5Mask        =       80h

;Modifier                Names

ShiftMapIndex   =       0
LockMapIndex    =       1
ControlMapIndex =       2
Mod1MapIndex    =       3
Mod2MapIndex    =       4
Mod3MapIndex    =       5
Mod4MapIndex    =       6
Mod5MapIndex    =       7

;Button          Masks

Button1Mask     =       100h
Button2Mask     =       200h
Button3Mask     =       400h
Button4Mask     =       800h
Button5Mask     =       1000h
AnyModifier     =       10000h

;Button          Names

Button1         =       1
Button2         =       2
Button3         =       3
Button4         =       4
Button5         =       5

;Notify          Modes
NotifyNormal    =       0
NotifyGrab      =       1
NotifyUngrab    =       2
NotifyWhileGrabbed      =       3
NotifyHint      =       1

;Notify          Detail

NotifyAncestor  =       0
NotifyVirtual   =       1
NotifyInferior  =       2
NotifyNonlinear =       3
NotifyNonlinearVirtual  =       4
NotifyPointer   =       5
NotifyPointerRoot       =       6
NotifyDetailNone        =       7

;Visibility              Notify

VisibilityUnobscured    =       0
VisibilityPartiallyObscured     =       1
VisibilityFullyObscured =       2

;Circulation             request

PlaceOnTop      =       0
PlaceOnBottom   =       1

;Protocol                Families

FamilyInternet  =       0
FamilyDECnet    =       1
FamilyChaos     =       2
FamilyInternet6 =       6

;Unspecific              authentication  families

FamilyServerInterpreted =       5

;Property       Notification

PropertyNewValue        =       0
PropertyDelete  =       1

;Color           Map     notification

ColormapUninstalled     =       0
ColormapInstalled       =       1

;Grab            Modes
GrabModeSync    =       0
GrabModeAsync   =       1

;Grab            reply   status
GrabSuccess     =       0
AlreadyGrabbed  =       1
GrabInvalidTime =       2
GrabNotViewable =       3
GrabFrozen      =       4

;AllowEvents             modes
AsyncPointer    =       0
SyncPointer     =       1
ReplayPointer   =       2
AsyncKeyboard   =       3
SyncKeyboard    =       4
ReplayKeyboard  =       5
AsyncBoth       =       6
SyncBoth        =       7

;InputFocus              specific

RevertToNone    =       None
RevertToPointerRoot     =       PointerRoot
RevertToParent  =       2

;Error           Codes
Success                 =       0
BadRequest              =       1
BadValue                =       2
BadWindow               =       3
BadPixmap               =       4
BadAtom                 =       5
BadCursor               =       6
BadFont                 =       7
BadMatch                =       8
BadDrawable             =       9
BadAccess               =       10
BadAlloc                =       11
BadColor                =       12
BadGC                   =       13
BadIDChoice             =       14
BadName                 =       15
BadLength               =       16
BadImplementation       =       17
FirstExtensionError     =       128
LastExtensionError      =       255

;Window          Classes

InputOutput     =       1
InputOnly       =       2

;Window          Attributes
CWBackPixmap    =       1h
CWBackPixel     =       2h
CWBorderPixmap  =       4h
CWBorderPixel   =       8h
CWBitGravity    =       10h
CWWinGravity    =       20h
CWBackingStore  =       40h
CWBackingPlanes =       80h
CWBackingPixel  =       100h
CWOverrideRedirect =    200h
CWSaveUnder     =       400h
CWEventMask     =       800h
CWDontPropagate =       1000h
CWColormap      =       2000h
CWCursor        =       4000h

;ConfigureWindow         Structure
CWX             =       1h
CWY             =       2h
CWWidth         =       4h
CWHeight        =       8h
CWBorderWidth   =       10h
CWSibling       =       20h
CWStackMode     =       40h

;Bit             Gravity
ForgetGravity           =       0
NorthWestGravity        =       1
NorthGravity            =       2
NorthEastGravity        =       3
WestGravity             =       4
CenterGravity           =       5
EastGravity             =       6
SouthWestGravity        =       7
SouthGravity            =       8
SouthEastGravity        =       9
StaticGravity           =       10

;Window          Gravity
UnmapGravity    =       0

;CreateWindow            backing-store   hint
NotUseful       =       0
WhenMapped      =       1
Always  =       2

;GetWindowAttributes             reply
IsUnmapped      =       0
IsUnviewable    =       1
IsViewable      =       2

;Used            in      ChangeSaveSet
SetModeInsert   =       0
SetModeDelete   =       1

;Used            in      ChangeCloseDownMode
DestroyAll      =       0
RetainPermanent =       1
RetainTemporary =       2

;Window          stacking        method  (in     configureWindow)
Above   =       0
Below   =       1
TopIf   =       2
BottomIf        =       3
Opposite        =       4

;Circulation             direction
RaiseLowest     =       0
LowerHighest    =       1

;Property                modes
PropModeReplace =       0
PropModePrepend =       1
PropModeAppend  =       2

;Graphics Functions
GXclear         =       0
GXand           =       1
GXandReverse    =       2
GXcopy          =       3
GXandInverted   =       4
GXnoop          =       5
GXxor           =       6
GXor            =       7
GXnor           =       8
GXequiv         =       9
GXinvert        =       10
GXorReverse     =       11
GXcopyInverted  =       12
GXorInverted    =       13
GXnand          =       14
GXset           =       15

;LineStyle
LineSolid       =       0
LineOnOffDash   =       1
LineDoubleDash  =       2

;capStyle
CapNotLast      =       0
CapButt         =       1
CapRound        =       2
CapProjecting   =       3

;joinStyle
JoinMiter       =       0
JoinRound       =       1
JoinBevel       =       2

;fillStyle
FillSolid       =       0
FillTiled       =       1
FillStippled    =       2
FillOpaqueStippled      =       3

;fillRule

EvenOddRule     =       0
WindingRule     =       1

;subwindow               mode

ClipByChildren  =       0
IncludeInferiors        =       1

;SetClipRectangles               ordering

Unsorted        =       0
YSorted =       1
YXSorted        =       2
YXBanded        =       3

;CoordinateMode          for     drawing routines

CoordModeOrigin =       0
CoordModePrevious       =       1

;Polygon         shapes

Complex =       0
Nonconvex       =       1
Convex  =       2

;Arc             modes   for     PolyFillArc

ArcChord        =       0
ArcPieSlice     =       1

;GC              components

GCFunction      =       1h
GCPlaneMask     =       2h
GCForeground    =       4h
GCBackground    =       8h
GCLineWidth     =       10h
GCLineStyle     =       20h
GCCapStyle      =       40h
GCJoinStyle     =       80h
GCFillStyle     =       100h
GCFillRule      =       200h
GCTile  =       400h
GCStipple       =       800h
GCTileStipXOrigin       =       1000h
GCTileStipYOrigin       =       2000h
GCFont  =       4000h
GCSubwindowMode =       8000h
GCGraphicsExposures     =       10000h
GCClipXOrigin   =       20000h
GCClipYOrigin   =       40000h
GCClipMask      =       80000h
GCDashOffset    =       100000h
GCDashList      =       200000h
GCArcMode       =       400000h

GCLastBit       =       22

struct XRectangle
  .x       dw  ?
  .y       dw  ?
  .width   dw  ?
  .height  dw  ?
ends


GCAll = (1 shl (GCLastBit+1)) -1

struct XGCValues
  .function    dd ?                     ;  logical operation
  .plane_mask  dd ?                     ;  plane mask
  .foreground  dd ?                     ;  foreground pixel
  .background  dd ?                     ;  background pixel
  .line_width  dd ?                     ;  line width (in pixels)
  .line_style  dd ?                     ;  LineSolid, LineOnOffDash, LineDoubleDash
  .cap_style   dd ?                     ;  CapNotLast, CapButt, CapRound, CapProjecting
  .join_style  dd ?                     ;  JoinMiter, JoinRound, JoinBevel
  .fill_style  dd ?                     ;  FillSolid, FillTiled, FillStippled FillOpaqueStippled
  .fill_rule   dd ?                     ;  EvenOddRule, WindingRule
  .arc_mode    dd ?                     ;  ArcChord, ArcPieSlice
  .tile        dd ?                     ;  tile pixmap for tiling operations
  .stipple     dd ?                     ;  stipple 1 plane pixmap for stippling
  .ts_x_origin dd ?                     ;  offset for tile or stipple operations
  .ts_y_origin dd ?
  .font        dd ?                     ;  default text font for text operations
  .subwindow_mode dd ?                  ;  ClipByChildren, IncludeInferiors
  .fraphics_exposures dd ?              ;  boolean, should exposures be generated
  .clip_x_origin dd ?                   ;  origin for clipping
  .clip_y_origin dd ?
  .clip_mask   dd ?                     ;  bitmap clipping; other calls for rects
  .dash_offset dd ?                     ;  patterned/dashed line information
  .dashes      dd ?
ends


;used            in      QueryFont       --      draw    direction

FontLeftToRight =       0
FontRightToLeft =       1

FontChange      =       255

;ImageFormat             --      PutImage,       GetImage

XYBitmap        =       0
XYPixmap        =       1
ZPixmap =       2

;For             CreateColormap

AllocNone       =       0
AllocAll        =       1


;Flags           used    in      StoreNamedColor,        StoreColors

DoRed   =       1h
DoGreen =       2h
DoBlue  =       4h

;QueryBestSize           Class

CursorShape     =       0
TileShape       =       1
StippleShape    =       2

;Keyboard                pointer stuff

AutoRepeatModeOff       =       0
AutoRepeatModeOn        =       1
AutoRepeatModeDefault   =       2

LedModeOff      =       0
LedModeOn       =       1

;masks           for     ChangeKeyboardControl

KBKeyClickPercent       =       1h
KBBellPercent   =       2h
KBBellPitch     =       4h
KBBellDuration  =       8h
KBLed   =       10h
KBLedMode       =       20h
KBKey   =       40h
KBAutoRepeatMode        =       80h

MappingSuccess  =       0
MappingBusy     =       1
MappingFailed   =       2

MappingModifier =       0
MappingKeyboard =       1
MappingPointer  =       2

;Screensaver             stuff

DontPreferBlanking      =       0
PreferBlanking  =       1
DefaultBlanking =       2

DisableScreenSaver      =       0
DisableScreenInterval   =       0

DontAllowExposures      =       0
AllowExposures  =       1
DefaultExposures        =       2

;for             ForceScreenSaver

ScreenSaverReset        =       0
ScreenSaverActive       =       1

;for             ChangeHosts

HostInsert      =       0
HostDelete      =       1

;for             ChangeAccessControl

EnableAccess    =       1
DisableAccess   =       0

;display         classes

StaticGray      =       0
GrayScale       =       1
StaticColor     =       2
PseudoColor     =       3
TrueColor       =       4
DirectColor     =       5


;Byte            order           used    in      imageByteOrder  and     bitmapBitOrder

LSBFirst        =       0
MSBFirst        =       1

;Keyboard and Pointer Event Structures

struct   XButtonEvent
  .type         rd    1
  .serial       rd    1
  .send_event   rd    1
  .display      rd    1
  .window       rd    1
  .root         rd    1
  .subwindow    rd    1
  .time         rd    1
  .x            rd    1
  .y            rd    1
  .x_root       rd    1
  .y_root       rd    1
  .state        rd    1
  .button       rd    1
  .same_screen  rd    1
ends


virtual at 0
XButtonPressedEvent  XButtonEvent
end virtual

virtual at 0
XButtonReleasedEvent XButtonEvent
end virtual

struct   XKeyEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .window                         rd    1
        .root                           rd    1
        .subwindow                      rd    1
        .time                           rd    1
        .x                              rd    1
        .y                              rd    1
        .x_root                         rd    1
        .y_root                         rd    1
        .state                          rd    1
        .keycode                        rd    1
        .same_screen                    rd    1
ends


virtual at 0
XKeyPressedEvent   XKeyEvent
end virtual

virtual at 0
XKeyReleasedEvent  XKeyEvent
end virtual


struct   XMotionEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .window                         rd    1
        .root                           rd    1
        .subwindow                      rd    1
        .time                           rd    1
        .x                              rd    1
        .y                              rd    1
        .x_root                         rd    1
        .y_root                         rd    1
        .state                          rd    1
        .is_hint                        rb    1
        .same_screen                    rd    1
ends


virtual at 0
XPointerMovedEvent  XMotionEvent
end virtual

;Window Entry/Exit Events

struct   XCrossingEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .window                         rd    1
        .root                           rd    1
        .subwindow                      rd    1
        .time                           rd    1
        .x                              rd    1
        .y                              rd    1
        .x_root                         rd    1
        .y_root                         rd    1
        .mode                           rd    1
        .detail                         rd    1
        .same_screen                    rd    1
        .focus                          rd    1
        .state                          rd    1
ends

virtual at 0
XEnterWindowEvent  XCrossingEvent
end virtual

virtual at 0
XLeaveWindowEvent  XCrossingEvent
end virtual

;       Input           Focus   Events

struct   XFocusChangeEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .window                         rd    1
        .mode                           rd    1
        .detail                         rd    1
ends



virtual at 0
XFocusInEvent  XFocusChangeEvent
end virtual

virtual at 0
XFocusOutEvent  XFocusChangeEvent
end virtual

;       Keymap          Notification    Events

struct   XKeymapEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .window                         rd    1
        .key_vector                     rb    32
ends

;       Exposure/Update         Events

struct   XExposeEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .window                         rd    1
        .x                              rd    1
        .y                              rd    1
        .width                          rd    1
        .height                         rd    1
        .count                          rd    1
ends


struct   XGraphicsExposeEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .drawable                       rd    1
        .x                              rd    1
        .y                              rd    1
        .width                          rd    1
        .height                         rd    1
        .count                          rd    1
        .major_code                     rd    1
        .minor_code                     rd    1
ends


struct   XNoExposeEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .drawable                       rd    1
        .major_code                     rd    1
        .minor_code                     rd    1
ends


;       CirculateNotify         Events

struct   XCirculateEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .event                          rd    1
        .window                         rd    1
        .place                          rd    1
ends


struct   XCirculateRequestEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .parent                         rd    1
        .window                         rd    1
        .place                          rd    1
ends

;       Configuration           Change  Events

struct   XConfigureEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .event                          rd    1
        .window                         rd    1
        .x                              rd    1
        .y                              rd    1
        .width                          rd    1
        .height                         rd    1
        .border_width                   rd    1
        .above                          rd    1
        .override_redirect              rd    1
ends

struct   XConfigureRequestEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .parent                         rd    1
        .window                         rd    1
        .x                              rd    1
        .y                              rd    1
        .width                          rd    1
        .height                         rd    1
        .border_width                   rd    1
        .above                          rd    1
        .detail                         rd    1
        .value_mask                     rd    1
ends

struct   XPropertyEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .window                         rd    1
        .atom                           rd    1
        .time                           rd    1
        .state                          rd    1
ends

struct   XResizeEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .window                         rd    1
        .width                          rd    1
        .height                         rd    1
ends

struct   XColormapEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .window                         rd    1
        .colormap                       rd    1
        .new                            rd    1
        .state                          rd    1
ends

;       Creation/Destruction            Notifications

struct   XCreateWindowEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .parent                         rd    1
        .window                         rd    1
        .x                              rd    1
        .y                              rd    1
        .width                          rd    1
        .heigth                         rd    1
        .border_width                   rd    1
        .override_redirect              rd    1
ends


struct   XDestroyWindowEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .event                          rd    1
        .window                         rd    1
ends

;       Parent          Movement        Events

struct   XGravityEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .event                          rd    1
        .window                         rd    1
        .x                              rd    1
        .y                              rd    1
ends

;       Mapping         Events

struct   XMapEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .event                          rd    1
        .window                         rd    1
        .override_redirect              rd    1
ends

struct   XMappingEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .window                         rd    1
        .request                        rd    1
        .first_keycode                  rd    1
        .count                          rd    1
ends


struct   XMapRequestEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .parent                         rd    1
        .window                         rd    1
ends

;       Parent          Change  Events

struct   XReparentEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .event                          rd    1
        .window                         rd    1
        .parent                         rd    1
        .x                              rd    1
        .y                              rd    1
        .override_redirect              rd    1
ends

struct   XSelectionClearEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .window                         rd    1
        .selection                      rd    1
        .time                           rd    1
ends

struct   XSelectionRequestEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .owner                          rd    1
        .requestor                      rd    1
        .selection                      rd    1
        .target                         rd    1
        .property                       rd    1
        .time                           rd    1
ends

struct   XSelectionEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .requestor                      rd    1
        .selection                      rd    1
        .target                         rd    1
        .property                       rd    1
        .time                           rd    1
ends

;       Hidden          Window  Events

struct   XUnmapEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .event                          rd    1
        .window                         rd    1
        .from_configure                 rd    1
ends

struct   XVisibilityEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .window                         rd    1
        .state                          rd    1
ends

;       Client          Messages        (XSendEvent)

struct   XClientMessageEvent
  .type                           rd    1
  .serial                         rd    1
  .send_event                     rd    1
  .display                        rd    1
  .window                         rd    1
  .message_type                   rd    1
  .format                         rd    1
  .data                           rb    20
ends


struct   XErrorEvent
  .type         dd    ?
  .display      dd    ?
  .resourceid   dd    ?
  .serial       dd    ?
  .error_code   db    ?
  .request_code db    ?
  .minor_code   db    ?
ends



struct XAnyEvent
  .type         rd    1
  .serial       rd    1
  .send_event   rd    1
  .display      rd    1
  .window       rd    1
ends


struct XEvent
  .xany XAnyEvent
  .pad  rb 24*4 - sizeof.XAnyEvent

  virtual at .xany
  . XAnyEvent
  end virtual
;
;
;  virtual at .xany
;  .xkey XKeyEvent
;  end virtual
;
;  virtual at .xany
;  .xbutton XButtonEvent
;  end virtual
;
;  virtual at .xany
;  .xmotion XMotionEvent
;  end virtual
;
;  virtual at .xany
;  .xcrossing XCrossingEvent
;  end virtual
;
;  virtual at .xany
;  .xfocus XFocusChangeEvent
;  end virtual
;
;  virtual at .xany
;  .xexpose XExposeEvent
;  end virtual
;
;  virtual at .xany
;  .xgraphicsexpose XGraphicsExposeEvent
;  end virtual
;
;  virtual at .xany
;  .xnoexpose XNoExposeEvent
;  end virtual
;
;  virtual at .xany
;  .xvisibility XVisibilityEvent
;  end virtual
;
;  virtual at .xany
;  .xcreatewindow XCreateWindowEvent
;  end virtual
;
;  virtual at .xany
;  .xdestroywindow XDestroyWindowEvent
;  end virtual
;
;  virtual at .xany
;  .xunmap XUnmapEvent
;  end virtual
;
;  virtual at .xany
;  .xmap XMapEvent
;  end virtual
;
;  virtual at .xany
;  .xmaprequest XMapRequestEvent
;  end virtual
;
;  virtual at .xany
;  .xreparent XReparentEvent
;  end virtual
;
;  virtual at .xany
;  .xconfigure XConfigureEvent
;  end virtual
;
;  virtual at .xany
;  .xgravity XGravityEvent
;  end virtual
;
;  virtual at .xany
;  .xresizerequest XResizeEvent
;  end virtual
;
;  virtual at .xany
;  .xconfigurerequest XConfigureRequestEvent
;  end virtual
;
;  virtual at .xany
;  .xcirculate XCirculateEvent
;  end virtual
;
;  virtual at .xany
;  .xcirculaterequest XCirculateRequestEvent
;  end virtual
;
;  virtual at .xany
;  .xproperty XPropertyEvent
;  end virtual
;
;  virtual at .xany
;  .xselectionclear XSelectionClearEvent
;  end virtual
;
;  virtual at .xany
;  .xselectionrequest XSelectionRequestEvent
;  end virtual
;
;  virtual at .xany
;  .xselection XSelectionEvent
;  end virtual
;
;  virtual at .xany
;  .xcolormap XColormapEvent
;  end virtual
;
;  virtual at .xany
;  .xclient XClientMessageEvent
;  end virtual
;
;  virtual at .xany
;  .xmapping XMappingEvent
;  end virtual
;
;  virtual at .xany
;  .xerror XErrorEvent
;  end virtual
;
;  virtual at .xany
;  .xkeymap XKeymapEvent
;  end virtual
ends


;       Misc.           Structures

struct   XKeyboardControl
        .key_click_percent              rd    1
        .bell_percent                   rd    1
        .bell_pitch                     rd    1
        .bell_duration                  rd    1
        .led                            rd    1
        .led_mode                       rd    1
        .key                            rd    1
        .auto_repeat_mode               rd    1
ends



struct   XModifierKeymap
        .max_keypermod                  rd    1
        .modifiermap                    rd    1
ends


struct XVisualInfo
  .Visual     dd ?
  .VisualID   dd ?
  .screen     dd ?
  .depth      dd ?
  .class      dd ?
  .red_mask   dd ?
  .green_mask dd ?
  .blue_mask  dd ?
  .colormap_size dd ?
  .bits_per_rgb  dd ?
ends




struct XWindowAttributes
  .x                     dd  ?     ; location of window
  .y                     dd  ?     ;
  .width                 dd  ?     ; width and height of window
  .height                dd  ?     ;
  .border_width          dd  ?     ; border width of window
  .depth                 dd  ?     ; depth of window
  .pVisual               dd  ?     ; the associated visual structure
  .root                  dd  ?     ; root of screen containing window
  .class                 dd  ?     ; InputOutput, InputOnly

  .bit_gravity           dd  ?     ; one of the bit gravity values
  .win_gravity           dd  ?     ; one of the window gravity values
  .backing_store         dd  ?     ; NotUseful, WhenMapped, Always
  .backing_planes        dd  ?     ; planes to be preserved if possible
  .backing_pixel         dd  ?     ; value to be used when restoring planes
  .save_under            dd  ?     ; boolean, should bits under be saved?
  .colormap              dd  ?     ; color map to be associated with window
  .map_installed         dd  ?     ; boolean, is color map currently installed
  .map_state             dd  ?     ; IsUnmapped, IsUnviewable, IsViewable
  .all_event_masks       dd  ?    ; set of events all people have interest in
  .your_event_mask       dd  ?          ; my event mask
  .do_not_propagate_mask dd  ?    ; set of events that should not propagate
  .override_redirect     dd  ?    ; boolean value for override-redirect
  .pScreen               dd  ?  ; back pointer to correct screen
ends


struct XSetWindowAttributes
  .background_pixmap    dd  ?           ; background, None, or ParentRelative
  .background_pixel     dd  ?           ; background pixel
  .border_pixmap        dd  ?           ; border of the window or CopyFromParent
  .border_pixel         dd  ?           ; border pixel value
  .bit_gravity          dd  ?           ; one of bit gravity values
  .win_gravity          dd  ?           ; one of the window gravity values
  .backing_store        dd  ?           ; NotUseful, WhenMapped, Always
  .backing_planes       dd  ?           ; planes to be preserved if possible
  .backing_pixel        dd  ?           ; value to use in restoring planes
  .save_under           dd  ?           ; should bits under be saved? (popups)
  .event_mask           dd  ?           ; set of events that should be saved
  .do_not_propagate_mask dd ?           ; set of events that should not propagate
  .override_redirect    dd  ?           ; boolean value for override_redirect
  .colormap             dd  ?           ; color map to be associated with window
  .cursor               dd  ?           ; cursor to be displayed (or None)
ends



struct XCharStruct
  .lbearing   dw ?       ; origin to left edge of raster
  .rbearing   dw ?       ; origin to right edge of raster
  .width      dw ?       ; advance to next char's origin
  .ascent     dw ?       ; baseline to top edge of raster
  .descent    dw ?       ; baseline to bottom edge of raster
  .attributes dw ?       ; per char flags (not predefined)
ends


struct XFontStruct
  .ext_data          dd   ?       ; hook for extension to hang data
  .fid               dd   ?       ; Font id for this font
  .direction         dd   ?       ; hint about the direction font is painted
  .min_char_or_byte2 dd   ?       ; first character
  .max_char_or_byte2 dd   ?       ; last character
  .min_byte1         dd   ?       ; first row that exists
  .max_byte1         dd   ?       ; last row that exists
  .all_chars_exist   dd   ?       ; flag if all characters have nonzero size
  .default_char      dd   ?       ; char to print for undefined character
  .n_properties      dd   ?       ; how many properties there are
  .properties        dd   ?       ; pointer to array of additional properties
  .min_bounds        XCharStruct  ; minimum bounds over all existing char
  .max_bounds        XCharStruct  ; maximum bounds over all existing char
  .per_char          dd   ?       ; first_char to last_char information
  .ascent            dd   ?       ; logical extent above baseline for spacing
  .descent           dd   ?       ; logical decent below baseline for spacing
ends


struct XWindowChanges
  .x            dd ?
  .y            dd ?
  .width        dd ?
  .height       dd ?
  .border_width dd ?
  .sibling      dd ?
  .stack_mode   dd ?
ends


struct XImage
  .width        dd ?                         ; size of image
  .height       dd ?
  .xoffset      dd ?                         ; number of pixels offset in X direction
  .format       dd ?                         ; XYBitmap, XYPixmap, ZPixmap
  .pData        dd ?                         ; pointer to image data
  .byte_order   dd ?                         ; data byte order, LSBFirst=0, MSBFirst=1
  .bitmap_unit  dd ?                         ; quantity of scan line 8, 16, 32
  .bitmap_bit_order dd ?                     ; LSBFirst, MSBFirst
  .bitmap_pad   dd ?                         ; 8, 16, 32 either XY or ZPixmap
  .depth        dd ?                         ; depth of image
  .bytes_per_line dd ?                       ; accelerator to next line
  .bits_per_pixel dd ?                       ; bits per pixel (ZPixmap)
  .red_mask       dd ?                       ; bits in z arrangment
  .green_mask     dd ?                       ; bits in z arrangment
  .blue_mask      dd ?                       ; bits in z arrangment
  .ptrObData      dd ?                       ; hook for object routines to hang on

  .funcCreateImage dd ?                      ; image manipulation routines
  .funcDestroyImage dd ?                     ;
  .funcGetPixel     dd ?
  .funcPutPixel     dd ?
  .funcSubImage     dd ?
  .funcAddPixel     dd ?
ends


struct XWMHints
  .flags dd ?
  .input dd ?
  .initial_state dd ?
  .icon_pixmap   dd ?
  .icon_window   dd ?
  .icon_x        dd ?
  .icon_y        dd ?
  .icon_mask     dd ?
  .window_group  dd ?
ends


InputHint       =       1
StateHint       =       2
IconPixmapHint  =       4
IconWindowHint  =       8
IconPositionHint=       16
IconMaskHint    =       32
WindowGroupHint =       64
UrgencyHint     =       128
AllHints = InputHint or StateHint or IconPixmapHint or IconWindowHint or IconPositionHint or IconMaskHint or WindowGroupHint or UrgencyHint


WithdrawnState  = 0
NormalState = 1
IconicState = 3


; RequestCodes
Xrequests = 0
.CreateWindow            =1
.ChangeWindowAttributes  =2
.GetWindowAttributes     =3
.DestroyWindow           =4
.DestroySubwindows       =5
.ChangeSaveSet           =6
.ReparentWindow          =7
.MapWindow               =8
.MapSubwindows           =9
.UnmapWindow             =10
.UnmapSubwindows         =11
.ConfigureWindow         =12
.CirculateWindow         =13
.GetGeometry             =14
.QueryTree               =15
.InternAtom              =16
.GetAtomName             =17
.ChangeProperty          =18
.DeleteProperty          =19
.GetProperty             =20
.ListProperties          =21
.SetSelectionOwner       =22
.GetSelectionOwner       =23
.ConvertSelection        =24
.SendEvent               =25
.GrabPointer             =26
.UngrabPointer           =27
.GrabButton              =28
.UngrabButton            =29
.ChangeActivePointerGrab =30
.GrabKeyboard            =31
.UngrabKeyboard          =32
.GrabKey                 =33
.UngrabKey               =34
.AllowEvents             =35
.GrabServer              =36
.UngrabServer            =37
.QueryPointer            =38
.GetMotionEvents         =39
.TranslateCoords         =40
.WarpPointer             =41
.SetInputFocus           =42
.GetInputFocus           =43
.QueryKeymap             =44
.OpenFont                =45
.CloseFont               =46
.QueryFont               =47
.QueryTextExtents        =48
.ListFonts               =49
.ListFontsWithInfo       =50
.SetFontPath             =51
.GetFontPath             =52
.CreatePixmap            =53
.FreePixmap              =54
.CreateGC                =55
.ChangeGC                =56
.CopyGC                  =57
.SetDashes               =58
.SetClipRectangles       =59
.FreeGC                  =60
.ClearArea               =61
.CopyArea                =62
.CopyPlane               =63
.PolyPoint               =64
.PolyLine                =65
.PolySegment             =66
.PolyRectangle           =67
.PolyArc                 =68
.FillPoly                =69
.PolyFillRectangle       =70
.PolyFillArc             =71
.PutImage                =72
.GetImage                =73
.PolyText8               =74
.PolyText16              =75
.ImageText8              =76
.ImageText16             =77
.CreateColormap          =78
.FreeColormap            =79
.CopyColormapAndFree     =80
.InstallColormap         =81
.UninstallColormap       =82
.ListInstalledColormaps  =83
.AllocColor              =84
.AllocNamedColor         =85
.AllocColorCells         =86
.AllocColorPlanes        =87
.FreeColors              =88
.StoreColors             =89
.StoreNamedColor         =90
.QueryColors             =91
.LookupColor             =92
.CreateCursor            =93
.CreateGlyphCursor       =94
.FreeCursor              =95
.RecolorCursor           =96
.QueryBestSize           =97
.QueryExtension          =98
.ListExtensions          =99
.ChangeKeyboardMapping   =100
.GetKeyboardMapping      =101
.ChangeKeyboardControl   =102
.GetKeyboardControl      =103
.Bell                    =104
.ChangePointerControl    =105
.GetPointerControl       =106
.SetScreenSaver          =107
.GetScreenSaver          =108
.ChangeHosts             =109
.ListHosts               =110
.SetAccessControl        =111
.SetCloseDownMode        =112
.KillClient              =113
.RotateProperties        =114
.ForceScreenSaver        =115
.SetPointerMapping       =116
.GetPointerMapping       =117
.SetModifierMapping      =118
.GetModifierMapping      =119
.NoOperation             =127


; Predefined atoms from the X server.

XA_PRIMARY      = 1
XA_SECONDARY    = 2
XA_ARC          = 3
XA_ATOM         = 4
XA_BITMAP       = 5
XA_CARDINAL     = 6
XA_COLORMAP     = 7
XA_CURSOR       = 8
XA_CUT_BUFFER0  = 9
XA_CUT_BUFFER1  = 10
XA_CUT_BUFFER2  = 11
XA_CUT_BUFFER3  = 12
XA_CUT_BUFFER4  = 13
XA_CUT_BUFFER5  = 14
XA_CUT_BUFFER6  = 15
XA_CUT_BUFFER7  = 16
XA_DRAWABLE     = 17
XA_FONT         = 18
XA_INTEGER      = 19
XA_PIXMAP       = 20
XA_POINT        = 21
XA_RECTANGLE    = 22
XA_RESOURCE_MANAGER = 23
XA_RGB_COLOR_MAP = 24
XA_RGB_BEST_MAP  = 25
XA_RGB_BLUE_MAP = 26
XA_RGB_DEFAULT_MAP = 27
XA_RGB_GRAY_MAP = 28
XA_RGB_GREEN_MAP = 29
XA_RGB_RED_MAP  = 30
XA_STRING       = 31
XA_VISUALID     = 32
XA_WINDOW       = 33
XA_WM_COMMAND   = 34
XA_WM_HINTS     = 35
XA_WM_CLIENT_MACHINE = 36
XA_WM_ICON_NAME = 37
XA_WM_ICON_SIZE = 38
XA_WM_NAME      = 39
XA_WM_NORMAL_HINTS = 40
XA_WM_SIZE_HINTS = 41
XA_WM_ZOOM_HINTS = 42
XA_MIN_SPACE     = 43
XA_NORM_SPACE    = 44
XA_MAX_SPACE     = 45
XA_END_SPACE     = 46
XA_SUPERSCRIPT_X = 47
XA_SUPERSCRIPT_Y = 48
XA_SUBSCRIPT_X   = 49
XA_SUBSCRIPT_Y   = 50
XA_UNDERLINE_POSITION = 51
XA_UNDERLINE_THICKNESS = 52
XA_STRIKEOUT_ASCENT = 53
XA_STRIKEOUT_DESCENT = 54
XA_ITALIC_ANGLE  = 55
XA_X_HEIGHT      = 56
XA_QUAD_WIDTH    = 57
XA_WEIGHT        = 58
XA_POINT_SIZE    = 59
XA_RESOLUTION    = 60
XA_COPYRIGHT     = 61
XA_NOTICE        = 62
XA_FONT_NAME     = 63
XA_FAMILY_NAME   = 64
XA_FULL_NAME     = 65
XA_CAP_HEIGHT    = 66
XA_WM_CLASS      = 67
XA_WM_TRANSIENT_FOR = 68

XA_LAST_PREDEFINED = 68
