1 /* 	Xlib binding for D language
2 	Copyright 2007 TEISSIER Sylvere sligor(at)free.fr
3 	version 0.1 2007/08/29
4 	This binding is an alpha release and need to be more tested
5 	
6 	This file is free software, please read licence.txt for more informations
7 */
8 
9 module std.c.linux.X11.X;
10 
11 const uint X_PROTOCOL=11;		/* current protocol version */
12 const uint X_PROTOCOL_REVISION=0;		/* current minor version */
13 
14 /* Resources */
15 alias ulong XID;
16 alias ulong Mask;
17 alias ulong VisualID;
18 alias ulong Time;
19 alias XID Atom; //alias needed because of None invariant shared for Atom and XID
20 alias XID Window;
21 alias XID Drawable;
22 alias XID Font;
23 alias XID Pixmap;
24 alias XID Cursor;
25 alias XID Colormap;
26 alias XID GContext;
27 alias XID KeySym;
28 alias uint KeyCode;
29 
30 /*****************************************************************
31  * RESERVED RESOURCE AND CONSTANT DEFINITIONS
32  *****************************************************************/
33 const XID None=0;/* universal null resource or null atom */
34 const uint ParentRelative=1;	/* border pixmap in CreateWindow and ChangeWindowAttributes special VisualID and special window class passed to CreateWindow */
35 const uint CopyFromParent=0;	/* background pixmap in CreateWindow and ChangeWindowAttributes */
36 const Window PointerWindow=0;	/* destination window in SendEvent */
37 const Window InputFocus=1;		/* destination window in SendEvent */
38 const Window PointerRoot=1;		/* focus window in SetInputFocus */
39 const Atom AnyPropertyType=0;	/* special Atom, passed to GetProperty */
40 const KeyCode AnyKey=0;			/* special Key Code, passed to GrabKey */
41 const uint AnyButton=0;			/* special Button Code, passed to GrabButton */
42 const XID AllTemporary=0;		/* special Resource ID passed to KillClient */
43 const Time CurrentTime=0;		/* special Time */
44 const KeySym NoSymbol=0;		/* special KeySym */
45 
46 /***************************************************************** 
47  * EVENT DEFINITIONS 
48  *****************************************************************/
49  
50  /* Input Event Masks. Used as event-mask window attribute and as arguments
51    to Grab requests.  Not to be confused with event names.  */
52  
53 enum EventMask:long
54 { 
55 	NoEventMask				=0,
56 	KeyPressMask			=1<<0,
57 	KeyReleaseMask			=1<<1, 
58 	ButtonPressMask			=1<<2,
59 	ButtonReleaseMask		=1<<3,
60 	EnterWindowMask			=1<<4,
61 	LeaveWindowMask			=1<<5,
62 	PointerMotionMask		=1<<6,
63 	PointerMotionHintMask	=1<<7,
64 	Button1MotionMask		=1<<8,
65 	Button2MotionMask		=1<<9,
66 	Button3MotionMask		=1<<10,
67 	Button4MotionMask		=1<<11,
68 	Button5MotionMask		=1<<12,
69 	ButtonMotionMask		=1<<13,
70 	KeymapStateMask		=1<<14,
71 	ExposureMask			=1<<15,
72 	VisibilityChangeMask	=1<<16,
73 	StructureNotifyMask		=1<<17,
74 	ResizeRedirectMask		=1<<18,
75 	SubstructureNotifyMask	=1<<19,
76 	SubstructureRedirectMask=1<<20,
77 	FocusChangeMask			=1<<21,
78 	PropertyChangeMask		=1<<22,
79 	ColormapChangeMask		=1<<23,
80 	OwnerGrabButtonMask		=1<<24
81 };
82 
83 /* Event names.  Used in "type" field in XEvent structures.  Not to be
84 confused with event masks above.  They start from 2 because 0 and 1
85 are reserved in the protocol for errors and replies. */
86 
87 enum EventType:int
88 {
89 	KeyPress			=2,
90 	KeyRelease			=3,
91 	ButtonPress			=4,
92 	ButtonRelease		=5,
93 	MotionNotify		=6,
94 	EnterNotify			=7,
95 	LeaveNotify			=8,
96 	FocusIn				=9,
97 	FocusOut			=10,
98 	KeymapNotify		=11,
99 	Expose				=12,
100 	GraphicsExpose		=13,
101 	NoExpose			=14,
102 	VisibilityNotify	=15,
103 	CreateNotify		=16,
104 	DestroyNotify		=17,
105 	UnmapNotify		=18,
106 	MapNotify			=19,
107 	MapRequest			=20,
108 	ReparentNotify		=21,
109 	ConfigureNotify		=22,
110 	ConfigureRequest	=23,
111 	GravityNotify		=24,
112 	ResizeRequest		=25,
113 	CirculateNotify		=26,
114 	CirculateRequest	=27,
115 	PropertyNotify		=28,
116 	SelectionClear		=29,
117 	SelectionRequest	=30,
118 	SelectionNotify		=31,
119 	ColormapNotify		=32,
120 	ClientMessage		=33,
121 	MappingNotify		=34,
122 	LASTEvent			=35	/* must be bigger than any event # */
123 };
124 
125 /* Key masks. Used as modifiers to GrabButton and GrabKey, results of QueryPointer,
126    state in various key-, mouse-, and button-related events. */
127 enum KeyMask:uint
128 {
129 	ShiftMask	=1<<0,
130 	LockMask	=1<<1,
131 	ControlMask	=1<<2,
132 	Mod1Mask	=1<<3,
133 	Mod2Mask	=1<<4,
134 	Mod3Mask	=1<<5,
135 	Mod4Mask	=1<<6,
136 	Mod5Mask	=1<<7,
137 	AnyModifier	=1<<15/* used in GrabButton, GrabKey */
138 };
139 
140 /* modifier names.  Used to build a SetModifierMapping request or
141    to read a GetModifierMapping request.  These correspond to the
142    masks defined above. */
143 enum ModifierName:int
144 {
145 	ShiftMapIndex	=0,
146 	LockMapIndex	=1,
147 	ControlMapIndex	=2,
148 	Mod1MapIndex	=3,
149 	Mod2MapIndex	=4,
150 	Mod3MapIndex	=5,
151 	Mod4MapIndex	=6,
152 	Mod5MapIndex	=7
153 };
154 
155 enum ButtonMask:int
156 {
157 	Button1Mask	=1<<8,
158 	Button2Mask	=1<<9,
159 	Button3Mask	=1<<10,
160 	Button4Mask	=1<<11,
161 	Button5Mask	=1<<12,
162 	AnyModifier	=1<<15/* used in GrabButton, GrabKey */
163 };
164 
165 enum KeyOrButtonMask:uint
166 {
167 	ShiftMask	=1<<0,
168 	LockMask	=1<<1,
169 	ControlMask	=1<<2,
170 	Mod1Mask	=1<<3,
171 	Mod2Mask	=1<<4,
172 	Mod3Mask	=1<<5,
173 	Mod4Mask	=1<<6,
174 	Mod5Mask	=1<<7,
175 	Button1Mask	=1<<8,
176 	Button2Mask	=1<<9,
177 	Button3Mask	=1<<10,
178 	Button4Mask	=1<<11,
179 	Button5Mask	=1<<12,
180 	AnyModifier	=1<<15/* used in GrabButton, GrabKey */
181 };
182 
183 
184 /* button names. Used as arguments to GrabButton and as detail in ButtonPress
185    and ButtonRelease events.  Not to be confused with button masks above.
186    Note that 0 is already defined above as "AnyButton".  */
187 
188 enum ButtonName:int
189 {
190 	Button1	=1,
191 	Button2	=2,
192 	Button3	=3,
193 	Button4	=4,
194 	Button5	=5
195 };
196 
197 /* Notify modes */
198 enum NotifyModes:int
199 {
200 	NotifyNormal		=0,
201 	NotifyGrab			=1,
202 	NotifyUngrab		=2,
203 	NotifyWhileGrabbed	=3
204 };
205 const int NotifyHint	=1;	/* for MotionNotify events */
206 		       
207 /* Notify detail */
208 enum NotifyDetail:int
209 {
210 	NotifyAncestor			=0,
211 	NotifyVirtual			=1,
212 	NotifyInferior			=2,
213 	NotifyNonlinear			=3,
214 	NotifyNonlinearVirtual	=4,
215 	NotifyPointer			=5,
216 	NotifyPointerRoot		=6,
217 	NotifyDetailNone		=7
218 };
219 
220 /* Visibility notify */
221 
222 enum VisibilityNotify:int
223 {
224 VisibilityUnobscured		=0,
225 VisibilityPartiallyObscured	=1,
226 VisibilityFullyObscured		=2
227 };
228 
229 /* Circulation request */
230 enum CirculationRequest:int
231 {
232 	PlaceOnTop		=0,
233 	PlaceOnBottom	=1
234 };
235 /* protocol families */
236 enum ProtocolFamlily:int
237 {
238 	FamilyInternet	=0,	/* IPv4 */
239 	FamilyDECnet	=1,
240 	FamilyChaos	=2,
241 	FamilyServerInterpreted =5, /* authentication families not tied to a specific protocol */
242 	FamilyInternet6 =6	/* IPv6 */
243 };
244 
245 /* Property notification */
246 
247 enum PropertyNotification:int
248 {
249 	PropertyNewValue	=0,
250 	PropertyDelete		=1
251 };
252 
253 /* Color Map notification */
254 enum ColorMapNotification:int
255 {
256 	ColormapUninstalled	=0,
257 	ColormapInstalled		=1
258 };
259 
260 /* GrabPointer, GrabButton, GrabKeyboard, GrabKey Modes */
261 enum GrabMode:int
262 {
263 	GrabModeSync	=0,
264 	GrabModeAsync	=1
265 };
266 
267 /* GrabPointer, GrabKeyboard reply status */
268 enum GrabReplyStatus:int
269 {
270 GrabSuccess			=0,
271 AlreadyGrabbed		=1,
272 GrabInvalidTime	=2,
273 GrabNotViewable		=3,
274 GrabFrozen			=4
275 };
276 
277 /* AllowEvents modes */
278 
279 enum AllowEventMode:int
280 {
281 AsyncPointer	=0,
282 SyncPointer		=1,
283 ReplayPointer	=2,
284 AsyncKeyboard	=3,
285 SyncKeyboard	=4,
286 ReplayKeyboard	=5,
287 AsyncBoth		=6,
288 SyncBoth		=7
289 };
290 
291 /* Used in SetInputFocus, GetInputFocus */
292 enum InputFocusRevertTo:int
293 {
294 RevertToNone		=None,
295 RevertToPointerRoot	=PointerRoot,
296 RevertToParent		=2
297 };
298 
299 /*****************************************************************
300  * ERROR CODES 
301  *****************************************************************/
302 
303 enum XErrorCode:int
304 {
305 	Success		   	=0,		/* everything's okay */
306 	BadRequest	   	=1,		/* bad request code */
307 	BadValue	   	=2,		/* int parameter out of range */
308 	BadWindow	   	=3,		/* parameter not a Window */
309 	BadPixmap	   	=4,		/* parameter not a Pixmap */
310 	BadAtom		=5,		/* parameter not an Atom */
311 	BadCursor	   	=6,		/* parameter not a Cursor */
312 	BadFont		   	=7,		/* parameter not a Font */
313 	BadMatch	   	=8,		/* parameter mismatch */
314 	BadDrawable	   	=9,		/* parameter not a Pixmap or Window */
315 	BadAccess	  	=10,	/* depending on context:
316 				 			- key/button already grabbed
317 				 			- attempt to free an illegal 
318 				   				cmap entry 
319 							- attempt to store into a read-only 
320 				   				color map entry.
321  							- attempt to modify the access control
322 				   				list from other than the local host.
323 							*/
324 	BadAlloc	  	=11,	/* insufficient resources */
325 	BadColor	  	=12,	/* no such colormap */
326 	BadGC		  	=13,	/* parameter not a GC */
327 	BadIDChoice	  	=14,	/* choice not in range or already used */
328 	BadName		=15,	/* font or color name doesn't exist */
329 	BadLength	  	=16,	/* Request length incorrect */
330 	BadImplementation =17,	/* server is defective */
331 
332 	FirstExtensionError	=128,
333 	LastExtensionError	=255
334 };
335 
336 /*****************************************************************
337  * WINDOW DEFINITIONS 
338  *****************************************************************/
339 
340 /* Window classes used by CreateWindow */
341 /* Note that CopyFromParent is already defined as 0 above */
342 enum WindowClass:int
343 {
344 	CopyFromParent	=0,
345 	InputOutput		=1,
346 	InputOnly		=2
347 };
348 
349 /* Window attributes for CreateWindow and ChangeWindowAttributes */
350 
351 enum WindowAttribute:ulong
352 {
353 	CWBackPixmap		=1<<0,
354 	CWBackPixel			=1<<1,
355 	CWBorderPixmap		=1<<2,
356 	CWBorderPixel		=1<<3,
357 	CWBitGravity		=1<<4,
358 	CWWinGravity		=1<<5,
359 	CWBackingStore		=1<<6,
360 	CWBackingPlanes		=1<<7,
361 	CWBackingPixel		=1<<8,
362 	CWOverrideRedirect	=1<<9,
363 	CWSaveUnder			=1<<10,
364 	CWEventMask			=1<<11,
365 	CWDontPropagate		=1<<12,
366 	CWColormap			=1<<13,
367 	CWCursor			=1<<14
368 };
369 /* ConfigureWindow structure */
370 enum ConfigureWindowStruct:int
371 {
372 	CWX				=1<<0,
373 	CWY				=1<<1,
374 	CWWidth			=1<<2,
375 	CWHeight		=1<<3,
376 	CWBorderWidth	=1<<4,
377 	CWSibling		=1<<5,
378 	CWStackMode		=1<<6
379 };
380 
381 /* Bit Gravity */
382 enum BitGravity:int
383 {
384 	ForgetGravity		=0,
385 	NorthWestGravity	=1,
386 	NorthGravity		=2,
387 	NorthEastGravity	=3,
388 	WestGravity			=4,
389 	CenterGravity		=5,
390 	EastGravity			=6,
391 	SouthWestGravity	=7,
392 	SouthGravity		=8,
393 	SouthEastGravity	=9,
394 	StaticGravity		=10
395 };
396 
397 /* Window gravity + bit gravity above */
398 
399 const uint UnmapGravity=0;
400 
401 /* Used in CreateWindow for backing-store hint */
402 enum BackingStoreHint:int
403 {
404 	NotUseful	=0,
405 	WhenMapped	=1,
406 	Always		=2
407 };
408 /* Used in GetWindowAttributes reply */
409 enum MapState:int
410 {
411 	IsUnmapped		=0,
412 	IsUnviewable	=1,
413 	IsViewable		=2
414 };
415 /* Used in ChangeSaveSet */
416 enum ChangeMode:int
417 {
418 	SetModeInsert	=0,
419 	SetModeDelete	=1
420 };
421 /* Used in ChangeCloseDownMode */
422 enum CloseDownMode:int
423 {
424 	DestroyAll			=0,
425 	RetainPermanent	=1,
426 	RetainTemporary	=2
427 };
428 
429 /* Window stacking method (in configureWindow) */
430 enum WindowStackingMethod:int
431 {
432 	Above		=0,
433 	Below		=1,
434 	TopIf		=2,
435 	BottomIf	=3,
436 	Opposite	=4
437 };
438 
439 /* Circulation direction */
440 enum CircularDirection:int
441 {
442 RaiseLowest		=0,
443 LowerHighest	=1
444 };
445 
446 /* Property modes */
447 enum PropertyMode:int
448 {
449 PropModeReplace	=0,
450 PropModePrepend	=1,
451 PropModeAppend	=2
452 };
453 
454 /*****************************************************************
455  * GRAPHICS DEFINITIONS
456  *****************************************************************/
457 
458 /* graphics functions, as in GC.alu */
459 enum GraphicFunction:int
460 {
461 	GXclear			=0x0,		/* 0 */
462 	GXand			=0x1,		/* src AND dst */
463 	GXandReverse	=0x2,		/* src AND NOT dst */
464 	GXcopy			=0x3,		/* src */
465 	GXandInverted	=0x4,		/* NOT src AND dst */
466 	GXnoop			=0x5,		/* dst */
467 	GXxor			=0x6,		/* src XOR dst */
468 	GXor			=0x7,		/* src OR dst */
469 	GXnor			=0x8,		/* NOT src AND NOT dst */
470 	GXequiv			=0x9,		/* NOT src XOR dst */
471 	GXinvert		=0xa,		/* NOT dst */
472 	GXorReverse		=0xb,		/* src OR NOT dst */
473 	GXcopyInverted	=0xc,		/* NOT src */
474 	GXorInverted	=0xd,		/* NOT src OR dst */
475 	GXnand			=0xe,		/* NOT src OR NOT dst */
476 	GXset			=0xf		/* 1 */
477 };
478 
479 /* LineStyle */
480 enum LineStyle:int
481 {
482 	LineSolid		=0,
483 	LineOnOffDash	=1,
484 	LineDoubleDash	=2
485 };
486 /* capStyle */
487 enum CapStyle:int
488 {
489 	CapNotLast		=0,
490 	CapButt			=1,
491 	CapRound		=2,
492 	CapProjecting	=3
493 };
494 /* joinStyle */
495 enum JoinStyle:int
496 {
497 	JoinMiter		=0,
498 	JoinRound		=1,
499 	JoinBevel		=2
500 };
501 /* fillStyle */
502 enum FillStyle:int
503 {
504 	FillSolid		=0,
505 	FillTiled		=1,
506 	FillStippled	=2,
507 	FillOpaqueStippled	=3
508 };
509 /* fillRule */
510 enum FillRule:int
511 {
512 	EvenOddRule		=0,
513 	WindingRule		=1
514 };
515 /* subwindow mode */
516 enum SubwindowMode:int
517 {
518 	ClipByChildren		=0,
519 	IncludeInferiors	=1
520 };
521 /* SetClipRectangles ordering */
522 enum ClipRectanglesOrdering:int
523 {
524 	Unsorted		=0,
525 	YSorted			=1,
526 	YXSorted		=2,
527 	YXBanded		=3
528 };
529 /* CoordinateMode for drawing routines */
530 enum CoordinateMode:int
531 {
532 	CoordModeOrigin		=0,	/* relative to the origin */
533 	CoordModePrevious	=1	/* relative to previous point */
534 };
535 /* Polygon shapes */
536 enum PolygonShape:int
537 {
538 	Complex		=0,	/* paths may intersect */
539 	Nonconvex		=1,	/* no paths intersect, but not convex */
540 	Convex			=2	/* wholly convex */
541 };
542 
543 /* Arc modes for PolyFillArc */
544 enum ArcMode:int
545 {
546 	ArcChord		=0,	/* join endpoints of arc */
547 	ArcPieSlice		=1	/* join endpoints to center of arc */
548 };
549 /* GC components: masks used in CreateGC, CopyGC, ChangeGC, OR'ed into
550    GC.stateChanges */
551 enum GCMask:ulong
552 {
553 	GCFunction			=1<<0,
554 	GCPlaneMask			=1<<1,
555 	GCForeground		=1<<2,
556 	GCBackground		=1<<3,
557 	GCLineWidth			=1<<4,
558 	GCLineStyle			=1<<5,
559 	GCCapStyle			=1<<6,
560 	GCJoinStyle			=1<<7,
561 	GCFillStyle			=1<<8,
562 	GCFillRule			=1<<9,
563 	GCTile				=1<<10,
564 	GCStipple			=1<<11,
565 	GCTileStipXOrigin	=1<<12,
566 	GCTileStipYOrigin	=1<<13,
567 	GCFont 				=1<<14,
568 	GCSubwindowMode		=1<<15,
569 	GCGraphicsExposures	=1<<16,
570 	GCClipXOrigin		=1<<17,
571 	GCClipYOrigin		=1<<18,
572 	GCClipMask			=1<<19,
573 	GCDashOffset		=1<<20,
574 	GCDashList			=1<<21,
575 	GCArcMode			=1<<22,
576 };
577 const uint GCLastBit=22;
578 /*****************************************************************
579  * FONTS 
580  *****************************************************************/
581 
582 /* used in QueryFont -- draw direction */
583 enum FontDrawDirection:int
584 {
585 	FontLeftToRight		=0,
586 	FontRightToLeft		=1,
587 	FontChange			=255
588 }
589 /*****************************************************************
590  *  IMAGING 
591  *****************************************************************/
592 
593 /* ImageFormat -- PutImage, GetImage */
594 enum ImageFormat:int
595 {
596 	XYBitmap	=0,	/* depth 1, XYFormat */
597 	XYPixmap	=1,	/* depth == drawable depth */
598 	ZPixmap	=2	/* depth == drawable depth */
599 };
600 
601 /*****************************************************************
602  *  COLOR MAP STUFF 
603  *****************************************************************/
604 
605 /* For CreateColormap */
606 enum AllocType:int
607 {
608 	AllocNone	=0,	/* create map with no entries */
609 	AllocAll	=1	/* allocate entire map writeable */
610 };
611 
612 /* Flags used in StoreNamedColor, StoreColors */
613 enum StoreColor:int
614 {
615 	DoRed	=1<<0,
616 	DoGreen	=1<<1,
617 	DoBlue	=1<<2
618 };
619 
620 /*****************************************************************
621  * CURSOR STUFF
622  *****************************************************************/
623 
624 /* QueryBestSize Class */
625 enum QueryBestSizeClass:int
626 {
627 	CursorShape		=0,	/* largest size that can be displayed */
628 	TileShape		=1,	/* size tiled fastest */
629 	StippleShape	=2	/* size stippled fastest */
630 };
631 
632 /***************************************************************** 
633  * KEYBOARD/POINTER STUFF
634  *****************************************************************/
635 
636 enum AutoRepeatMode:int
637 {
638 	AutoRepeatModeOff		=0,
639 	AutoRepeatModeOn		=1,
640 	AutoRepeatModeDefault	=2
641 };
642 
643 enum LedMode:int
644 {
645 	LedModeOff		=0,
646 	LedModeOn		=1
647 };
648 /* masks for ChangeKeyboardControl */
649 
650 enum KBMask:ulong
651 {
652 	KBKeyClickPercent	=1<<0,
653 	KBBellPercent		=1<<1,
654 	KBBellPitch			=1<<2,
655 	KBBellDuration		=1<<3,
656 	KBLed				=1<<4,
657 	KBLedMode			=1<<5,
658 	KBKey				=1<<6,
659 	KBAutoRepeatMode	=1<<7
660 };
661 
662 enum MappingErrorCode:int
663 {
664 	MappingSuccess     	=0,
665 	MappingBusy        	=1,
666 	MappingFailed		=2
667 };
668 
669 enum MappingType:int
670 {
671 	MappingModifier		=0,
672 	MappingKeyboard		=1,
673 	MappingPointer		=2
674 };
675 
676 /*****************************************************************
677  * SCREEN SAVER STUFF 
678  *****************************************************************/
679 
680 enum ScreenSaverBlancking:int
681 {
682 	DontPreferBlanking	=0,
683 	PreferBlanking		=1,
684 	DefaultBlanking		=2
685 };
686 
687 enum ScreenSaverDisable:int
688 {
689 	DisableScreenSaver		=0,
690 	DisableScreenInterval	=0
691 };
692 
693 enum ScreenSaverExposure:int
694 {
695 	DontAllowExposures	=0,
696 	AllowExposures		=1,
697 	DefaultExposures	=2
698 };
699 
700 /* for ForceScreenSaver */
701 
702 enum ScreenSaverMode:int
703 {
704 	ScreenSaverReset 	=0,
705 	ScreenSaverActive 	=1
706 };
707 
708 /*****************************************************************
709  * HOSTS AND CONNECTIONS
710  *****************************************************************/
711 
712 /* for ChangeHosts */
713 
714 enum HostChange:int
715 {
716 	HostInsert		=0,
717 	HostDelete		=1
718 };
719 
720 /* for ChangeAccessControl */
721 
722 enum HostAccess:int
723 {
724 	EnableAccess	=1,     
725 	DisableAccess	=0
726 };
727 
728 /* Display classes  used in opening the connection 
729  * Note that the statically allocated ones are even numbered and the
730  * dynamically changeable ones are odd numbered */
731 
732 enum DisplayClass:int
733 {
734 	StaticGray		=0,
735 	GrayScale		=1,
736 	StaticColor		=2,
737 	PseudoColor		=3,
738 	TrueColor		=4,
739 	DirectColor		=5
740 };
741 
742 /* Byte order  used in imageByteOrder and bitmapBitOrder */
743 
744 enum ByteOrder:int
745 {
746 	LSBFirst		=0,
747 	MSBFirst		=1
748 };