1 #ifndef __win32_x11_h__
2 #define __win32_x11_h__
4 /* Copyright (c) Nate Robins, 1997. */
6 /* This program is freely distributable without licensing fees
7 and is provided without guarantee or warrantee expressed or
8 implied. This program is -not- in the public domain. */
13 /* Type definitions (conversions) */
14 typedef int Visual
; /* Win32 equivalent of X11 type */
16 typedef HPALETTE Colormap
;
17 typedef PIXELFORMATDESCRIPTOR XVisualInfo
;
21 typedef HCURSOR Cursor
;
23 typedef int Atom
; /* dummies */
27 #define True TRUE /* Win32 equivalents of X11 booleans */
30 #define None 0L /* universal null resource or null atom */
32 /* Input Event Masks. Used as event-mask window attribute and as arguments
33 to Grab requests. Not to be confused with event names. */
35 #define NoEventMask 0L
36 #define KeyPressMask (1L<<0)
37 #define KeyReleaseMask (1L<<1)
38 #define ButtonPressMask (1L<<2)
39 #define ButtonReleaseMask (1L<<3)
40 #define EnterWindowMask (1L<<4)
41 #define LeaveWindowMask (1L<<5)
42 #define PointerMotionMask (1L<<6)
43 #define PointerMotionHintMask (1L<<7)
44 #define Button1MotionMask (1L<<8)
45 #define Button2MotionMask (1L<<9)
46 #define Button3MotionMask (1L<<10)
47 #define Button4MotionMask (1L<<11)
48 #define Button5MotionMask (1L<<12)
49 #define ButtonMotionMask (1L<<13)
50 #define KeymapStateMask (1L<<14)
51 #define ExposureMask (1L<<15)
52 #define VisibilityChangeMask (1L<<16)
53 #define StructureNotifyMask (1L<<17)
54 #define ResizeRedirectMask (1L<<18)
55 #define SubstructureNotifyMask (1L<<19)
56 #define SubstructureRedirectMask (1L<<20)
57 #define FocusChangeMask (1L<<21)
58 #define PropertyChangeMask (1L<<22)
59 #define ColormapChangeMask (1L<<23)
60 #define OwnerGrabButtonMask (1L<<24)
62 /* Key masks. Used as modifiers to GrabButton and GrabKey, results of
63 QueryPointer, state in various key-, mouse-, and button-related
66 #define ShiftMask (1<<0)
67 #define LockMask (1<<1)
68 #define ControlMask (1<<2)
69 #define Mod1Mask (1<<3)
70 #define Mod2Mask (1<<4)
71 #define Mod3Mask (1<<5)
72 #define Mod4Mask (1<<6)
73 #define Mod5Mask (1<<7)
75 /* Window classes used by CreateWindow */
76 /* Note that CopyFromParent is already defined as 0 above */
81 /* Window attributes for CreateWindow and ChangeWindowAttributes */
83 #define CWBackPixmap (1L<<0)
84 #define CWBackPixel (1L<<1)
85 #define CWBorderPixmap (1L<<2)
86 #define CWBorderPixel (1L<<3)
87 #define CWBitGravity (1L<<4)
88 #define CWWinGravity (1L<<5)
89 #define CWBackingStore (1L<<6)
90 #define CWBackingPlanes (1L<<7)
91 #define CWBackingPixel (1L<<8)
92 #define CWOverrideRedirect (1L<<9)
93 #define CWSaveUnder (1L<<10)
94 #define CWEventMask (1L<<11)
95 #define CWDontPropagate (1L<<12)
96 #define CWColormap (1L<<13)
97 #define CWCursor (1L<<14)
99 /* ConfigureWindow structure */
103 #define CWWidth (1<<2)
104 #define CWHeight (1<<3)
105 #define CWBorderWidth (1<<4)
106 #define CWSibling (1<<5)
107 #define CWStackMode (1<<6)
110 /* Used in GetWindowAttributes reply */
113 #define IsUnviewable 1
116 /* Window stacking method (in configureWindow) */
124 /* For CreateColormap */
126 #define AllocNone 0 /* create map with no entries */
127 #define AllocAll 1 /* allocate entire map writeable */
130 /* Flags used in StoreNamedColor, StoreColors */
133 #define DoGreen (1<<1)
134 #define DoBlue (1<<2)
137 * Bitmask returned by XParseGeometry(). Each bit tells if the corresponding
138 * value (x, y, width, height) was found in the parsed string.
140 #define NoValue 0x0000
141 #define XValue 0x0001
142 #define YValue 0x0002
143 #define WidthValue 0x0004
144 #define HeightValue 0x0008
145 #define AllValues 0x000F
146 #define XNegative 0x0010
147 #define YNegative 0x0020
149 /* flags argument in size hints */
150 #define USPosition (1L << 0) /* user specified x, y */
151 #define USSize (1L << 1) /* user specified width, height */
153 /* definitions for initial window state */
154 #define WithdrawnState 0 /* for windows that are not mapped */
155 #define NormalState 1 /* most applications want to start this way */
156 #define IconicState 3 /* application wants to start as an icon */
157 #define GameModeState 4 /* Win32 GLUT only (not in Xlib!). */
159 /* Type definitions */
162 unsigned int background_pixmap
; /* background pixmap */
163 unsigned long background_pixel
; /* background pixel */
164 unsigned long border_pixel
; /* border pixel value */
165 long event_mask
; /* set of events that should be saved */
166 long do_not_propagate_mask
; /* set of events that should not propagate */
167 Bool override_redirect
; /* boolean value for override-redirect */
168 Colormap colormap
; /* color map to be associated with window */
169 } XSetWindowAttributes
;
173 unsigned short red
, green
, blue
;
174 char flags
; /* do_red, do_green, do_blue */
178 unsigned char *value
; /* same as Property routines */
179 Atom encoding
; /* prop type */
180 int format
; /* prop data format: 8, 16, or 32 */
181 unsigned long nitems
; /* number of data items in value */
185 long flags
; /* marks which fields in this structure are defined */
186 int x
, y
; /* obsolete for new window mgrs, but clients */
187 int width
, height
; /* should set so old wm's don't mess up */
190 /* Functions emulated by macros. */
192 #define XFreeColormap(display, colormap) \
193 DeleteObject(colormap)
195 #define XCreateFontCursor(display, shape) \
196 LoadCursor(NULL, shape)
198 #define XDefineCursor(display, window, cursor) \
201 #define XFlush(display) \
204 #define DisplayWidth(display, screen) \
205 GetSystemMetrics(SM_CXSCREEN)
207 #define DisplayHeight(display, screen) \
208 GetSystemMetrics(SM_CYSCREEN)
210 #define XMapWindow(display, window) \
211 ShowWindow(window, SW_SHOWNORMAL)
213 #define XUnmapWindow(display, window) \
214 ShowWindow(window, SW_HIDE)
216 #define XIconifyWindow(display, window, screen) \
217 ShowWindow(window, SW_MINIMIZE)
219 #define XWithdrawWindow(display, window, screen) \
220 ShowWindow(window, SW_HIDE)
222 #define XLowerWindow(display, window) \
223 SetWindowPos(window, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE)
225 #define XSetWMName(display, window, tp) \
226 SetWindowText(window, (tp)->value)
228 /* There really isn't a way to set the icon name separate from the
229 windows name in Win32, so, just set the windows name. */
230 #define XSetWMIconName(display, window, tp) \
231 XSetWMName(display, window, tp)
233 #define XDestroyWindow(display, window) \
234 DestroyWindow(window)
236 /* Anything that needs to be freed was allocated with malloc in our
237 fake X windows library for Win32, so free it with plain old
239 #define XFree(data) \
242 /* Nothing to be done for this...the pointer is always 'ungrabbed'
244 #define XUngrabPointer(display, time) \
247 /* Function prototypes. */
249 extern XVisualInfo
* XGetVisualInfo(
252 XVisualInfo
* ttemplate
, /* Avoid class with C++ keyword. */
255 extern Colormap
XCreateColormap(
261 extern void XAllocColorCells(
265 unsigned long plane_masks_return
[],
266 unsigned int nplanes
,
267 unsigned long pixels_return
[],
268 unsigned int npixels
);
270 extern void XStoreColor(
275 extern void XSetWindowColormap(
280 extern Bool
XTranslateCoordinates(
282 Window src
, Window dst
,
283 int src_x
, int src_y
,
284 int* dest_x_return
, int* dest_y_return
,
285 Window
* child_return
);
287 extern Status
XGetGeometry(
291 int* x_return
, int* y_return
,
292 unsigned int* width_return
, unsigned int* height_return
,
293 unsigned int *border_width_return
,
294 unsigned int* depth_return
);
296 extern int DisplayWidthMM(
300 extern int DisplayHeightMM(
304 extern void XWarpPointer(
306 Window src
, Window dst
,
307 int src_x
, int src_y
,
308 int src_width
, int src_height
,
309 int dst_x
, int dst_y
);
311 extern int XParseGeometry(
314 unsigned int* width
, unsigned int* height
);
319 #endif /* __win32_x11_h__ */