2 * Copyright 2001-2003 Red Hat Inc., Durham, North Carolina.
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:
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.
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
30 * Kevin E. Martin <kem@redhat.com>
31 * David H. Dawes <dawes@xfree86.org>
32 * Rickard E. (Rik) Faith <faith@redhat.com>
37 * Main header file included by all other DMX-related files.
41 * - <a href="http://dmx.sourceforge.net">DMX Home Page</a>
42 * - <a href="http://sourceforge.net/projects/dmx">DMX Project Page (on
44 * - <a href="http://dmx.sourceforge.net/dmx.html">Distributed Multihead
45 * X design</a>, the design document for DMX
46 * - <a href="http://dmx.sourceforge.net/DMXSpec.txt">Client-to-Server
47 * DMX Extension to the X Protocol</a>
54 #include <dmx-config.h>
59 /* Handle client-side include files in one place. */
60 #include "dmxclient.h"
63 #include "scrnintstr.h"
65 #include "picturestr.h"
69 #include <GL/glxint.h>
82 /** Provide the typedef globally, but keep the contents opaque outside
83 * of the input routines. \see dmxinput.h */
84 typedef struct _DMXInputInfo DMXInputInfo
;
86 /** Provide the typedef globally, but keep the contents opaque outside
87 * of the XSync statistic routines. \see dmxstat.c */
88 typedef struct _DMXStatInfo DMXStatInfo
;
90 /** Global structure containing information about each backend screen. */
91 typedef struct _DMXScreenInfo
{
92 const char *name
; /**< Name from command line or config file */
93 int index
; /**< Index into dmxScreens global */
95 /*---------- Back-end X server information ----------*/
97 Display
*beDisplay
; /**< Back-end X server's display */
98 int beWidth
; /**< Width of BE display */
99 int beHeight
; /**< Height of BE display */
100 int beDepth
; /**< Depth of BE display */
101 int beBPP
; /**< Bits per pixel of BE display */
102 int beXDPI
; /**< Horizontal dots per inch of BE */
103 int beYDPI
; /**< Vertical dots per inch of BE */
105 int beNumDepths
; /**< Number of depths on BE server */
106 int *beDepths
; /**< Depths from BE server */
108 int beNumPixmapFormats
; /**< Number of pixmap formats on BE */
109 XPixmapFormatValues
*bePixmapFormats
; /**< Pixmap formats on BE */
111 int beNumVisuals
; /**< Number of visuals on BE */
112 XVisualInfo
*beVisuals
; /**< Visuals from BE server */
113 int beDefVisualIndex
; /**< Default visual index of BE */
115 int beNumDefColormaps
; /**< Number of default colormaps */
116 Colormap
*beDefColormaps
; /**< Default colormaps for DMX server */
118 Pixel beBlackPixel
; /**< Default black pixel for BE */
119 Pixel beWhitePixel
; /**< Default white pixel for BE */
121 /*---------- Screen window information ----------*/
123 Window scrnWin
; /**< "Screen" window on backend display */
124 int scrnX
; /**< X offset of "screen" WRT BE display */
125 int scrnY
; /**< Y offset of "screen" WRT BE display */
126 int scrnWidth
; /**< Width of "screen" */
127 int scrnHeight
; /**< Height of "screen" */
128 int scrnXSign
; /**< X offset sign of "screen" */
129 int scrnYSign
; /**< Y offset sign of "screen" */
131 /** Default drawables for "screen" */
132 Drawable scrnDefDrawables
[MAXFORMATS
];
134 struct _DMXScreenInfo
*next
; /**< List of "screens" on same display */
135 struct _DMXScreenInfo
*over
; /**< List of "screens" that overlap */
137 /*---------- Root window information ----------*/
139 Window rootWin
; /**< "Root" window on backend display */
140 int rootX
; /**< X offset of "root" window WRT "screen"*/
141 int rootY
; /**< Y offset of "root" window WRT "screen"*/
142 int rootWidth
; /**< Width of "root" window */
143 int rootHeight
; /**< Height of "root" window */
145 int rootXOrigin
; /**< Global X origin of "root" window */
146 int rootYOrigin
; /**< Global Y origin of "root" window */
148 /*---------- Shadow framebuffer information ----------*/
150 void *shadow
; /**< Shadow framebuffer data (if enabled) */
151 XlibGC shadowGC
; /**< Default GC used by shadow FB code */
152 XImage
*shadowFBImage
; /**< Screen image used by shadow FB code */
154 /*---------- Other related information ----------*/
156 int shared
; /**< Non-zero if another Xdmx is running */
162 /* Support for cursors on overlapped
163 * backend displays. */
166 int cursorNotShared
; /* for overlapping screens on a backend */
168 PositionType where
; /**< Relative layout information */
169 int whereX
; /**< Relative layout information */
170 int whereY
; /**< Relative layout information */
171 int whereRefScreen
; /**< Relative layout information */
173 int savedTimeout
; /**< Original screen saver timeout */
174 int dpmsCapable
; /**< Non-zero if backend is DPMS capable */
175 int dpmsEnabled
; /**< Non-zero if DPMS enabled */
176 int dpmsStandby
; /**< Original DPMS standby value */
177 int dpmsSuspend
; /**< Original DPMS suspend value */
178 int dpmsOff
; /**< Original DPMS off value */
180 DMXStatInfo
*stat
; /**< Statistics about XSync */
181 Bool needsSync
; /**< True if an XSync is pending */
184 /** Visual information for glxProxy */
186 __GLXvisualConfig
*glxVisuals
;
190 /** FB config information for glxProxy */
191 __GLXFBConfig
*fbconfigs
;
195 /** Function pointers to wrapped screen
197 CloseScreenProcPtr CloseScreen
;
198 SaveScreenProcPtr SaveScreen
;
200 CreateGCProcPtr CreateGC
;
202 CreateWindowProcPtr CreateWindow
;
203 DestroyWindowProcPtr DestroyWindow
;
204 PositionWindowProcPtr PositionWindow
;
205 ChangeWindowAttributesProcPtr ChangeWindowAttributes
;
206 RealizeWindowProcPtr RealizeWindow
;
207 UnrealizeWindowProcPtr UnrealizeWindow
;
208 RestackWindowProcPtr RestackWindow
;
209 WindowExposuresProcPtr WindowExposures
;
210 CopyWindowProcPtr CopyWindow
;
212 ResizeWindowProcPtr ResizeWindow
;
213 ReparentWindowProcPtr ReparentWindow
;
215 ChangeBorderWidthProcPtr ChangeBorderWidth
;
217 GetImageProcPtr GetImage
;
218 GetSpansProcPtr GetSpans
;
220 CreatePixmapProcPtr CreatePixmap
;
221 DestroyPixmapProcPtr DestroyPixmap
;
222 BitmapToRegionProcPtr BitmapToRegion
;
224 RealizeFontProcPtr RealizeFont
;
225 UnrealizeFontProcPtr UnrealizeFont
;
227 CreateColormapProcPtr CreateColormap
;
228 DestroyColormapProcPtr DestroyColormap
;
229 InstallColormapProcPtr InstallColormap
;
230 StoreColorsProcPtr StoreColors
;
232 SetShapeProcPtr SetShape
;
234 CreatePictureProcPtr CreatePicture
;
235 DestroyPictureProcPtr DestroyPicture
;
236 ChangePictureClipProcPtr ChangePictureClip
;
237 DestroyPictureClipProcPtr DestroyPictureClip
;
239 ChangePictureProcPtr ChangePicture
;
240 ValidatePictureProcPtr ValidatePicture
;
242 CompositeProcPtr Composite
;
243 GlyphsProcPtr Glyphs
;
244 CompositeRectsProcPtr CompositeRects
;
246 InitIndexedProcPtr InitIndexed
;
247 CloseIndexedProcPtr CloseIndexed
;
248 UpdateIndexedProcPtr UpdateIndexed
;
250 TrapezoidsProcPtr Trapezoids
;
251 TrianglesProcPtr Triangles
;
254 /* Global variables available to all Xserver/hw/dmx routines. */
255 extern int dmxNumScreens
; /**< Number of dmxScreens */
256 extern DMXScreenInfo
*dmxScreens
; /**< List of outputs */
257 extern XErrorEvent dmxLastErrorEvent
; /**< Last error that
260 extern Bool dmxErrorOccurred
; /**< True if an error
263 extern Bool dmxOffScreenOpt
; /**< True if using off
267 extern Bool dmxSubdividePrimitives
; /**< True if using the
269 * primitive subdivision
271 extern Bool dmxLazyWindowCreation
; /**< True if using the
273 * lazy window creation
275 extern Bool dmxUseXKB
; /**< True if the XKB
277 * extension should be
278 * used with the backend
280 extern int dmxDepth
; /**< Requested depth if
284 extern Bool dmxGLXProxy
; /**< True if glxProxy
286 * support is enabled */
287 extern Bool dmxGLXSwapGroupSupport
; /**< True if glxProxy
290 * groups and barriers
292 extern Bool dmxGLXSyncSwap
; /**< True if glxProxy
294 * should force an XSync
296 * swap buffers call */
297 extern Bool dmxGLXFinishSwap
; /**< True if glxProxy
304 extern char *dmxFontPath
; /**< NULL if no font
308 * otherwise, a string
310 * paths built from the
314 extern Bool dmxIgnoreBadFontPaths
; /**< True if bad font
317 * ignored during server
319 extern Bool dmxAddRemoveScreens
; /**< True if add and
321 * remove screens support
324 /** Wrap screen or GC function pointer */
325 #define DMX_WRAP(_entry, _newfunc, _saved, _actual) \
327 (_saved)->_entry = (_actual)->_entry; \
328 (_actual)->_entry = (_newfunc); \
331 /** Unwrap screen or GC function pointer */
332 #define DMX_UNWRAP(_entry, _saved, _actual) \
334 (_actual)->_entry = (_saved)->_entry; \
337 /* Define the MAXSCREENSALLOC/FREE macros, when MAXSCREENS patch has not
338 * been applied to sources. */
340 #define MAXSCREEN_MAKECONSTSTR1(x) #x
341 #define MAXSCREEN_MAKECONSTSTR2(x) MAXSCREEN_MAKECONSTSTR1(x)
343 #define MAXSCREEN_FAILED_TXT "Failed at [" \
344 MAXSCREEN_MAKECONSTSTR2(__LINE__) ":" __FILE__ "] to allocate object: "
346 #define _MAXSCREENSALLOCF(o,size,fatal) \
349 o = calloc((size), sizeof(*(o))); \
350 if (!o && fatal) FatalError(MAXSCREEN_FAILED_TXT #o); \
353 #define _MAXSCREENSALLOCR(o,size,retval) \
356 o = calloc((size), sizeof(*(o))); \
357 if (!o) return retval; \
361 #define MAXSCREENSFREE(o) \
367 #define MAXSCREENSALLOC(o) _MAXSCREENSALLOCF(o,MAXSCREENS, 0)
368 #define MAXSCREENSALLOC_FATAL(o) _MAXSCREENSALLOCF(o,MAXSCREENS, 1)
369 #define MAXSCREENSALLOC_RETURN(o,r) _MAXSCREENSALLOCR(o,MAXSCREENS, (r))
370 #define MAXSCREENSALLOCPLUSONE(o) _MAXSCREENSALLOCF(o,MAXSCREENS+1,0)
371 #define MAXSCREENSALLOCPLUSONE_FATAL(o) _MAXSCREENSALLOCF(o,MAXSCREENS+1,1)
372 #define MAXSCREENSCALLOC(o,m) _MAXSCREENSALLOCF(o,MAXSCREENS*(m),0)
373 #define MAXSCREENSCALLOC_FATAL(o,m) _MAXSCREENSALLOCF(o,MAXSCREENS*(m),1)
376 extern DevPrivateKeyRec dmxGCPrivateKeyRec
;
378 #define dmxGCPrivateKey (&dmxGCPrivateKeyRec) /**< Private index for GCs */
380 extern DevPrivateKeyRec dmxWinPrivateKeyRec
;
382 #define dmxWinPrivateKey (&dmxWinPrivateKeyRec) /**< Private index for Windows */
384 extern DevPrivateKeyRec dmxPixPrivateKeyRec
;
386 #define dmxPixPrivateKey (&dmxPixPrivateKeyRec) /**< Private index for Pixmaps */
388 extern int dmxFontPrivateIndex
; /**< Private index for Fonts */
390 extern DevPrivateKeyRec dmxScreenPrivateKeyRec
;
392 #define dmxScreenPrivateKey (&dmxScreenPrivateKeyRec) /**< Private index for Screens */
394 extern DevPrivateKeyRec dmxColormapPrivateKeyRec
;
396 #define dmxColormapPrivateKey (&dmxColormapPrivateKeyRec) /**< Private index for Colormaps */
398 extern DevPrivateKeyRec dmxPictPrivateKeyRec
;
400 #define dmxPictPrivateKey (&dmxPictPrivateKeyRec) /**< Private index for Picts */
402 extern DevPrivateKeyRec dmxGlyphSetPrivateKeyRec
;
404 #define dmxGlyphSetPrivateKey (&dmxGlyphSetPrivateKeyRec) /**< Private index for GlyphSets */
406 void DMXExtensionInit(void);