1 module iv
.x11
.util
/*is aliced*/;
3 import core
.stdc
.config
: c_long
, c_ulong
;
4 import core
.stdc
.stddef
: wchar_t
;
11 import iv
.x11
.resource
: XrmStringToQuark
;
17 * Bitmask returned by XParseGeometry(). Each bit tells if the corresponding
18 * value (x, y, width, height) was found in the parsed string.
32 * new version containing base_width, base_height, and win_gravity fields;
33 * used with WM_NORMAL_HINTS.
36 c_long flags
; /* marks which fields in this structure are defined */
37 int x
, y
; /* obsolete for new window mgrs, but clients */
38 int width
, height
; /* should set so old wm's don't mess up */
39 int min_width
, min_height
;
40 int max_width
, max_height
;
41 int width_inc
, height_inc
;
43 int x
; /* numerator */
44 int y
; /* denominator */
46 aspect min_aspect
, max_aspect
;
47 int base_width
, base_height
; /* added by ICCCM version 1 */
48 int win_gravity
; /* added by ICCCM version 1 */
52 * The next block of definitions are for window manager properties that
53 * clients and applications use for communication.
55 /* flags argument in size hints */
57 USPosition
= 1<<0, /* user specified x, y */
58 USSize
= 1<<1, /* user specified width, height */
60 PPosition
= 1<<2, /* program specified position */
61 PSize
= 1<<3, /* program specified size */
62 PMinSize
= 1<<4, /* program specified minimum size */
63 PMaxSize
= 1<<5, /* program specified maximum size */
64 PResizeInc
= 1<<6, /* program specified resize increments */
65 PAspect
= 1<<7, /* program specified min and max aspect ratios */
66 PBaseSize
= 1<<8, /* program specified base for incrementing */
67 PWinGravity
= 1<<9, /* program specified window gravity */
71 enum c_long PAllHints
= (PPosition|PSize|PMinSize|PMaxSize|PResizeInc|PAspect
);
74 c_long flags
; /* marks which fields in this structure are defined */
75 Bool input
; /* does this application rely on the window manager to get keyboard input? */
76 int initial_state
; /* see below */
77 Pixmap icon_pixmap
; /* pixmap to be used as icon */
78 Window icon_window
; /* window to be used as icon */
79 int icon_x
, icon_y
; /* initial position of icon */
80 Pixmap icon_mask
; /* icon mask bitmap */
81 XID window_group
; /* id of related window group */
82 /* this structure may be extended in the future */
85 /* definition for flags of XWMHints */
89 IconPixmapHint
= (1<<2),
90 IconWindowHint
= (1<<3),
91 IconPositionHint
= (1<<4),
92 IconMaskHint
= (1<<5),
93 WindowGroupHint
= (1<<6),
94 AllHints
= (InputHint|StateHint|IconPixmapHint|IconWindowHint|IconPositionHint|IconMaskHint|WindowGroupHint
),
95 XUrgencyHint
= (1<<8),
98 /* definitions for initial window state */
100 WithdrawnState
= 0, /* for windows that are not mapped */
101 NormalState
= 1, /* most applications want to start this way */
102 IconicState
= 3, /* application wants to start as an icon */
106 * Obsolete states no longer defined by ICCCM
109 DontCareState
= 0, /* don't know or care */
110 ZoomState
= 2, /* application wants to start zoomed */
111 InactiveState
= 4, /* application believes it is seldom used; */
113 /* some wm's may put it on inactive menu */
117 * new structure for manipulating TEXT properties; used with WM_NAME,
118 * WM_ICON_NAME, WM_CLIENT_MACHINE, and WM_COMMAND.
120 struct XTextProperty
{
121 ubyte* value
; /* same as Property routines */
122 Atom encoding
; /* prop type */
123 int format
; /* prop data format: 8, 16, or 32 */
124 c_ulong nitems
; /* number of data items in value */
127 enum int XNoMemory
= -1;
128 enum int XLocaleNotSupported
= -2;
129 enum int XConverterNotFound
= -3;
131 alias XICCEncodingStyle
= int;
133 XStringStyle
, /* STRING */
134 XCompoundTextStyle
, /* COMPOUND_TEXT */
135 XTextStyle
, /* text in owner's encoding (current locale) */
136 XStdICCTextStyle
, /* STRING, else COMPOUND_TEXT */
137 /* The following is an XFree86 extension, introduced in November 2000 */
138 XUTF8StringStyle
, /* UTF8_STRING */
142 int min_width
, min_height
;
143 int max_width
, max_height
;
144 int width_inc
, height_inc
;
148 const(char)* res_name
; // was `char*`
149 const(char)* res_class
; // was `char*`
152 version (XUTIL_DEFINE_FUNCTIONS
) {
153 int XDestroyImage (XImage
* ximage
);
154 c_ulong
XGetPixel (XImage
*ximage
, int x
, int y
);
155 int XPutPixel (XImage
* ximage
, int x
, int y
, c_ulong pixel
);
156 XImage
* XSubImage (XImage
*ximage
, int x
, int y
, uint width
, uint height
);
157 int XAddPixel (XImage
*ximage
, c_long value
);
160 * These macros are used to give some sugar to the image routines so that
161 * naive people are more comfortable with them.
165 * The XDestroyImage() function deallocates the memory associated with the XImage structure.
166 * Note that when the image is created using XCreateImage(), XGetImage(), or XSubImage(), the destroy procedure that this macro calls frees both the image structure and the data pointed to by the image structure.
168 * ximage = Specifies the image.
170 * XAddPixel(), XCreateImage(), XGetPixel(), XPutPixel(), XSubImage(), http://tronche.com/gui/x/xlib/utilities/manipulating-images.html
172 int XDestroyImage (XImage
* ximage
) { return ximage
.f
.destroy_image(ximage
); }
175 * The XGetPixel() function returns the specified pixel from the named image. The pixel value is returned in normalized format (that is, the least-significant byte of the long is the least-significant byte of the pixel). The image must contain the x and y coordinates.
177 * ximage = Specifies the image.
178 * x = Specify the x coordinate.
179 * y = Specify the y coordinate.
181 * XAddPixel(), XCreateImage(), XGetPixel(), XPutPixel(), XSubImage(), http://tronche.com/gui/x/xlib/utilities/manipulating-images.html
183 c_ulong
XGetPixel (XImage
* ximage
, int x
, int y
) { return ximage
.f
.get_pixel(ximage
, x
, y
); }
186 * The XPutPixel() function overwrites the pixel in the named image with the specified pixel value. The input pixel value must be in normalized format (that is, the least-significant byte of the long is the least-significant byte of the pixel). The image must contain the x and y coordinates.
188 * ximage = Specifies the image.
189 * x = Specify the x coordinate.
190 * y = Specify the y coordinate.
191 * pixel = Specifies the new pixel value.
193 * XAddPixel(), XCreateImage(), XGetPixel(), XPutPixel(), XSubImage(), http://tronche.com/gui/x/xlib/utilities/manipulating-images.html
195 int XPutPixel (XImage
* ximage
, int x
, int y
, c_ulong pixel
) { return ximage
.f
.put_pixel(ximage
, x
, y
, pixel
); }
198 * The XSubImage() function creates a new image that is a subsection of an existing one. It allocates the memory necessary for the new XImage structure and returns a pointer to the new image. The data is copied from the source image, and the image must contain the rectangle defined by x, y, subimage_width, and subimage_height.
200 * ximage = Specifies the image.
201 * x = Specify the x coordinate.
202 * y = Specify the y coordinate.
203 * subimage_width = Specifies the width of the new subimage, in pixels.
204 * subimage_height = Specifies the height of the new subimage, in pixels.
206 * XAddPixel(), XCreateImage(), XGetPixel(), XPutPixel(), XSubImage(), http://tronche.com/gui/x/xlib/utilities/manipulating-images.html
208 XImage
* XSubImage (XImage
* ximage
, int x
, int y
, uint width
, uint height
) { return ximage
.f
.sub_image(ximage
, x
, y
, width
, height
); }
211 * The XAddPixel() function adds a constant value to every pixel in an image. It is useful when you have a base pixel value from allocating color resources and need to manipulate the image to that form.
213 * ximage = Specifies the image.
214 * value = Specifies the constant value that is to be added.
216 * XAddPixel(), XCreateImage(), XGetPixel(), XPutPixel(), XSubImage(), http://tronche.com/gui/x/xlib/utilities/manipulating-images.html
218 int XAddPixel (XImage
* ximage
, c_long value
) { return ximage
.f
.add_pixel(ximage
, value
); }
222 nothrow @trusted @nogc:
224 * Compose sequence status structure, used in calling XLookupString.
226 struct XComposeStatus
{
227 XPointer compose_ptr
; /* state table pointer */
228 int chars_matched
; /* match state */
232 * Keysym macros, used on Keysyms to test for classes of symbols
235 template IsKeypadKey (KeySym keysym
) {
236 enum IsKeypadKey
= (keysym
>= XK_KP_Space
&& keysym
<= XK_KP_Equal
);
239 template IsPrivateKeypadKey (KeySym keysym
) {
240 enum IsPrivateKeypadKey
= (keysym
>= 0x11000000 && keysym
<= 0x1100FFFF);
243 template IsCursorKey (KeySym keysym
) {
244 enum IsCursorKey
= (keysym
>= XK_Home
&& keysym
< XK_Select
);
247 template IsPFKey (KeySym keysym
) {
248 enum IsPFKey
= (keysym
>= XK_KP_F1
&& keysym
<= XK_KP_F4
);
251 template IsFunctionKey (KeySym keysym
) {
252 enum IsFunctionKey
= (keysym
>= XK_F1
&& keysym
<= XK_F35
);
255 template IsMiscFunctionKey (KeySym keysym
) {
256 enum IsMiscFunctionKey
= (keysym
>= XK_Select
&& keysym
<= XK_Break
);
259 template IsModifierKey (KeySym keysym
) {
260 enum IsModifierKey
= (
261 (keysym
>= XK_Shift_L
&& keysym
<= XK_Hyper_R
) ||
262 (keysym
>= XK_ISO_Lock
&& keysym
<= XK_ISO_Last_Group_Lock
) ||
263 (keysym
== XK_Mode_switch
) ||
264 (keysym
== XK_Num_Lock
)
269 * opaque reference to Region data type
271 //alias Region = _XRegion*;
273 /* Return values from XRectInRegion() */
282 * Information used by the visual utility routines to find desired visual
283 * type from the many visuals a display may support.
290 int c_class
; /* C++ */;
301 VisualScreenMask
= 0x2,
302 VisualDepthMask
= 0x4,
303 VisualClassMask
= 0x8,
304 VisualRedMaskMask
= 0x10,
305 VisualGreenMaskMask
= 0x20,
306 VisualBlueMaskMask
= 0x40,
307 VisualColormapSizeMask
= 0x80,
308 VisualBitsPerRGBMask
= 0x100,
309 VisualAllMask
= 0x1FF,
313 * This defines a window manager property that clients may use to
314 * share standard color maps of type RGB_COLOR_MAP:
316 struct XStandardColormap
{
325 VisualID visualid
; /* added by ICCCM version 1 */
326 XID killid
; /* added by ICCCM version 1 */
329 enum XID ReleaseByFreeingColormap
= cast(XID
)1; /* for killid field above */
333 * return codes for XReadBitmapFile and XWriteBitmapFile
337 BitmapOpenFailed
= 1,
338 BitmapFileInvalid
= 2,
346 /* Associative lookup table return codes */
348 XCSUCCESS
= 0, /* No error. */
349 XCNOMEM
= 1, /* Out of memory */
350 XCNOENT
= 2, /* No entry in table */
353 //typedef XContext = int;
354 alias XContext
= int;
356 template XUniqueContext () {
357 const XContext XUniqueContext
= XrmUniqueQuark();
361 XContext
XStringToContext (char* statement
) { return cast(XContext
)XrmStringToQuark(statement
); }
363 /* The following declarations are alphabetized. */
364 XClassHint
* XAllocClassHint ();
365 XIconSize
* XAllocIconSize ();
366 XSizeHints
* XAllocSizeHints ();
367 XStandardColormap
* XAllocStandardColormap ();
368 XWMHints
* XAllocWMHints ();
369 int XClipBox (XRegion r
, XRectangle
* rect_return
);
370 XRegion
XCreateRegion ();
371 char* XDefaultString ();
372 int XDeleteContext (Display
* display
, XID rid
, XContext context
);
373 int XDestroyRegion (XRegion r
);
374 int XEmptyRegion (XRegion r
);
375 int XEqualRegion (XRegion r1
, XRegion r2
);
376 int XFindContext (Display
* display
, XID rid
, XContext context
, XPointer
* data_return
);
377 Status
XGetClassHint (Display
* display
, Window w
, XClassHint
* class_hints_return
);
378 Status
XGetIconSizes (Display
* display
, Window w
, XIconSize
** size_list_return
, int* count_return
);
379 Status
XGetNormalHints (Display
* display
, Window w
, XSizeHints
* hints_return
);
380 Status
XGetRGBColormaps (Display
* display
, Window w
, XStandardColormap
** stdcmap_return
, int* count_return
, Atom property
);
381 Status
XGetSizeHints (Display
* display
, Window w
, XSizeHints
* hints_return
, Atom property
);
382 Status
XGetStandardColormap (Display
* display
, Window w
, XStandardColormap
* colormap_return
, Atom property
);
383 Status
XGetTextProperty (Display
* display
, Window window
, XTextProperty
* text_prop_return
, Atom property
);
384 XVisualInfo
* XGetVisualInfo (Display
* display
, long vinfo_mask
, XVisualInfo
* vinfo_template
, int* nitems_return
);
385 Status
XGetWMClientMachine (Display
* display
, Window w
, XTextProperty
* text_prop_return
);
386 XWMHints
*XGetWMHints (Display
* display
, Window w
);
387 Status
XGetWMIconName (Display
* display
, Window w
, XTextProperty
* text_prop_return
);
388 Status
XGetWMName (Display
* display
, Window w
, XTextProperty
* text_prop_return
);
389 Status
XGetWMNormalHints (Display
* display
, Window w
, XSizeHints
* hints_return
, long* supplied_return
);
390 Status
XGetWMSizeHints (Display
* display
, Window w
, XSizeHints
* hints_return
, long* supplied_return
, Atom property
);
391 Status
XGetZoomHints (Display
* display
, Window w
, XSizeHints
* zhints_return
);
392 int XIntersectRegion (XRegion sra
, XRegion srb
, XRegion dr_return
);
393 void XConvertCase (KeySym sym
, KeySym
* lower
, KeySym
* upper
);
394 int XLookupString (XKeyEvent
* event_struct
, char* buffer_return
, int bytes_buffer
, KeySym
* keysym_return
, XComposeStatus
* status_in_out
);
395 Status
XMatchVisualInfo (Display
* display
, int screen
, int depth
, int cclass
, XVisualInfo
* vinfo_return
);
396 int XOffsetRegion (XRegion r
, int dx
, int dy
);
397 Bool
XPointInRegion (XRegion r
, int x
, int y
);
398 XRegion
XPolygonRegion (iv
.x11
.xlib
.XPoint
* points
, int n
, int fill_rule
);
399 int XRectInRegion (XRegion r
, int x
, int y
, uint width
, uint height
);
400 int XSaveContext (Display
* display
, XID rid
, XContext context
, char* data
);
401 int XSetClassHint (Display
* display
, Window w
, XClassHint
* class_hints
);
402 int XSetIconSizes (Display
* display
, Window w
, XIconSize
* size_list
, int count
);
403 int XSetNormalHints (Display
* display
, Window w
, XSizeHints
* hints
);
404 void XSetRGBColormaps (Display
* display
, Window w
, XStandardColormap
* stdcmaps
, int count
, Atom property
);
405 int XSetSizeHints (Display
* display
, Window w
, XSizeHints
* hints
, Atom property
);
406 int XSetStandardProperties (Display
* display
, Window w
, const(char)* window_name
, const(char)* icon_name
, Pixmap icon_pixmap
, char** argv
, int argc
, XSizeHints
* hints
);
407 void XSetTextProperty (Display
* display
, Window w
, XTextProperty
* text_prop
, Atom property
);
408 void XSetWMClientMachine (Display
* display
, Window w
, XTextProperty
* text_prop
);
409 int XSetWMHints (Display
* display
, Window w
, XWMHints
* wm_hints
);
410 void XSetWMIconName (Display
* display
, Window w
, XTextProperty
* text_prop
);
411 void XSetWMName (Display
* display
, Window w
, XTextProperty
* text_prop
);
412 void XSetWMNormalHints (Display
* display
, Window w
, XSizeHints
* hints
);
413 void XSetWMProperties (Display
* display
, Window w
, XTextProperty
* window_name
, XTextProperty
* icon_name
, char** argv
, int argc
, XSizeHints
* normal_hints
, XWMHints
* wm_hints
, XClassHint
* class_hints
);
414 void XmbSetWMProperties (Display
* display
, Window w
, const(char)* window_name
, const(char)* icon_name
, char** argv
, int argc
, XSizeHints
* normal_hints
, XWMHints
* wm_hints
, XClassHint
* class_hints
);
415 void Xutf8SetWMProperties (Display
* display
, Window w
, const(char)* window_name
, const(char)* icon_name
, char** argv
, int argc
, XSizeHints
* normal_hints
, XWMHints
* wm_hints
, XClassHint
* class_hints
);
416 void XSetWMSizeHints (Display
* display
, Window w
, XSizeHints
* hints
, Atom property
);
417 int XSetRegion (Display
* display
, GC gc
, XRegion r
);
418 void XSetStandardColormap (Display
* display
, Window w
, XStandardColormap
* colormap
, Atom property
);
419 int XSetZoomHints (Display
* display
, Window w
, XSizeHints
* zhints
);
420 int XShrinkRegion (XRegion r
, int dx
, int dy
);
421 Status
XStringListToTextProperty (char** list
, int count
, XTextProperty
* text_prop_return
);
422 int XSubtractRegion (XRegion sra
, XRegion srb
, XRegion dr_return
);
423 int XmbTextListToTextProperty (Display
* display
, char** list
, int count
, XICCEncodingStyle style
, XTextProperty
* text_prop_return
);
424 int XwcTextListToTextProperty (Display
* display
, wchar_t
** list
, int count
, XICCEncodingStyle style
, XTextProperty
* text_prop_return
);
425 int Xutf8TextListToTextProperty (Display
* display
, char** list
, int count
, XICCEncodingStyle style
, XTextProperty
* text_prop_return
);
426 void XwcFreeStringList (wchar_t
** list
);
427 Status
XTextPropertyToStringList (XTextProperty
* text_prop
, char*** list_return
, int* count_return
);
428 int XmbTextPropertyToTextList (Display
* display
, const XTextProperty
* text_prop
, char*** list_return
, int* count_return
);
429 int XwcTextPropertyToTextList (Display
* display
, const(XTextProperty
)* text_prop
, wchar_t
*** list_return
, int* count_return
);
430 int Xutf8TextPropertyToTextList (Display
* display
, const(XTextProperty
)* text_prop
, char*** list_return
, int* count_return
);
431 int XUnionRectWithRegion (XRectangle
* rectangle
, XRegion src_region
, XRegion dest_region_return
);
432 int XUnionRegion (XRegion sra
, XRegion srb
, XRegion dr_return
);
433 int XWMGeometry (Display
* display
, int screen_number
, char* user_geometry
, char* default_geometry
, uint border_width
,
434 XSizeHints
* hints
, int* x_return
, int* y_return
, int* width_return
, int* height_return
, int* gravity_return
);
435 int XXorRegion (XRegion sra
, XRegion srb
, XRegion dr_return
);