| 1 | /* $Id: os2_x11.h,v 1.3 2000-03-11 15:07:47 sandervl Exp $ */
|
|---|
| 2 | #ifndef __os2_x11_h__
|
|---|
| 3 | #define __os2_x11_h__
|
|---|
| 4 |
|
|---|
| 5 | /* Copyright (c) Nate Robins, 1997. */
|
|---|
| 6 |
|
|---|
| 7 | /* This program is freely distributable without licensing fees
|
|---|
| 8 | and is provided without guarantee or warrantee expressed or
|
|---|
| 9 | implied. This program is -not- in the public domain. */
|
|---|
| 10 |
|
|---|
| 11 | /* JvdH 30/01/2000 - GLUT port to Odin */
|
|---|
| 12 |
|
|---|
| 13 | #include <stdlib.h>
|
|---|
| 14 | #include <windows.h>
|
|---|
| 15 |
|
|---|
| 16 | /* Type definitions (conversions) */
|
|---|
| 17 | typedef int Visual; /* OS/2 equivalent of X11 type */
|
|---|
| 18 | typedef HWND Window;
|
|---|
| 19 | typedef HPALETTE Colormap;
|
|---|
| 20 | typedef PIXELFORMATDESCRIPTOR XVisualInfo;
|
|---|
| 21 | typedef BOOL Bool;
|
|---|
| 22 | typedef MSG XEvent;
|
|---|
| 23 | typedef HDC Display;
|
|---|
| 24 | typedef HCURSOR Cursor;
|
|---|
| 25 |
|
|---|
| 26 | typedef int Atom; /* dummies */
|
|---|
| 27 | typedef int XDevice;
|
|---|
| 28 | typedef int Status;
|
|---|
| 29 |
|
|---|
| 30 | #define True TRUE /* OS/2 equivalents of X11 booleans */
|
|---|
| 31 | #define False FALSE
|
|---|
| 32 |
|
|---|
| 33 | #define None 0L /* universal null resource or null atom */
|
|---|
| 34 |
|
|---|
| 35 | /* Input Event Masks. Used as event-mask window attribute and as arguments
|
|---|
| 36 | to Grab requests. Not to be confused with event names. */
|
|---|
| 37 |
|
|---|
| 38 | #define NoEventMask 0L
|
|---|
| 39 | #define KeyPressMask (1L<<0)
|
|---|
| 40 | #define KeyReleaseMask (1L<<1)
|
|---|
| 41 | #define ButtonPressMask (1L<<2)
|
|---|
| 42 | #define ButtonReleaseMask (1L<<3)
|
|---|
| 43 | #define EnterWindowMask (1L<<4)
|
|---|
| 44 | #define LeaveWindowMask (1L<<5)
|
|---|
| 45 | #define PointerMotionMask (1L<<6)
|
|---|
| 46 | #define PointerMotionHintMask (1L<<7)
|
|---|
| 47 | #define Button1MotionMask (1L<<8)
|
|---|
| 48 | #define Button2MotionMask (1L<<9)
|
|---|
| 49 | #define Button3MotionMask (1L<<10)
|
|---|
| 50 | #define Button4MotionMask (1L<<11)
|
|---|
| 51 | #define Button5MotionMask (1L<<12)
|
|---|
| 52 | #define ButtonMotionMask (1L<<13)
|
|---|
| 53 | #define KeymapStateMask (1L<<14)
|
|---|
| 54 | #define ExposureMask (1L<<15)
|
|---|
| 55 | #define VisibilityChangeMask (1L<<16)
|
|---|
| 56 | #define StructureNotifyMask (1L<<17)
|
|---|
| 57 | #define ResizeRedirectMask (1L<<18)
|
|---|
| 58 | #define SubstructureNotifyMask (1L<<19)
|
|---|
| 59 | #define SubstructureRedirectMask (1L<<20)
|
|---|
| 60 | #define FocusChangeMask (1L<<21)
|
|---|
| 61 | #define PropertyChangeMask (1L<<22)
|
|---|
| 62 | #define ColormapChangeMask (1L<<23)
|
|---|
| 63 | #define OwnerGrabButtonMask (1L<<24)
|
|---|
| 64 |
|
|---|
| 65 | /* Key masks. Used as modifiers to GrabButton and GrabKey, results of
|
|---|
| 66 | QueryPointer, state in various key-, mouse-, and button-related
|
|---|
| 67 | events. */
|
|---|
| 68 |
|
|---|
| 69 | #define ShiftMask (1<<0)
|
|---|
| 70 | #define LockMask (1<<1)
|
|---|
| 71 | #define ControlMask (1<<2)
|
|---|
| 72 | #define Mod1Mask (1<<3)
|
|---|
| 73 | #define Mod2Mask (1<<4)
|
|---|
| 74 | #define Mod3Mask (1<<5)
|
|---|
| 75 | #define Mod4Mask (1<<6)
|
|---|
| 76 | #define Mod5Mask (1<<7)
|
|---|
| 77 |
|
|---|
| 78 | /* Window classes used by CreateWindow */
|
|---|
| 79 | /* Note that CopyFromParent is already defined as 0 above */
|
|---|
| 80 |
|
|---|
| 81 | #define InputOutput 1
|
|---|
| 82 | #define InputOnly 2
|
|---|
| 83 |
|
|---|
| 84 | /* Window attributes for CreateWindow and ChangeWindowAttributes */
|
|---|
| 85 |
|
|---|
| 86 | #define CWBackPixmap (1L<<0)
|
|---|
| 87 | #define CWBackPixel (1L<<1)
|
|---|
| 88 | #define CWBorderPixmap (1L<<2)
|
|---|
| 89 | #define CWBorderPixel (1L<<3)
|
|---|
| 90 | #define CWBitGravity (1L<<4)
|
|---|
| 91 | #define CWWinGravity (1L<<5)
|
|---|
| 92 | #define CWBackingStore (1L<<6)
|
|---|
| 93 | #define CWBackingPlanes (1L<<7)
|
|---|
| 94 | #define CWBackingPixel (1L<<8)
|
|---|
| 95 | #define CWOverrideRedirect (1L<<9)
|
|---|
| 96 | #define CWSaveUnder (1L<<10)
|
|---|
| 97 | #define CWEventMask (1L<<11)
|
|---|
| 98 | #define CWDontPropagate (1L<<12)
|
|---|
| 99 | #define CWColormap (1L<<13)
|
|---|
| 100 | #define CWCursor (1L<<14)
|
|---|
| 101 |
|
|---|
| 102 | /* ConfigureWindow structure */
|
|---|
| 103 |
|
|---|
| 104 | #define CWX (1<<0)
|
|---|
| 105 | #define CWY (1<<1)
|
|---|
| 106 | #define CWWidth (1<<2)
|
|---|
| 107 | #define CWHeight (1<<3)
|
|---|
| 108 | #define CWBorderWidth (1<<4)
|
|---|
| 109 | #define CWSibling (1<<5)
|
|---|
| 110 | #define CWStackMode (1<<6)
|
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 | /* Used in GetWindowAttributes reply */
|
|---|
| 114 |
|
|---|
| 115 | #define IsUnmapped 0
|
|---|
| 116 | #define IsUnviewable 1
|
|---|
| 117 | #define IsViewable 2
|
|---|
| 118 |
|
|---|
| 119 | /* Window stacking method (in configureWindow) */
|
|---|
| 120 |
|
|---|
| 121 | #define Above 0
|
|---|
| 122 | #define Below 1
|
|---|
| 123 | #define TopIf 2
|
|---|
| 124 | #define BottomIf 3
|
|---|
| 125 | #define Opposite 4
|
|---|
| 126 |
|
|---|
| 127 | /* For CreateColormap */
|
|---|
| 128 |
|
|---|
| 129 | #define AllocNone 0 /* create map with no entries */
|
|---|
| 130 | #define AllocAll 1 /* allocate entire map writeable */
|
|---|
| 131 |
|
|---|
| 132 |
|
|---|
| 133 | /* Flags used in StoreNamedColor, StoreColors */
|
|---|
| 134 |
|
|---|
| 135 | #define DoRed (1<<0)
|
|---|
| 136 | #define DoGreen (1<<1)
|
|---|
| 137 | #define DoBlue (1<<2)
|
|---|
| 138 |
|
|---|
| 139 | /*
|
|---|
| 140 | * Bitmask returned by XParseGeometry(). Each bit tells if the corresponding
|
|---|
| 141 | * value (x, y, width, height) was found in the parsed string.
|
|---|
| 142 | */
|
|---|
| 143 | #define NoValue 0x0000
|
|---|
| 144 | #define XValue 0x0001
|
|---|
| 145 | #define YValue 0x0002
|
|---|
| 146 | #define WidthValue 0x0004
|
|---|
| 147 | #define HeightValue 0x0008
|
|---|
| 148 | #define AllValues 0x000F
|
|---|
| 149 | #define XNegative 0x0010
|
|---|
| 150 | #define YNegative 0x0020
|
|---|
| 151 |
|
|---|
| 152 | /* flags argument in size hints */
|
|---|
| 153 | #define USPosition (1L << 0) /* user specified x, y */
|
|---|
| 154 | #define USSize (1L << 1) /* user specified width, height */
|
|---|
| 155 |
|
|---|
| 156 | /* definitions for initial window state */
|
|---|
| 157 | #define WithdrawnState 0 /* for windows that are not mapped */
|
|---|
| 158 | #define NormalState 1 /* most applications want to start this way */
|
|---|
| 159 | #define IconicState 3 /* application wants to start as an icon */
|
|---|
| 160 | #define GameModeState 4 /* Win32 GLUT only (not in Xlib!). */
|
|---|
| 161 |
|
|---|
| 162 | /* Type definitions */
|
|---|
| 163 |
|
|---|
| 164 | typedef struct {
|
|---|
| 165 | unsigned int background_pixmap; /* background pixmap */
|
|---|
| 166 | unsigned long background_pixel; /* background pixel */
|
|---|
| 167 | unsigned long border_pixel; /* border pixel value */
|
|---|
| 168 | long event_mask; /* set of events that should be saved */
|
|---|
| 169 | long do_not_propagate_mask; /* set of events that should not propagate */
|
|---|
| 170 | Bool override_redirect; /* boolean value for override-redirect */
|
|---|
| 171 | Colormap colormap; /* color map to be associated with window */
|
|---|
| 172 | } XSetWindowAttributes;
|
|---|
| 173 |
|
|---|
| 174 | typedef struct {
|
|---|
| 175 | unsigned long pixel;
|
|---|
| 176 | unsigned short red, green, blue;
|
|---|
| 177 | char flags; /* do_red, do_green, do_blue */
|
|---|
| 178 | } XColor;
|
|---|
| 179 |
|
|---|
| 180 | typedef struct {
|
|---|
| 181 | unsigned char *value; /* same as Property routines */
|
|---|
| 182 | Atom encoding; /* prop type */
|
|---|
| 183 | int format; /* prop data format: 8, 16, or 32 */
|
|---|
| 184 | unsigned long nitems; /* number of data items in value */
|
|---|
| 185 | } XTextProperty;
|
|---|
| 186 |
|
|---|
| 187 | typedef struct {
|
|---|
| 188 | long flags; /* marks which fields in this structure are defined*/
|
|---|
| 189 | int x, y; /* obsolete for new window mgrs, but clients*/
|
|---|
| 190 | int width, height; /* should set so old wm's don't mess up*/
|
|---|
| 191 | } XSizeHints;
|
|---|
| 192 |
|
|---|
| 193 | /* Functions emulated by macros. */
|
|---|
| 194 |
|
|---|
| 195 | #define XFreeColormap(display, colormap) \
|
|---|
| 196 | DeleteObject(colormap)
|
|---|
| 197 |
|
|---|
| 198 | #if defined(__WIN32OS2__)
|
|---|
| 199 | #define XCreateFontCursor(display, shape) \
|
|---|
| 200 | LoadCursorA(NULL, shape)
|
|---|
| 201 | #else
|
|---|
| 202 | #define XCreateFontCursor(display, shape) \
|
|---|
| 203 | LoadCursor(NULL, shape)
|
|---|
| 204 | #endif
|
|---|
| 205 |
|
|---|
| 206 | #define XDefineCursor(display, window, cursor) \
|
|---|
| 207 | SetCursor(cursor)
|
|---|
| 208 |
|
|---|
| 209 | #define XFlush(display) \
|
|---|
| 210 | /* Nothing. */
|
|---|
| 211 |
|
|---|
| 212 | #define DisplayWidth(display, screen) \
|
|---|
| 213 | GetSystemMetrics(SM_CXSCREEN)
|
|---|
| 214 |
|
|---|
| 215 | #define DisplayHeight(display, screen) \
|
|---|
| 216 | GetSystemMetrics(SM_CYSCREEN)
|
|---|
| 217 |
|
|---|
| 218 | #define XMapWindow(display, window) \
|
|---|
| 219 | ShowWindow(window, SW_SHOWNORMAL)
|
|---|
| 220 |
|
|---|
| 221 | #define XUnmapWindow(display, window) \
|
|---|
| 222 | ShowWindow(window, SW_HIDE)
|
|---|
| 223 |
|
|---|
| 224 | #define XIconifyWindow(display, window, screen) \
|
|---|
| 225 | ShowWindow(window, SW_MINIMIZE)
|
|---|
| 226 |
|
|---|
| 227 | #define XWithdrawWindow(display, window, screen) \
|
|---|
| 228 | ShowWindow(window, SW_HIDE)
|
|---|
| 229 |
|
|---|
| 230 | #define XLowerWindow(display, window) \
|
|---|
| 231 | SetWindowPos(window, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE)
|
|---|
| 232 |
|
|---|
| 233 | #if defined(__WIN32OS2__)
|
|---|
| 234 | #define XSetWMName(display, window, tp) \
|
|---|
| 235 | SetWindowTextA(window, (LPCSTR)(tp)->value)
|
|---|
| 236 | #else
|
|---|
| 237 | #define XSetWMName(display, window, tp) \
|
|---|
| 238 | SetWindowText(window, (tp)->value)
|
|---|
| 239 | #endif
|
|---|
| 240 |
|
|---|
| 241 | /* There really isn't a way to set the icon name separate from the
|
|---|
| 242 | windows name in Win32, so, just set the windows name. */
|
|---|
| 243 | #define XSetWMIconName(display, window, tp) \
|
|---|
| 244 | XSetWMName(display, window, tp)
|
|---|
| 245 |
|
|---|
| 246 | #define XDestroyWindow(display, window) \
|
|---|
| 247 | DestroyWindow(window)
|
|---|
| 248 |
|
|---|
| 249 | /* Anything that needs to be freed was allocated with malloc in our
|
|---|
| 250 | fake X windows library for Win32, so free it with plain old
|
|---|
| 251 | free(). */
|
|---|
| 252 | #define XFree(data) \
|
|---|
| 253 | free(data)
|
|---|
| 254 |
|
|---|
| 255 | /* Nothing to be done for this...the pointer is always 'ungrabbed'
|
|---|
| 256 | in Win32. */
|
|---|
| 257 | #define XUngrabPointer(display, time) \
|
|---|
| 258 | /* Nothing. */
|
|---|
| 259 |
|
|---|
| 260 | /* Function prototypes. */
|
|---|
| 261 |
|
|---|
| 262 | extern XVisualInfo* XGetVisualInfo(
|
|---|
| 263 | Display* display,
|
|---|
| 264 | long mask,
|
|---|
| 265 | XVisualInfo* ttemplate, /* Avoid class with C++ keyword.*/
|
|---|
| 266 | int*nitems);
|
|---|
| 267 |
|
|---|
| 268 | extern Colormap XCreateColormap(
|
|---|
| 269 | Display* display,
|
|---|
| 270 | Window root,
|
|---|
| 271 | Visual* visual,
|
|---|
| 272 | int alloc);
|
|---|
| 273 |
|
|---|
| 274 | extern void XAllocColorCells(
|
|---|
| 275 | Display* display,
|
|---|
| 276 | Colormap colormap,
|
|---|
| 277 | Bool contig,
|
|---|
| 278 | unsigned long plane_masks_return[],
|
|---|
| 279 | unsigned int nplanes,
|
|---|
| 280 | unsigned long pixels_return[],
|
|---|
| 281 | unsigned int npixels);
|
|---|
| 282 |
|
|---|
| 283 | extern void XStoreColor(
|
|---|
| 284 | Display* display,
|
|---|
| 285 | Colormap colormap,
|
|---|
| 286 | XColor* color);
|
|---|
| 287 |
|
|---|
| 288 | extern void XSetWindowColormap(
|
|---|
| 289 | Display* display,
|
|---|
| 290 | Window window,
|
|---|
| 291 | Colormap colormap);
|
|---|
| 292 |
|
|---|
| 293 | extern Bool XTranslateCoordinates(
|
|---|
| 294 | Display *display,
|
|---|
| 295 | Window src, Window dst,
|
|---|
| 296 | int src_x, int src_y,
|
|---|
| 297 | int* dest_x_return, int* dest_y_return,
|
|---|
| 298 | Window* child_return);
|
|---|
| 299 |
|
|---|
| 300 | extern Status XGetGeometry(
|
|---|
| 301 | Display* display,
|
|---|
| 302 | Window window,
|
|---|
| 303 | Window* root_return,
|
|---|
| 304 | int* x_return, int* y_return,
|
|---|
| 305 | unsigned int* width_return, unsigned int* height_return,
|
|---|
| 306 | unsigned int *border_width_return,
|
|---|
| 307 | unsigned int* depth_return);
|
|---|
| 308 |
|
|---|
| 309 | extern int DisplayWidthMM(
|
|---|
| 310 | Display* display,
|
|---|
| 311 | int screen);
|
|---|
| 312 |
|
|---|
| 313 | extern int DisplayHeightMM(
|
|---|
| 314 | Display* display,
|
|---|
| 315 | int screen);
|
|---|
| 316 |
|
|---|
| 317 | extern void XWarpPointer(
|
|---|
| 318 | Display* display,
|
|---|
| 319 | Window src, Window dst,
|
|---|
| 320 | int src_x, int src_y,
|
|---|
| 321 | int src_width, int src_height,
|
|---|
| 322 | int dst_x, int dst_y);
|
|---|
| 323 |
|
|---|
| 324 | extern int XParseGeometry(
|
|---|
| 325 | char* string,
|
|---|
| 326 | int* x, int* y,
|
|---|
| 327 | unsigned int* width, unsigned int* height);
|
|---|
| 328 |
|
|---|
| 329 | extern int XPending(
|
|---|
| 330 | Display* display);
|
|---|
| 331 |
|
|---|
| 332 | #endif /* __win32_x11_h__ */
|
|---|