1 ! Copyright (C) 2005, 2006 Eduardo Cavazos and Alex Chapman, 2016 Björn Lindqvist
2 ! https://factorcode.org/license.txt for BSD license.
4 ! Selected parts of /usr/include/X11/X.h
5 USING: alien.c-types alien.syntax math ;
21 TYPEDEF: uchar KeyCode
23 ! Reserved resource and constant definitions
24 CONSTANT: ParentRelative 1
25 CONSTANT: CopyFromParent 0
26 CONSTANT: PointerWindow 0
27 CONSTANT: InputFocus 1
28 CONSTANT: PointerRoot 1
29 CONSTANT: AnyPropertyType 0
32 CONSTANT: AllTemporary 0
33 CONSTANT: CurrentTime 0
38 ! Input Event Masks. Used as event-mask window attribute and as
39 ! arguments to Grab requests. Not to be confused with event names.
40 : NoEventMask ( -- n ) 0 ; inline
41 : KeyPressMask ( -- n ) 0 2^ ; inline
42 : KeyReleaseMask ( -- n ) 1 2^ ; inline
43 : ButtonPressMask ( -- n ) 2 2^ ; inline
44 : ButtonReleaseMask ( -- n ) 3 2^ ; inline
45 : EnterWindowMask ( -- n ) 4 2^ ; inline
46 : LeaveWindowMask ( -- n ) 5 2^ ; inline
47 : PointerMotionMask ( -- n ) 6 2^ ; inline
48 : PointerMotionHintMask ( -- n ) 7 2^ ; inline
49 : Button1MotionMask ( -- n ) 8 2^ ; inline
50 : Button2MotionMask ( -- n ) 9 2^ ; inline
51 : Button3MotionMask ( -- n ) 10 2^ ; inline
52 : Button4MotionMask ( -- n ) 11 2^ ; inline
53 : Button5MotionMask ( -- n ) 12 2^ ; inline
54 : ButtonMotionMask ( -- n ) 13 2^ ; inline
55 : KeymapStateMask ( -- n ) 14 2^ ; inline
56 : ExposureMask ( -- n ) 15 2^ ; inline
57 : VisibilityChangeMask ( -- n ) 16 2^ ; inline
58 : StructureNotifyMask ( -- n ) 17 2^ ; inline
59 : ResizeRedirectMask ( -- n ) 18 2^ ; inline
60 : SubstructureNotifyMask ( -- n ) 19 2^ ; inline
61 : SubstructureRedirectMask ( -- n ) 20 2^ ; inline
62 : FocusChangeMask ( -- n ) 21 2^ ; inline
63 : PropertyChangeMask ( -- n ) 22 2^ ; inline
64 : ColormapChangeMask ( -- n ) 23 2^ ; inline
65 : OwnerGrabButtonMask ( -- n ) 24 2^ ; inline
67 ! Event names. Used in "type" field in XEvent structures. Not to be
68 ! confused with event masks above. They start from 2 because 0 and 1
69 ! are reserved in the protocol for errors and replies.
71 CONSTANT: KeyRelease 3
72 CONSTANT: ButtonPress 4
73 CONSTANT: ButtonRelease 5
74 CONSTANT: MotionNotify 6
75 CONSTANT: EnterNotify 7
76 CONSTANT: LeaveNotify 8
79 CONSTANT: KeymapNotify 11
81 CONSTANT: GraphicsExpose 13
83 CONSTANT: VisibilityNotify 15
84 CONSTANT: CreateNotify 16
85 CONSTANT: DestroyNotify 17
86 CONSTANT: UnmapNotify 18
87 CONSTANT: MapNotify 19
88 CONSTANT: MapRequest 20
89 CONSTANT: ReparentNotify 21
90 CONSTANT: ConfigureNotify 22
91 CONSTANT: ConfigureRequest 23
92 CONSTANT: GravityNotify 24
93 CONSTANT: ResizeRequest 25
94 CONSTANT: CirculateNotify 26
95 CONSTANT: CirculateRequest 27
96 CONSTANT: PropertyNotify 28
97 CONSTANT: SelectionClear 29
98 CONSTANT: SelectionRequest 30
99 CONSTANT: SelectionNotify 31
100 CONSTANT: ColormapNotify 32
101 CONSTANT: ClientMessage 33
102 CONSTANT: MappingNotify 34
103 CONSTANT: GenericEvent 35
104 CONSTANT: LASTEvent 36
106 ! Key masks. Used as modifiers to GrabButton and GrabKey, results of
107 ! QueryPointer, state in various key-, mouse-, and button-related
109 : ShiftMask ( -- n ) 1 0 shift ; inline
110 : LockMask ( -- n ) 1 1 shift ; inline
111 : ControlMask ( -- n ) 1 2 shift ; inline
112 : Mod1Mask ( -- n ) 1 3 shift ; inline
113 : Mod2Mask ( -- n ) 1 4 shift ; inline
114 : Mod3Mask ( -- n ) 1 5 shift ; inline
115 : Mod4Mask ( -- n ) 1 6 shift ; inline
116 : Mod5Mask ( -- n ) 1 7 shift ; inline
118 ! modifier names. Used to build a SetModifierMapping request or
119 ! to read a GetModifierMapping request. These correspond to the
120 ! masks defined above.
121 CONSTANT: ShiftMapIndex 0
122 CONSTANT: LockMapIndex 1
123 CONSTANT: ControlMapIndex 2
124 CONSTANT: Mod1MapIndex 3
125 CONSTANT: Mod2MapIndex 4
126 CONSTANT: Mod3MapIndex 5
127 CONSTANT: Mod4MapIndex 6
128 CONSTANT: Mod5MapIndex 7
130 ! button masks. Used in same manner as Key masks above. Not to be
131 ! confused with button names below.
132 : Button1Mask ( -- n ) 1 8 shift ; inline
133 : Button2Mask ( -- n ) 1 9 shift ; inline
134 : Button3Mask ( -- n ) 1 10 shift ; inline
135 : Button4Mask ( -- n ) 1 11 shift ; inline
136 : Button5Mask ( -- n ) 1 12 shift ; inline
138 : AnyModifier ( -- n ) 15 2^ ; ! used in GrabButton, GrabKey
140 ! button names. Used as arguments to GrabButton and as detail in
141 ! ButtonPress and ButtonRelease events. Not to be confused with
142 ! button masks above. Note that 0 is already defined above as
152 CONSTANT: NotifyNormal 0
153 CONSTANT: NotifyGrab 1
154 CONSTANT: NotifyUngrab 2
155 CONSTANT: NotifyWhileGrabbed 3
157 CONSTANT: NotifyHint 1 ! for MotionNotify events
161 CONSTANT: NotifyAncestor 0
162 CONSTANT: NotifyVirtual 1
163 CONSTANT: NotifyInferior 2
164 CONSTANT: NotifyNonlinear 3
165 CONSTANT: NotifyNonlinearVirtual 4
166 CONSTANT: NotifyPointer 5
167 CONSTANT: NotifyPointerRoot 6
168 CONSTANT: NotifyDetailNone 7
172 CONSTANT: VisibilityUnobscured 0
173 CONSTANT: VisibilityPartiallyObscured 1
174 CONSTANT: VisibilityFullyObscured 2
176 ! Circulation request
178 CONSTANT: PlaceOnTop 0
179 CONSTANT: PlaceOnBottom 1
183 CONSTANT: FamilyInternet 0 ! IPv4
184 CONSTANT: FamilyDECnet 1
185 CONSTANT: FamilyChaos 2
186 CONSTANT: FamilyInternet6 6 ! IPv6
188 ! authentication families not tied to a specific protocol
189 CONSTANT: FamilyServerInterpreted 5
191 ! Property notification
193 CONSTANT: PropertyNewValue 0
194 CONSTANT: PropertyDelete 1
196 ! Color Map notification
198 CONSTANT: ColormapUninstalled 0
199 CONSTANT: ColormapInstalled 1
201 ! GrabPointer, GrabButton, GrabKeyboard, GrabKey Modes
203 CONSTANT: GrabModeSync 0
204 CONSTANT: GrabModeAsync 1
206 ! GrabPointer, GrabKeyboard reply status
208 CONSTANT: GrabSuccess 0
209 CONSTANT: AlreadyGrabbed 1
210 CONSTANT: GrabInvalidTime 2
211 CONSTANT: GrabNotViewable 3
212 CONSTANT: GrabFrozen 4
216 CONSTANT: AsyncPointer 0
217 CONSTANT: SyncPointer 1
218 CONSTANT: ReplayPointer 2
219 CONSTANT: AsyncKeyboard 3
220 CONSTANT: SyncKeyboard 4
221 CONSTANT: ReplayKeyboard 5
222 CONSTANT: AsyncBoth 6
225 ! Used in SetInputFocus, GetInputFocus
227 : RevertToNone ( -- n ) None ;
228 : RevertToPointerRoot ( -- n ) PointerRoot ;
229 CONSTANT: RevertToParent 2
231 ! *****************************************************************
233 ! *****************************************************************
235 CONSTANT: Success 0 ! everything's okay
236 CONSTANT: BadRequest 1 ! bad request code
237 CONSTANT: BadValue 2 ! int parameter out of range
238 CONSTANT: BadWindow 3 ! parameter not a Window
239 CONSTANT: BadPixmap 4 ! parameter not a Pixmap
240 CONSTANT: BadAtom 5 ! parameter not an Atom
241 CONSTANT: BadCursor 6 ! parameter not a Cursor
242 CONSTANT: BadFont 7 ! parameter not a Font
243 CONSTANT: BadMatch 8 ! parameter mismatch
244 CONSTANT: BadDrawable 9 ! parameter not a Pixmap or Window
245 CONSTANT: BadAccess 10 ! depending on context:
246 ! - key/button already grabbed
247 ! - attempt to free an illegal
249 ! - attempt to store into a read-only
251 ! - attempt to modify the access control
252 ! list from other than the local host.
253 CONSTANT: BadAlloc 11 ! insufficient resources
254 CONSTANT: BadColor 12 ! no such colormap
255 CONSTANT: BadGC 13 ! parameter not a GC
256 CONSTANT: BadIDChoice 14 ! choice not in range or already used
257 CONSTANT: BadName 15 ! font or color name doesn't exist
258 CONSTANT: BadLength 16 ! Request length incorrect
259 CONSTANT: BadImplementation 17 ! server is defective
261 CONSTANT: FirstExtensionError 128
262 CONSTANT: LastExtensionError 255
264 ! *****************************************************************
265 ! * WINDOW DEFINITIONS
266 ! *****************************************************************
268 ! Window classes used by CreateWindow
269 ! Note that CopyFromParent is already defined as 0 above
271 CONSTANT: InputOutput 1
272 CONSTANT: InputOnly 2
274 ! ConfigureWindow structure
275 : CWX ( -- n ) 0 2^ ; inline
276 : CWY ( -- n ) 1 2^ ; inline
277 : CWWidth ( -- n ) 2 2^ ; inline
278 : CWHeight ( -- n ) 3 2^ ; inline
279 : CWBorderWidth ( -- n ) 4 2^ ; inline
280 : CWSibling ( -- n ) 5 2^ ; inline
281 : CWStackMode ( -- n ) 6 2^ ; inline
285 CONSTANT: ForgetGravity 0
286 CONSTANT: NorthWestGravity 1
287 CONSTANT: NorthGravity 2
288 CONSTANT: NorthEastGravity 3
289 CONSTANT: WestGravity 4
290 CONSTANT: CenterGravity 5
291 CONSTANT: EastGravity 6
292 CONSTANT: SouthWestGravity 7
293 CONSTANT: SouthGravity 8
294 CONSTANT: SouthEastGravity 9
295 CONSTANT: StaticGravity 10
297 ! Window gravity + bit gravity above
299 CONSTANT: UnmapGravity 0
301 ! Used in CreateWindow for backing-store hint
303 CONSTANT: NotUseful 0
304 CONSTANT: WhenMapped 1
307 ! Used in GetWindowAttributes reply
308 CONSTANT: IsUnmapped 0
309 CONSTANT: IsUnviewable 1
310 CONSTANT: IsViewable 2
313 ! Used in ChangeSaveSet
315 CONSTANT: SetModeInsert 0
316 CONSTANT: SetModeDelete 1
318 ! Used in ChangeCloseDownMode
320 CONSTANT: DestroyAll 0
321 CONSTANT: RetainPermanent 1
322 CONSTANT: RetainTemporary 2
324 ! Window stacking method (in configureWindow)
332 ! Circulation direction
334 CONSTANT: RaiseLowest 0
335 CONSTANT: LowerHighest 1
339 CONSTANT: PropModeReplace 0
340 CONSTANT: PropModePrepend 1
341 CONSTANT: PropModeAppend 2
343 ! *****************************************************************
344 ! * GRAPHICS DEFINITIONS
345 ! *****************************************************************
347 ! graphics functions, as in GC.alu
349 CONSTANT: GXclear 0x0
351 CONSTANT: GXandReverse 0x2
353 CONSTANT: GXandInverted 0x4
358 CONSTANT: GXequiv 0x9
359 CONSTANT: GXinvert 0xa
360 CONSTANT: GXorReverse 0xb
361 CONSTANT: GXcopyInverted 0xc
362 CONSTANT: GXorInverted 0xd
368 CONSTANT: LineSolid 0
369 CONSTANT: LineOnOffDash 1
370 CONSTANT: LineDoubleDash 2
374 CONSTANT: CapNotLast 0
377 CONSTANT: CapProjecting 3
381 CONSTANT: JoinMiter 0
382 CONSTANT: JoinRound 1
383 CONSTANT: JoinBevel 2
387 CONSTANT: FillSolid 0
388 CONSTANT: FillTiled 1
389 CONSTANT: FillStippled 2
390 CONSTANT: FillOpaqueStippled 3
394 CONSTANT: EvenOddRule 0
395 CONSTANT: WindingRule 1
399 CONSTANT: ClipByChildren 0
400 CONSTANT: IncludeInferiors 1
402 ! SetClipRectangles ordering
409 ! CoordinateMode for drawing routines
411 CONSTANT: CoordModeOrigin 0 ! relative to the origin
412 CONSTANT: CoordModePrevious 1 ! relative to previous point
416 CONSTANT: Complex 0 ! paths may intersect
417 CONSTANT: Nonconvex 1 ! no paths intersect, but not convex
418 CONSTANT: Convex 2 ! wholly convex
420 ! Arc modes for PolyFillArc
422 CONSTANT: ArcChord 0 ! join endpoints of arc
423 CONSTANT: ArcPieSlice 1 ! join endpoints to center of arc
425 ! GC components: masks used in CreateGC, CopyGC, ChangeGC, OR'ed into
428 : GCFunction ( -- n ) 0 2^ ; inline
429 : GCPlaneMask ( -- n ) 1 2^ ; inline
430 : GCForeground ( -- n ) 2 2^ ; inline
431 : GCBackground ( -- n ) 3 2^ ; inline
432 : GCLineWidth ( -- n ) 4 2^ ; inline
433 : GCLineStyle ( -- n ) 5 2^ ; inline
434 : GCCapStyle ( -- n ) 6 2^ ; inline
435 : GCJoinStyle ( -- n ) 7 2^ ; inline
436 : GCFillStyle ( -- n ) 8 2^ ; inline
437 : GCFillRule ( -- n ) 9 2^ ; inline
438 : GCTile ( -- n ) 10 2^ ; inline
439 : GCStipple ( -- n ) 11 2^ ; inline
440 : GCTileStipXOrigin ( -- n ) 12 2^ ; inline
441 : GCTileStipYOrigin ( -- n ) 13 2^ ; inline
442 : GCFont ( -- n ) 14 2^ ; inline
443 : GCSubwindowMode ( -- n ) 15 2^ ; inline
444 : GCGraphicsExposures ( -- n ) 16 2^ ; inline
445 : GCClipXOrigin ( -- n ) 17 2^ ; inline
446 : GCClipYOrigin ( -- n ) 18 2^ ; inline
447 : GCClipMask ( -- n ) 19 2^ ; inline
448 : GCDashOffset ( -- n ) 20 2^ ; inline
449 : GCDashList ( -- n ) 21 2^ ; inline
450 : GCArcMode ( -- n ) 22 2^ ; inline
452 ! *****************************************************************
454 ! *****************************************************************
456 ! used in QueryFont -- draw direction
458 CONSTANT: FontLeftToRight 0
459 CONSTANT: FontRightToLeft 1
461 CONSTANT: FontChange 255
463 ! *****************************************************************
465 ! *****************************************************************
467 ! ImageFormat -- PutImage, GetImage
469 CONSTANT: XYBitmap 0 ! depth 1, XYFormat
470 CONSTANT: XYPixmap 1 ! depth == drawable depth
471 CONSTANT: ZPixmap 2 ! depth == drawable depth
473 ! *****************************************************************
475 ! *****************************************************************
479 CONSTANT: AllocNone 0 ! create map with no entries
480 CONSTANT: AllocAll 1 ! allocate entire map writeable
483 ! Flags used in StoreNamedColor, StoreColors
485 : DoRed ( -- n ) 0 2^ ;
486 : DoGreen ( -- n ) 1 2^ ;
487 : DoBlue ( -- n ) 2 2^ ;
489 ! *****************************************************************
491 ! *****************************************************************
493 ! QueryBestSize Class
495 CONSTANT: CursorShape 0 ! largest size that can be displayed
496 CONSTANT: TileShape 1 ! size tiled fastest
497 CONSTANT: StippleShape 2 ! size stippled fastest
499 ! *****************************************************************
500 ! * KEYBOARD/POINTER STUFF
501 ! *****************************************************************
503 CONSTANT: AutoRepeatModeOff 0
504 CONSTANT: AutoRepeatModeOn 1
505 CONSTANT: AutoRepeatModeDefault 2
507 CONSTANT: LedModeOff 0
508 CONSTANT: LedModeOn 1
510 ! masks for ChangeKeyboardControl
512 : KBKeyClickPercent ( -- n ) 0 2^ ;
513 : KBBellPercent ( -- n ) 1 2^ ;
514 : KBBellPitch ( -- n ) 2 2^ ;
515 : KBBellDuration ( -- n ) 3 2^ ;
516 : KBLed ( -- n ) 4 2^ ;
517 : KBLedMode ( -- n ) 5 2^ ;
518 : KBKey ( -- n ) 6 2^ ;
519 : KBAutoRepeatMode ( -- n ) 7 2^ ;
521 CONSTANT: MappingSuccess 0
522 CONSTANT: MappingBusy 1
523 CONSTANT: MappingFailed 2
525 CONSTANT: MappingModifier 0
526 CONSTANT: MappingKeyboard 1
527 CONSTANT: MappingPointer 2
529 ! *****************************************************************
530 ! * SCREEN SAVER STUFF
531 ! *****************************************************************
533 CONSTANT: DontPreferBlanking 0
534 CONSTANT: PreferBlanking 1
535 CONSTANT: DefaultBlanking 2
537 CONSTANT: DisableScreenSaver 0
538 CONSTANT: DisableScreenInterval 0
540 CONSTANT: DontAllowExposures 0
541 CONSTANT: AllowExposures 1
542 CONSTANT: DefaultExposures 2
544 ! for ForceScreenSaver
546 CONSTANT: ScreenSaverReset 0
547 CONSTANT: ScreenSaverActive 1
549 ! *****************************************************************
550 ! * HOSTS AND CONNECTIONS
551 ! *****************************************************************
555 CONSTANT: HostInsert 0
556 CONSTANT: HostDelete 1
558 ! for ChangeAccessControl
560 CONSTANT: EnableAccess 1
561 CONSTANT: DisableAccess 0
563 ! Display classes used in opening the connection
564 ! Note that the statically allocated ones are even numbered and the
565 ! dynamically changeable ones are odd numbered
567 CONSTANT: StaticGray 0
568 CONSTANT: GrayScale 1
569 CONSTANT: StaticColor 2
570 CONSTANT: PseudoColor 3
571 CONSTANT: TrueColor 4
572 CONSTANT: DirectColor 5
574 ! Byte order used in imageByteOrder and bitmapBitOrder