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"
66 #include "picturestr.h"
71 #include <GL/glxint.h>
84 /** Provide the typedef globally, but keep the contents opaque outside
85 * of the input routines. \see dmxinput.h */
86 typedef struct _DMXInputInfo DMXInputInfo
;
88 /** Provide the typedef globally, but keep the contents opaque outside
89 * of the XSync statistic routines. \see dmxstat.c */
90 typedef struct _DMXStatInfo DMXStatInfo
;
92 /** Global structure containing information about each backend screen. */
93 typedef struct _DMXScreenInfo
{
94 const char *name
; /**< Name from command line or config file */
95 int index
; /**< Index into dmxScreens global */
97 /*---------- Back-end X server information ----------*/
99 Display
*beDisplay
; /**< Back-end X server's display */
100 int beWidth
; /**< Width of BE display */
101 int beHeight
; /**< Height of BE display */
102 int beDepth
; /**< Depth of BE display */
103 int beBPP
; /**< Bits per pixel of BE display */
104 int beXDPI
; /**< Horizontal dots per inch of BE */
105 int beYDPI
; /**< Vertical dots per inch of BE */
107 int beNumDepths
; /**< Number of depths on BE server */
108 int *beDepths
; /**< Depths from BE server */
110 int beNumPixmapFormats
; /**< Number of pixmap formats on BE */
111 XPixmapFormatValues
*bePixmapFormats
; /**< Pixmap formats on BE */
113 int beNumVisuals
; /**< Number of visuals on BE */
114 XVisualInfo
*beVisuals
; /**< Visuals from BE server */
115 int beDefVisualIndex
; /**< Default visual index of BE */
117 int beNumDefColormaps
; /**< Number of default colormaps */
118 Colormap
*beDefColormaps
; /**< Default colormaps for DMX server */
120 Pixel beBlackPixel
; /**< Default black pixel for BE */
121 Pixel beWhitePixel
; /**< Default white pixel for BE */
123 /*---------- Screen window information ----------*/
125 Window scrnWin
; /**< "Screen" window on backend display */
126 int scrnX
; /**< X offset of "screen" WRT BE display */
127 int scrnY
; /**< Y offset of "screen" WRT BE display */
128 int scrnWidth
; /**< Width of "screen" */
129 int scrnHeight
; /**< Height of "screen" */
130 int scrnXSign
; /**< X offset sign of "screen" */
131 int scrnYSign
; /**< Y offset sign of "screen" */
133 /** Default drawables for "screen" */
134 Drawable scrnDefDrawables
[MAXFORMATS
];
136 struct _DMXScreenInfo
*next
; /**< List of "screens" on same display */
137 struct _DMXScreenInfo
*over
; /**< List of "screens" that overlap */
139 /*---------- Root window information ----------*/
141 Window rootWin
; /**< "Root" window on backend display */
142 int rootX
; /**< X offset of "root" window WRT "screen"*/
143 int rootY
; /**< Y offset of "root" window WRT "screen"*/
144 int rootWidth
; /**< Width of "root" window */
145 int rootHeight
; /**< Height of "root" window */
147 int rootXOrigin
; /**< Global X origin of "root" window */
148 int rootYOrigin
; /**< Global Y origin of "root" window */
150 /*---------- Shadow framebuffer information ----------*/
152 void *shadow
; /**< Shadow framebuffer data (if enabled) */
153 XlibGC shadowGC
; /**< Default GC used by shadow FB code */
154 XImage
*shadowFBImage
; /**< Screen image used by shadow FB code */
156 /*---------- Other related information ----------*/
158 int shared
; /**< Non-zero if another Xdmx is running */
164 /* Support for cursors on overlapped
165 * backend displays. */
168 int cursorNotShared
; /* for overlapping screens on a backend */
170 PositionType where
; /**< Relative layout information */
171 int whereX
; /**< Relative layout information */
172 int whereY
; /**< Relative layout information */
173 int whereRefScreen
; /**< Relative layout information */
175 int savedTimeout
; /**< Original screen saver timeout */
176 int dpmsCapable
; /**< Non-zero if backend is DPMS capable */
177 int dpmsEnabled
; /**< Non-zero if DPMS enabled */
178 int dpmsStandby
; /**< Original DPMS standby value */
179 int dpmsSuspend
; /**< Original DPMS suspend value */
180 int dpmsOff
; /**< Original DPMS off value */
182 DMXStatInfo
*stat
; /**< Statistics about XSync */
183 Bool needsSync
; /**< True if an XSync is pending */
186 /** Visual information for glxProxy */
188 __GLXvisualConfig
*glxVisuals
;
192 /** FB config information for glxProxy */
193 __GLXFBConfig
*fbconfigs
;
197 /** Function pointers to wrapped screen
199 CloseScreenProcPtr CloseScreen
;
200 SaveScreenProcPtr SaveScreen
;
202 CreateGCProcPtr CreateGC
;
204 CreateWindowProcPtr CreateWindow
;
205 DestroyWindowProcPtr DestroyWindow
;
206 PositionWindowProcPtr PositionWindow
;
207 ChangeWindowAttributesProcPtr ChangeWindowAttributes
;
208 RealizeWindowProcPtr RealizeWindow
;
209 UnrealizeWindowProcPtr UnrealizeWindow
;
210 RestackWindowProcPtr RestackWindow
;
211 WindowExposuresProcPtr WindowExposures
;
212 PaintWindowBackgroundProcPtr PaintWindowBackground
;
213 PaintWindowBorderProcPtr PaintWindowBorder
;
214 CopyWindowProcPtr CopyWindow
;
216 ResizeWindowProcPtr ResizeWindow
;
217 ReparentWindowProcPtr ReparentWindow
;
219 ChangeBorderWidthProcPtr ChangeBorderWidth
;
221 GetImageProcPtr GetImage
;
222 GetSpansProcPtr GetSpans
;
224 CreatePixmapProcPtr CreatePixmap
;
225 DestroyPixmapProcPtr DestroyPixmap
;
226 BitmapToRegionProcPtr BitmapToRegion
;
228 RealizeFontProcPtr RealizeFont
;
229 UnrealizeFontProcPtr UnrealizeFont
;
231 CreateColormapProcPtr CreateColormap
;
232 DestroyColormapProcPtr DestroyColormap
;
233 InstallColormapProcPtr InstallColormap
;
234 StoreColorsProcPtr StoreColors
;
237 SetShapeProcPtr SetShape
;
241 CreatePictureProcPtr CreatePicture
;
242 DestroyPictureProcPtr DestroyPicture
;
243 ChangePictureClipProcPtr ChangePictureClip
;
244 DestroyPictureClipProcPtr DestroyPictureClip
;
246 ChangePictureProcPtr ChangePicture
;
247 ValidatePictureProcPtr ValidatePicture
;
249 CompositeProcPtr Composite
;
250 GlyphsProcPtr Glyphs
;
251 CompositeRectsProcPtr CompositeRects
;
253 InitIndexedProcPtr InitIndexed
;
254 CloseIndexedProcPtr CloseIndexed
;
255 UpdateIndexedProcPtr UpdateIndexed
;
257 TrapezoidsProcPtr Trapezoids
;
258 TrianglesProcPtr Triangles
;
259 TriStripProcPtr TriStrip
;
260 TriFanProcPtr TriFan
;
264 /* Global variables available to all Xserver/hw/dmx routines. */
265 extern int dmxNumScreens
; /**< Number of dmxScreens */
266 extern DMXScreenInfo
*dmxScreens
; /**< List of outputs */
267 extern int dmxShadowFB
; /**< Non-zero if using
268 * shadow frame-buffer
270 extern XErrorEvent dmxLastErrorEvent
; /**< Last error that
272 extern Bool dmxErrorOccurred
; /**< True if an error
274 extern Bool dmxOffScreenOpt
; /**< True if using off
277 extern Bool dmxSubdividePrimitives
; /**< True if using the
278 * primitive subdivision
280 extern Bool dmxLazyWindowCreation
; /**< True if using the
281 * lazy window creation
283 extern Bool dmxUseXKB
; /**< True if the XKB
284 * extension should be
285 * used with the backend
287 extern int dmxDepth
; /**< Requested depth if
290 extern Bool dmxGLXProxy
; /**< True if glxProxy
291 * support is enabled */
292 extern Bool dmxGLXSwapGroupSupport
; /**< True if glxProxy
294 * groups and barriers
296 extern Bool dmxGLXSyncSwap
; /**< True if glxProxy
297 * should force an XSync
299 * swap buffers call */
300 extern Bool dmxGLXFinishSwap
; /**< True if glxProxy
306 extern char *dmxFontPath
; /**< NULL if no font
309 * otherwise, a string
311 * paths built from the
315 extern Bool dmxIgnoreBadFontPaths
; /**< True if bad font
317 * ignored during server
319 extern Bool dmxAddRemoveScreens
; /**< True if add and
320 * remove screens support
323 /** Wrap screen or GC function pointer */
324 #define DMX_WRAP(_entry, _newfunc, _saved, _actual) \
326 (_saved)->_entry = (_actual)->_entry; \
327 (_actual)->_entry = (_newfunc); \
330 /** Unwrap screen or GC function pointer */
331 #define DMX_UNWRAP(_entry, _saved, _actual) \
333 (_actual)->_entry = (_saved)->_entry; \
336 /* Define the MAXSCREENSALLOC/FREE macros, when MAXSCREENS patch has not
337 * been applied to sources. */
339 #define MAXSCREEN_MAKECONSTSTR1(x) #x
340 #define MAXSCREEN_MAKECONSTSTR2(x) MAXSCREEN_MAKECONSTSTR1(x)
342 #define MAXSCREEN_FAILED_TXT "Failed at [" \
343 MAXSCREEN_MAKECONSTSTR2(__LINE__) ":" __FILE__ "] to allocate object: "
345 #define _MAXSCREENSALLOCF(o,size,fatal) \
348 o = xalloc((size) * sizeof(*(o))); \
349 if (o) memset(o, 0, (size) * sizeof(*(o))); \
350 if (!o && fatal) FatalError(MAXSCREEN_FAILED_TXT #o); \
353 #define _MAXSCREENSALLOCR(o,size,retval) \
356 o = xalloc((size) * sizeof(*(o))); \
357 if (o) memset(o, 0, (size) * sizeof(*(o))); \
358 if (!o) return retval; \
362 #define MAXSCREENSFREE(o) \
368 #define MAXSCREENSALLOC(o) _MAXSCREENSALLOCF(o,MAXSCREENS, 0)
369 #define MAXSCREENSALLOC_FATAL(o) _MAXSCREENSALLOCF(o,MAXSCREENS, 1)
370 #define MAXSCREENSALLOC_RETURN(o,r) _MAXSCREENSALLOCR(o,MAXSCREENS, (r))
371 #define MAXSCREENSALLOCPLUSONE(o) _MAXSCREENSALLOCF(o,MAXSCREENS+1,0)
372 #define MAXSCREENSALLOCPLUSONE_FATAL(o) _MAXSCREENSALLOCF(o,MAXSCREENS+1,1)
373 #define MAXSCREENSCALLOC(o,m) _MAXSCREENSALLOCF(o,MAXSCREENS*(m),0)
374 #define MAXSCREENSCALLOC_FATAL(o,m) _MAXSCREENSALLOCF(o,MAXSCREENS*(m),1)