dmx.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. /*
  2. * Copyright 2001-2003 Red Hat Inc., Durham, North Carolina.
  3. *
  4. * All Rights Reserved.
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining
  7. * a copy of this software and associated documentation files (the
  8. * "Software"), to deal in the Software without restriction, including
  9. * without limitation on the rights to use, copy, modify, merge,
  10. * publish, distribute, sublicense, and/or sell copies of the Software,
  11. * and to permit persons to whom the Software is furnished to do so,
  12. * subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice (including the
  15. * next paragraph) shall be included in all copies or substantial
  16. * portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  19. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  21. * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
  22. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  23. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  24. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  25. * SOFTWARE.
  26. */
  27. /*
  28. * Authors:
  29. * Kevin E. Martin <kem@redhat.com>
  30. * David H. Dawes <dawes@xfree86.org>
  31. * Rickard E. (Rik) Faith <faith@redhat.com>
  32. *
  33. */
  34. /** \file
  35. * Main header file included by all other DMX-related files.
  36. */
  37. /** \mainpage
  38. * - <a href="http://dmx.sourceforge.net">DMX Home Page</a>
  39. * - <a href="http://sourceforge.net/projects/dmx">DMX Project Page (on
  40. * Source Forge)</a>
  41. * - <a href="http://dmx.sourceforge.net/dmx.html">Distributed Multihead
  42. * X design</a>, the design document for DMX
  43. * - <a href="http://dmx.sourceforge.net/DMXSpec.txt">Client-to-Server
  44. * DMX Extension to the X Protocol</a>
  45. */
  46. #ifndef DMX_H
  47. #define DMX_H
  48. #if HAVE_DMX_CONFIG_H
  49. #include <dmx-config.h>
  50. #endif
  51. #include "gcstruct.h"
  52. /* Handle client-side include files in one place. */
  53. #include "dmxclient.h"
  54. #include "globals.h"
  55. #include "scrnintstr.h"
  56. #include "picturestr.h"
  57. #ifdef GLXEXT
  58. #include <GL/glx.h>
  59. #include <GL/glxint.h>
  60. #endif
  61. typedef enum {
  62. PosNone = -1,
  63. PosAbsolute = 0,
  64. PosRightOf,
  65. PosLeftOf,
  66. PosAbove,
  67. PosBelow,
  68. PosRelative
  69. } PositionType;
  70. /** Provide the typedef globally, but keep the contents opaque outside
  71. * of the input routines. \see dmxinput.h */
  72. typedef struct _DMXInputInfo DMXInputInfo;
  73. /** Provide the typedef globally, but keep the contents opaque outside
  74. * of the XSync statistic routines. \see dmxstat.c */
  75. typedef struct _DMXStatInfo DMXStatInfo;
  76. /** Global structure containing information about each backend screen. */
  77. typedef struct _DMXScreenInfo {
  78. const char *name; /**< Name from command line or config file */
  79. int index; /**< Index into dmxScreens global */
  80. /*---------- Back-end X server information ----------*/
  81. Display *beDisplay; /**< Back-end X server's display */
  82. int beWidth; /**< Width of BE display */
  83. int beHeight; /**< Height of BE display */
  84. int beDepth; /**< Depth of BE display */
  85. int beBPP; /**< Bits per pixel of BE display */
  86. int beXDPI; /**< Horizontal dots per inch of BE */
  87. int beYDPI; /**< Vertical dots per inch of BE */
  88. int beNumDepths; /**< Number of depths on BE server */
  89. int *beDepths; /**< Depths from BE server */
  90. int beNumPixmapFormats; /**< Number of pixmap formats on BE */
  91. XPixmapFormatValues *bePixmapFormats; /**< Pixmap formats on BE */
  92. int beNumVisuals; /**< Number of visuals on BE */
  93. XVisualInfo *beVisuals; /**< Visuals from BE server */
  94. int beDefVisualIndex; /**< Default visual index of BE */
  95. int beNumDefColormaps; /**< Number of default colormaps */
  96. Colormap *beDefColormaps; /**< Default colormaps for DMX server */
  97. Pixel beBlackPixel; /**< Default black pixel for BE */
  98. Pixel beWhitePixel; /**< Default white pixel for BE */
  99. /*---------- Screen window information ----------*/
  100. Window scrnWin; /**< "Screen" window on backend display */
  101. int scrnX; /**< X offset of "screen" WRT BE display */
  102. int scrnY; /**< Y offset of "screen" WRT BE display */
  103. int scrnWidth; /**< Width of "screen" */
  104. int scrnHeight; /**< Height of "screen" */
  105. int scrnXSign; /**< X offset sign of "screen" */
  106. int scrnYSign; /**< Y offset sign of "screen" */
  107. /** Default drawables for "screen" */
  108. Drawable scrnDefDrawables[MAXFORMATS];
  109. struct _DMXScreenInfo *next; /**< List of "screens" on same display */
  110. struct _DMXScreenInfo *over; /**< List of "screens" that overlap */
  111. /*---------- Root window information ----------*/
  112. Window rootWin; /**< "Root" window on backend display */
  113. int rootX; /**< X offset of "root" window WRT "screen"*/
  114. int rootY; /**< Y offset of "root" window WRT "screen"*/
  115. int rootWidth; /**< Width of "root" window */
  116. int rootHeight; /**< Height of "root" window */
  117. int rootXOrigin; /**< Global X origin of "root" window */
  118. int rootYOrigin; /**< Global Y origin of "root" window */
  119. /*---------- Shadow framebuffer information ----------*/
  120. void *shadow; /**< Shadow framebuffer data (if enabled) */
  121. XlibGC shadowGC; /**< Default GC used by shadow FB code */
  122. XImage *shadowFBImage; /**< Screen image used by shadow FB code */
  123. /*---------- Other related information ----------*/
  124. int shared; /**< Non-zero if another Xdmx is running */
  125. Bool WMRunningOnBE;
  126. Cursor noCursor;
  127. Cursor curCursor;
  128. /* Support for cursors on overlapped
  129. * backend displays. */
  130. CursorPtr cursor;
  131. int cursorVisible;
  132. int cursorNotShared; /* for overlapping screens on a backend */
  133. PositionType where; /**< Relative layout information */
  134. int whereX; /**< Relative layout information */
  135. int whereY; /**< Relative layout information */
  136. int whereRefScreen; /**< Relative layout information */
  137. int savedTimeout; /**< Original screen saver timeout */
  138. int dpmsCapable; /**< Non-zero if backend is DPMS capable */
  139. int dpmsEnabled; /**< Non-zero if DPMS enabled */
  140. int dpmsStandby; /**< Original DPMS standby value */
  141. int dpmsSuspend; /**< Original DPMS suspend value */
  142. int dpmsOff; /**< Original DPMS off value */
  143. DMXStatInfo *stat; /**< Statistics about XSync */
  144. Bool needsSync; /**< True if an XSync is pending */
  145. #ifdef GLXEXT
  146. /** Visual information for glxProxy */
  147. int numGlxVisuals;
  148. __GLXvisualConfig *glxVisuals;
  149. int glxMajorOpcode;
  150. int glxErrorBase;
  151. /** FB config information for glxProxy */
  152. __GLXFBConfig *fbconfigs;
  153. int numFBConfigs;
  154. #endif
  155. /** Function pointers to wrapped screen
  156. * functions */
  157. CloseScreenProcPtr CloseScreen;
  158. SaveScreenProcPtr SaveScreen;
  159. CreateGCProcPtr CreateGC;
  160. CreateWindowProcPtr CreateWindow;
  161. DestroyWindowProcPtr DestroyWindow;
  162. PositionWindowProcPtr PositionWindow;
  163. ChangeWindowAttributesProcPtr ChangeWindowAttributes;
  164. RealizeWindowProcPtr RealizeWindow;
  165. UnrealizeWindowProcPtr UnrealizeWindow;
  166. RestackWindowProcPtr RestackWindow;
  167. WindowExposuresProcPtr WindowExposures;
  168. CopyWindowProcPtr CopyWindow;
  169. ResizeWindowProcPtr ResizeWindow;
  170. ReparentWindowProcPtr ReparentWindow;
  171. ChangeBorderWidthProcPtr ChangeBorderWidth;
  172. GetImageProcPtr GetImage;
  173. GetSpansProcPtr GetSpans;
  174. CreatePixmapProcPtr CreatePixmap;
  175. DestroyPixmapProcPtr DestroyPixmap;
  176. BitmapToRegionProcPtr BitmapToRegion;
  177. RealizeFontProcPtr RealizeFont;
  178. UnrealizeFontProcPtr UnrealizeFont;
  179. CreateColormapProcPtr CreateColormap;
  180. DestroyColormapProcPtr DestroyColormap;
  181. InstallColormapProcPtr InstallColormap;
  182. StoreColorsProcPtr StoreColors;
  183. SetShapeProcPtr SetShape;
  184. CreatePictureProcPtr CreatePicture;
  185. DestroyPictureProcPtr DestroyPicture;
  186. ChangePictureClipProcPtr ChangePictureClip;
  187. DestroyPictureClipProcPtr DestroyPictureClip;
  188. ChangePictureProcPtr ChangePicture;
  189. ValidatePictureProcPtr ValidatePicture;
  190. CompositeProcPtr Composite;
  191. GlyphsProcPtr Glyphs;
  192. CompositeRectsProcPtr CompositeRects;
  193. InitIndexedProcPtr InitIndexed;
  194. CloseIndexedProcPtr CloseIndexed;
  195. UpdateIndexedProcPtr UpdateIndexed;
  196. TrapezoidsProcPtr Trapezoids;
  197. TrianglesProcPtr Triangles;
  198. } DMXScreenInfo;
  199. /* Global variables available to all Xserver/hw/dmx routines. */
  200. extern int dmxNumScreens; /**< Number of dmxScreens */
  201. extern DMXScreenInfo *dmxScreens; /**< List of outputs */
  202. extern XErrorEvent dmxLastErrorEvent; /**< Last error that
  203. * occurred */
  204. extern Bool dmxErrorOccurred; /**< True if an error
  205. * occurred */
  206. extern Bool dmxOffScreenOpt; /**< True if using off
  207. * screen
  208. * optimizations */
  209. extern Bool dmxSubdividePrimitives; /**< True if using the
  210. * primitive subdivision
  211. * optimization */
  212. extern Bool dmxLazyWindowCreation; /**< True if using the
  213. * lazy window creation
  214. * optimization */
  215. extern Bool dmxUseXKB; /**< True if the XKB
  216. * extension should be
  217. * used with the backend
  218. * servers */
  219. extern int dmxDepth; /**< Requested depth if
  220. * non-zero */
  221. #ifdef GLXEXT
  222. extern Bool dmxGLXProxy; /**< True if glxProxy
  223. * support is enabled */
  224. extern Bool dmxGLXSwapGroupSupport; /**< True if glxProxy
  225. * support for swap
  226. * groups and barriers
  227. * is enabled */
  228. extern Bool dmxGLXSyncSwap; /**< True if glxProxy
  229. * should force an XSync
  230. * request after each
  231. * swap buffers call */
  232. extern Bool dmxGLXFinishSwap; /**< True if glxProxy
  233. * should force a
  234. * glFinish request
  235. * after each swap
  236. * buffers call */
  237. #endif
  238. extern char *dmxFontPath; /**< NULL if no font
  239. * path is set on the
  240. * command line;
  241. * otherwise, a string
  242. * of comma separated
  243. * paths built from the
  244. * command line
  245. * specified font
  246. * paths */
  247. extern Bool dmxIgnoreBadFontPaths; /**< True if bad font
  248. * paths should be
  249. * ignored during server
  250. * init */
  251. extern Bool dmxAddRemoveScreens; /**< True if add and
  252. * remove screens support
  253. * is enabled */
  254. /** Wrap screen or GC function pointer */
  255. #define DMX_WRAP(_entry, _newfunc, _saved, _actual) \
  256. do { \
  257. (_saved)->_entry = (_actual)->_entry; \
  258. (_actual)->_entry = (_newfunc); \
  259. } while (0)
  260. /** Unwrap screen or GC function pointer */
  261. #define DMX_UNWRAP(_entry, _saved, _actual) \
  262. do { \
  263. (_actual)->_entry = (_saved)->_entry; \
  264. } while (0)
  265. /* Define the MAXSCREENSALLOC/FREE macros, when MAXSCREENS patch has not
  266. * been applied to sources. */
  267. #ifdef MAXSCREENS
  268. #define MAXSCREEN_MAKECONSTSTR1(x) #x
  269. #define MAXSCREEN_MAKECONSTSTR2(x) MAXSCREEN_MAKECONSTSTR1(x)
  270. #define MAXSCREEN_FAILED_TXT "Failed at [" \
  271. MAXSCREEN_MAKECONSTSTR2(__LINE__) ":" __FILE__ "] to allocate object: "
  272. #define _MAXSCREENSALLOCF(o,size,fatal) \
  273. do { \
  274. if (!o) { \
  275. o = calloc((size), sizeof(*(o))); \
  276. if (!o && fatal) FatalError(MAXSCREEN_FAILED_TXT #o); \
  277. } \
  278. } while (0)
  279. #define _MAXSCREENSALLOCR(o,size,retval) \
  280. do { \
  281. if (!o) { \
  282. o = calloc((size), sizeof(*(o))); \
  283. if (!o) return retval; \
  284. } \
  285. } while (0)
  286. #define MAXSCREENSFREE(o) \
  287. do { \
  288. free(o); \
  289. o = NULL; \
  290. } while (0)
  291. #define MAXSCREENSALLOC(o) _MAXSCREENSALLOCF(o,MAXSCREENS, 0)
  292. #define MAXSCREENSALLOC_FATAL(o) _MAXSCREENSALLOCF(o,MAXSCREENS, 1)
  293. #define MAXSCREENSALLOC_RETURN(o,r) _MAXSCREENSALLOCR(o,MAXSCREENS, (r))
  294. #define MAXSCREENSALLOCPLUSONE(o) _MAXSCREENSALLOCF(o,MAXSCREENS+1,0)
  295. #define MAXSCREENSALLOCPLUSONE_FATAL(o) _MAXSCREENSALLOCF(o,MAXSCREENS+1,1)
  296. #define MAXSCREENSCALLOC(o,m) _MAXSCREENSALLOCF(o,MAXSCREENS*(m),0)
  297. #define MAXSCREENSCALLOC_FATAL(o,m) _MAXSCREENSALLOCF(o,MAXSCREENS*(m),1)
  298. #endif
  299. extern DevPrivateKeyRec dmxGCPrivateKeyRec;
  300. #define dmxGCPrivateKey (&dmxGCPrivateKeyRec) /**< Private index for GCs */
  301. extern DevPrivateKeyRec dmxWinPrivateKeyRec;
  302. #define dmxWinPrivateKey (&dmxWinPrivateKeyRec) /**< Private index for Windows */
  303. extern DevPrivateKeyRec dmxPixPrivateKeyRec;
  304. #define dmxPixPrivateKey (&dmxPixPrivateKeyRec) /**< Private index for Pixmaps */
  305. extern int dmxFontPrivateIndex; /**< Private index for Fonts */
  306. extern DevPrivateKeyRec dmxScreenPrivateKeyRec;
  307. #define dmxScreenPrivateKey (&dmxScreenPrivateKeyRec) /**< Private index for Screens */
  308. extern DevPrivateKeyRec dmxColormapPrivateKeyRec;
  309. #define dmxColormapPrivateKey (&dmxColormapPrivateKeyRec) /**< Private index for Colormaps */
  310. extern DevPrivateKeyRec dmxPictPrivateKeyRec;
  311. #define dmxPictPrivateKey (&dmxPictPrivateKeyRec) /**< Private index for Picts */
  312. extern DevPrivateKeyRec dmxGlyphSetPrivateKeyRec;
  313. #define dmxGlyphSetPrivateKey (&dmxGlyphSetPrivateKeyRec) /**< Private index for GlyphSets */
  314. void DMXExtensionInit(void);
  315. #endif /* DMX_H */