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 /* These definitions are missing from windows.h */
14 WINGDIAPI
int WINAPI
wglChoosePixelFormat(HDC
, PIXELFORMATDESCRIPTOR
*);
15 WINGDIAPI
int WINAPI
wglDescribePixelFormat(HDC
, int, UINT
, LPPIXELFORMATDESCRIPTOR
);
16 WINGDIAPI
int WINAPI
wglGetPixelFormat(HDC
);
17 WINGDIAPI BOOL WINAPI
wglSetPixelFormat(HDC
, int, PIXELFORMATDESCRIPTOR
*);
18 WINGDIAPI BOOL WINAPI
wglSwapBuffers(HDC
);
20 /* Type definitions (conversions) */
21 typedef int Visual
; /* Win32 equivalent of X11 type */
23 typedef HPALETTE Colormap
;
24 typedef PIXELFORMATDESCRIPTOR XVisualInfo
;
28 typedef HCURSOR Cursor
;
30 typedef int Atom
; /* dummies */
34 #define True TRUE /* Win32 equivalents of X11 booleans */
37 #define None 0L /* universal null resource or null atom */
39 /* Input Event Masks. Used as event-mask window attribute and as arguments
40 to Grab requests. Not to be confused with event names. */
42 #define NoEventMask 0L
43 #define KeyPressMask (1L<<0)
44 #define KeyReleaseMask (1L<<1)
45 #define ButtonPressMask (1L<<2)
46 #define ButtonReleaseMask (1L<<3)
47 #define EnterWindowMask (1L<<4)
48 #define LeaveWindowMask (1L<<5)
49 #define PointerMotionMask (1L<<6)
50 #define PointerMotionHintMask (1L<<7)
51 #define Button1MotionMask (1L<<8)
52 #define Button2MotionMask (1L<<9)
53 #define Button3MotionMask (1L<<10)
54 #define Button4MotionMask (1L<<11)
55 #define Button5MotionMask (1L<<12)
56 #define ButtonMotionMask (1L<<13)
57 #define KeymapStateMask (1L<<14)
58 #define ExposureMask (1L<<15)
59 #define VisibilityChangeMask (1L<<16)
60 #define StructureNotifyMask (1L<<17)
61 #define ResizeRedirectMask (1L<<18)
62 #define SubstructureNotifyMask (1L<<19)
63 #define SubstructureRedirectMask (1L<<20)
64 #define FocusChangeMask (1L<<21)
65 #define PropertyChangeMask (1L<<22)
66 #define ColormapChangeMask (1L<<23)
67 #define OwnerGrabButtonMask (1L<<24)
69 /* Key masks. Used as modifiers to GrabButton and GrabKey, results of
70 QueryPointer, state in various key-, mouse-, and button-related
73 #define ShiftMask (1<<0)
74 #define LockMask (1<<1)
75 #define ControlMask (1<<2)
76 #define Mod1Mask (1<<3)
77 #define Mod2Mask (1<<4)
78 #define Mod3Mask (1<<5)
79 #define Mod4Mask (1<<6)
80 #define Mod5Mask (1<<7)
82 /* Window classes used by CreateWindow */
83 /* Note that CopyFromParent is already defined as 0 above */
88 /* Window attributes for CreateWindow and ChangeWindowAttributes */
90 #define CWBackPixmap (1L<<0)
91 #define CWBackPixel (1L<<1)
92 #define CWBorderPixmap (1L<<2)
93 #define CWBorderPixel (1L<<3)
94 #define CWBitGravity (1L<<4)
95 #define CWWinGravity (1L<<5)
96 #define CWBackingStore (1L<<6)
97 #define CWBackingPlanes (1L<<7)
98 #define CWBackingPixel (1L<<8)
99 #define CWOverrideRedirect (1L<<9)
100 #define CWSaveUnder (1L<<10)
101 #define CWEventMask (1L<<11)
102 #define CWDontPropagate (1L<<12)
103 #define CWColormap (1L<<13)
104 #define CWCursor (1L<<14)
106 /* ConfigureWindow structure */
110 #define CWWidth (1<<2)
111 #define CWHeight (1<<3)
112 #define CWBorderWidth (1<<4)
113 #define CWSibling (1<<5)
114 #define CWStackMode (1<<6)
117 /* Used in GetWindowAttributes reply */
120 #define IsUnviewable 1
123 /* Window stacking method (in configureWindow) */
131 /* For CreateColormap */
133 #define AllocNone 0 /* create map with no entries */
134 #define AllocAll 1 /* allocate entire map writeable */
137 /* Flags used in StoreNamedColor, StoreColors */
140 #define DoGreen (1<<1)
141 #define DoBlue (1<<2)
144 * Bitmask returned by XParseGeometry(). Each bit tells if the corresponding
145 * value (x, y, width, height) was found in the parsed string.
147 #define NoValue 0x0000
148 #define XValue 0x0001
149 #define YValue 0x0002
150 #define WidthValue 0x0004
151 #define HeightValue 0x0008
152 #define AllValues 0x000F
153 #define XNegative 0x0010
154 #define YNegative 0x0020
156 /* flags argument in size hints */
157 #define USPosition (1L << 0) /* user specified x, y */
158 #define USSize (1L << 1) /* user specified width, height */
160 /* definitions for initial window state */
161 #define WithdrawnState 0 /* for windows that are not mapped */
162 #define NormalState 1 /* most applications want to start this way */
163 #define IconicState 3 /* application wants to start as an icon */
164 #define GameModeState 4 /* Win32 GLUT only (not in Xlib!). */
166 /* Type definitions */
169 unsigned int background_pixmap
; /* background pixmap */
170 unsigned long background_pixel
; /* background pixel */
171 unsigned long border_pixel
; /* border pixel value */
172 long event_mask
; /* set of events that should be saved */
173 long do_not_propagate_mask
; /* set of events that should not propagate */
174 Bool override_redirect
; /* boolean value for override-redirect */
175 Colormap colormap
; /* color map to be associated with window */
176 } XSetWindowAttributes
;
180 unsigned short red
, green
, blue
;
181 char flags
; /* do_red, do_green, do_blue */
185 unsigned char *value
; /* same as Property routines */
186 Atom encoding
; /* prop type */
187 int format
; /* prop data format: 8, 16, or 32 */
188 unsigned long nitems
; /* number of data items in value */
192 long flags
; /* marks which fields in this structure are defined */
193 int x
, y
; /* obsolete for new window mgrs, but clients */
194 int width
, height
; /* should set so old wm's don't mess up */
197 /* Functions emulated by macros. */
199 #define XFreeColormap(display, colormap) \
200 DeleteObject(colormap)
202 #define XCreateFontCursor(display, shape) \
203 LoadCursor(NULL, shape)
205 #define XDefineCursor(display, window, cursor) \
208 #define XFlush(display) \
211 #define DisplayWidth(display, screen) \
212 GetSystemMetrics(SM_CXSCREEN)
214 #define DisplayHeight(display, screen) \
215 GetSystemMetrics(SM_CYSCREEN)
217 #define XMapWindow(display, window) \
218 ShowWindow(window, SW_SHOWNORMAL)
220 #define XUnmapWindow(display, window) \
221 ShowWindow(window, SW_HIDE)
223 #define XIconifyWindow(display, window, screen) \
224 ShowWindow(window, SW_MINIMIZE)
226 #define XWithdrawWindow(display, window, screen) \
227 ShowWindow(window, SW_HIDE)
229 #define XLowerWindow(display, window) \
230 SetWindowPos(window, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE)
232 #define XSetWMName(display, window, tp) \
233 SetWindowText(window, (tp)->value)
235 /* There really isn't a way to set the icon name separate from the
236 windows name in Win32, so, just set the windows name. */
237 #define XSetWMIconName(display, window, tp) \
238 XSetWMName(display, window, tp)
240 #define XDestroyWindow(display, window) \
241 DestroyWindow(window)
243 /* Anything that needs to be freed was allocated with malloc in our
244 fake X windows library for Win32, so free it with plain old
246 #define XFree(data) \
249 /* Nothing to be done for this...the pointer is always 'ungrabbed'
251 #define XUngrabPointer(display, time) \
254 /* Function prototypes. */
256 extern XVisualInfo
* XGetVisualInfo(
259 XVisualInfo
* ttemplate
, /* Avoid class with C++ keyword. */
262 extern Colormap
XCreateColormap(
268 extern void XAllocColorCells(
272 unsigned long plane_masks_return
[],
273 unsigned int nplanes
,
274 unsigned long pixels_return
[],
275 unsigned int npixels
);
277 extern void XStoreColor(
282 extern void XSetWindowColormap(
287 extern Bool
XTranslateCoordinates(
289 Window src
, Window dst
,
290 int src_x
, int src_y
,
291 int* dest_x_return
, int* dest_y_return
,
292 Window
* child_return
);
294 extern Status
XGetGeometry(
298 int* x_return
, int* y_return
,
299 unsigned int* width_return
, unsigned int* height_return
,
300 unsigned int *border_width_return
,
301 unsigned int* depth_return
);
303 extern int DisplayWidthMM(
307 extern int DisplayHeightMM(
311 extern void XWarpPointer(
313 Window src
, Window dst
,
314 int src_x
, int src_y
,
315 int src_width
, int src_height
,
316 int dst_x
, int dst_y
);
318 extern int XParseGeometry(
321 unsigned int* width
, unsigned int* height
);
326 #endif /* __win32_x11_h__ */