Imported Upstream version 1.15.1
[deb_xorg-server.git] / hw / dmx / dmx.h
CommitLineData
a09e091a
JB
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/*
29 * Authors:
30 * Kevin E. Martin <kem@redhat.com>
31 * David H. Dawes <dawes@xfree86.org>
32 * Rickard E. (Rik) Faith <faith@redhat.com>
33 *
34 */
35
36/** \file
37 * Main header file included by all other DMX-related files.
38 */
39
40/** \mainpage
41 * - <a href="http://dmx.sourceforge.net">DMX Home Page</a>
42 * - <a href="http://sourceforge.net/projects/dmx">DMX Project Page (on
43 * Source Forge)</a>
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>
48 */
49
50#ifndef DMX_H
51#define DMX_H
52
53#if HAVE_DMX_CONFIG_H
54#include <dmx-config.h>
55#endif
56
57#include "gcstruct.h"
58
59/* Handle client-side include files in one place. */
60#include "dmxclient.h"
61
62#include "globals.h"
63#include "scrnintstr.h"
64
65#include "picturestr.h"
66
67#ifdef GLXEXT
68#include <GL/glx.h>
69#include <GL/glxint.h>
70#endif
71
72typedef enum {
73 PosNone = -1,
74 PosAbsolute = 0,
75 PosRightOf,
76 PosLeftOf,
77 PosAbove,
78 PosBelow,
79 PosRelative
80} PositionType;
81
82/** Provide the typedef globally, but keep the contents opaque outside
83 * of the input routines. \see dmxinput.h */
84typedef struct _DMXInputInfo DMXInputInfo;
85
86/** Provide the typedef globally, but keep the contents opaque outside
87 * of the XSync statistic routines. \see dmxstat.c */
88typedef struct _DMXStatInfo DMXStatInfo;
89
90/** Global structure containing information about each backend screen. */
91typedef struct _DMXScreenInfo {
92 const char *name; /**< Name from command line or config file */
93 int index; /**< Index into dmxScreens global */
94
95 /*---------- Back-end X server information ----------*/
96
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 */
104
105 int beNumDepths; /**< Number of depths on BE server */
106 int *beDepths; /**< Depths from BE server */
107
108 int beNumPixmapFormats; /**< Number of pixmap formats on BE */
109 XPixmapFormatValues *bePixmapFormats; /**< Pixmap formats on BE */
110
111 int beNumVisuals; /**< Number of visuals on BE */
112 XVisualInfo *beVisuals; /**< Visuals from BE server */
113 int beDefVisualIndex; /**< Default visual index of BE */
114
115 int beNumDefColormaps; /**< Number of default colormaps */
116 Colormap *beDefColormaps; /**< Default colormaps for DMX server */
117
118 Pixel beBlackPixel; /**< Default black pixel for BE */
119 Pixel beWhitePixel; /**< Default white pixel for BE */
120
121 /*---------- Screen window information ----------*/
122
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" */
130
131 /** Default drawables for "screen" */
132 Drawable scrnDefDrawables[MAXFORMATS];
133
134 struct _DMXScreenInfo *next; /**< List of "screens" on same display */
135 struct _DMXScreenInfo *over; /**< List of "screens" that overlap */
136
137 /*---------- Root window information ----------*/
138
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 */
144
145 int rootXOrigin; /**< Global X origin of "root" window */
146 int rootYOrigin; /**< Global Y origin of "root" window */
147
148 /*---------- Shadow framebuffer information ----------*/
149
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 */
153
154 /*---------- Other related information ----------*/
155
156 int shared; /**< Non-zero if another Xdmx is running */
157
158 Bool WMRunningOnBE;
159
160 Cursor noCursor;
161 Cursor curCursor;
162 /* Support for cursors on overlapped
163 * backend displays. */
164 CursorPtr cursor;
165 int cursorVisible;
166 int cursorNotShared; /* for overlapping screens on a backend */
167
168 PositionType where; /**< Relative layout information */
169 int whereX; /**< Relative layout information */
170 int whereY; /**< Relative layout information */
171 int whereRefScreen; /**< Relative layout information */
172
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 */
179
180 DMXStatInfo *stat; /**< Statistics about XSync */
181 Bool needsSync; /**< True if an XSync is pending */
182
183#ifdef GLXEXT
184 /** Visual information for glxProxy */
185 int numGlxVisuals;
186 __GLXvisualConfig *glxVisuals;
187 int glxMajorOpcode;
188 int glxErrorBase;
189
190 /** FB config information for glxProxy */
191 __GLXFBConfig *fbconfigs;
192 int numFBConfigs;
193#endif
194
195 /** Function pointers to wrapped screen
196 * functions */
197 CloseScreenProcPtr CloseScreen;
198 SaveScreenProcPtr SaveScreen;
199
200 CreateGCProcPtr CreateGC;
201
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;
211
212 ResizeWindowProcPtr ResizeWindow;
213 ReparentWindowProcPtr ReparentWindow;
214
215 ChangeBorderWidthProcPtr ChangeBorderWidth;
216
217 GetImageProcPtr GetImage;
218 GetSpansProcPtr GetSpans;
219
220 CreatePixmapProcPtr CreatePixmap;
221 DestroyPixmapProcPtr DestroyPixmap;
222 BitmapToRegionProcPtr BitmapToRegion;
223
224 RealizeFontProcPtr RealizeFont;
225 UnrealizeFontProcPtr UnrealizeFont;
226
227 CreateColormapProcPtr CreateColormap;
228 DestroyColormapProcPtr DestroyColormap;
229 InstallColormapProcPtr InstallColormap;
230 StoreColorsProcPtr StoreColors;
231
232 SetShapeProcPtr SetShape;
233
234 CreatePictureProcPtr CreatePicture;
235 DestroyPictureProcPtr DestroyPicture;
236 ChangePictureClipProcPtr ChangePictureClip;
237 DestroyPictureClipProcPtr DestroyPictureClip;
238
239 ChangePictureProcPtr ChangePicture;
240 ValidatePictureProcPtr ValidatePicture;
241
242 CompositeProcPtr Composite;
243 GlyphsProcPtr Glyphs;
244 CompositeRectsProcPtr CompositeRects;
245
246 InitIndexedProcPtr InitIndexed;
247 CloseIndexedProcPtr CloseIndexed;
248 UpdateIndexedProcPtr UpdateIndexed;
249
250 TrapezoidsProcPtr Trapezoids;
251 TrianglesProcPtr Triangles;
252} DMXScreenInfo;
253
254/* Global variables available to all Xserver/hw/dmx routines. */
255extern int dmxNumScreens; /**< Number of dmxScreens */
256extern DMXScreenInfo *dmxScreens; /**< List of outputs */
257extern XErrorEvent dmxLastErrorEvent; /**< Last error that
258
259 * occurred */
260extern Bool dmxErrorOccurred; /**< True if an error
261
262 * occurred */
263extern Bool dmxOffScreenOpt; /**< True if using off
264
265 * screen
266 * optimizations */
267extern Bool dmxSubdividePrimitives; /**< True if using the
268
269 * primitive subdivision
270 * optimization */
271extern Bool dmxLazyWindowCreation; /**< True if using the
272
273 * lazy window creation
274 * optimization */
275extern Bool dmxUseXKB; /**< True if the XKB
276
277 * extension should be
278 * used with the backend
279 * servers */
280extern int dmxDepth; /**< Requested depth if
281
282 * non-zero */
283#ifdef GLXEXT
284extern Bool dmxGLXProxy; /**< True if glxProxy
285
286 * support is enabled */
287extern Bool dmxGLXSwapGroupSupport; /**< True if glxProxy
288
289 * support for swap
290 * groups and barriers
291 * is enabled */
292extern Bool dmxGLXSyncSwap; /**< True if glxProxy
293
294 * should force an XSync
295 * request after each
296 * swap buffers call */
297extern Bool dmxGLXFinishSwap; /**< True if glxProxy
298
299 * should force a
300 * glFinish request
301 * after each swap
302 * buffers call */
303#endif
304extern char *dmxFontPath; /**< NULL if no font
305
306 * path is set on the
307 * command line;
308 * otherwise, a string
309 * of comma separated
310 * paths built from the
311 * command line
312 * specified font
313 * paths */
314extern Bool dmxIgnoreBadFontPaths; /**< True if bad font
315
316 * paths should be
317 * ignored during server
318 * init */
319extern Bool dmxAddRemoveScreens; /**< True if add and
320
321 * remove screens support
322 * is enabled */
323
324/** Wrap screen or GC function pointer */
325#define DMX_WRAP(_entry, _newfunc, _saved, _actual) \
326do { \
327 (_saved)->_entry = (_actual)->_entry; \
328 (_actual)->_entry = (_newfunc); \
329} while (0)
330
331/** Unwrap screen or GC function pointer */
332#define DMX_UNWRAP(_entry, _saved, _actual) \
333do { \
334 (_actual)->_entry = (_saved)->_entry; \
335} while (0)
336
337/* Define the MAXSCREENSALLOC/FREE macros, when MAXSCREENS patch has not
338 * been applied to sources. */
339#ifdef MAXSCREENS
340#define MAXSCREEN_MAKECONSTSTR1(x) #x
341#define MAXSCREEN_MAKECONSTSTR2(x) MAXSCREEN_MAKECONSTSTR1(x)
342
343#define MAXSCREEN_FAILED_TXT "Failed at [" \
344 MAXSCREEN_MAKECONSTSTR2(__LINE__) ":" __FILE__ "] to allocate object: "
345
346#define _MAXSCREENSALLOCF(o,size,fatal) \
347 do { \
348 if (!o) { \
349 o = calloc((size), sizeof(*(o))); \
350 if (!o && fatal) FatalError(MAXSCREEN_FAILED_TXT #o); \
351 } \
352 } while (0)
353#define _MAXSCREENSALLOCR(o,size,retval) \
354 do { \
355 if (!o) { \
356 o = calloc((size), sizeof(*(o))); \
357 if (!o) return retval; \
358 } \
359 } while (0)
360
361#define MAXSCREENSFREE(o) \
362 do { \
363 free(o); \
364 o = NULL; \
365 } while (0)
366
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)
374#endif
375
376extern DevPrivateKeyRec dmxGCPrivateKeyRec;
377
378#define dmxGCPrivateKey (&dmxGCPrivateKeyRec) /**< Private index for GCs */
379
380extern DevPrivateKeyRec dmxWinPrivateKeyRec;
381
382#define dmxWinPrivateKey (&dmxWinPrivateKeyRec) /**< Private index for Windows */
383
384extern DevPrivateKeyRec dmxPixPrivateKeyRec;
385
386#define dmxPixPrivateKey (&dmxPixPrivateKeyRec) /**< Private index for Pixmaps */
387
388extern int dmxFontPrivateIndex; /**< Private index for Fonts */
389
390extern DevPrivateKeyRec dmxScreenPrivateKeyRec;
391
392#define dmxScreenPrivateKey (&dmxScreenPrivateKeyRec) /**< Private index for Screens */
393
394extern DevPrivateKeyRec dmxColormapPrivateKeyRec;
395
396#define dmxColormapPrivateKey (&dmxColormapPrivateKeyRec) /**< Private index for Colormaps */
397
398extern DevPrivateKeyRec dmxPictPrivateKeyRec;
399
400#define dmxPictPrivateKey (&dmxPictPrivateKeyRec) /**< Private index for Picts */
401
402extern DevPrivateKeyRec dmxGlyphSetPrivateKeyRec;
403
404#define dmxGlyphSetPrivateKey (&dmxGlyphSetPrivateKeyRec) /**< Private index for GlyphSets */
405
406void DMXExtensionInit(void);
407
408#endif /* DMX_H */