Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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