1706f2543Smrg/* 2706f2543Smrg * Copyright 2001-2003 Red Hat Inc., Durham, North Carolina. 3706f2543Smrg * 4706f2543Smrg * All Rights Reserved. 5706f2543Smrg * 6706f2543Smrg * Permission is hereby granted, free of charge, to any person obtaining 7706f2543Smrg * a copy of this software and associated documentation files (the 8706f2543Smrg * "Software"), to deal in the Software without restriction, including 9706f2543Smrg * without limitation on the rights to use, copy, modify, merge, 10706f2543Smrg * publish, distribute, sublicense, and/or sell copies of the Software, 11706f2543Smrg * and to permit persons to whom the Software is furnished to do so, 12706f2543Smrg * subject to the following conditions: 13706f2543Smrg * 14706f2543Smrg * The above copyright notice and this permission notice (including the 15706f2543Smrg * next paragraph) shall be included in all copies or substantial 16706f2543Smrg * portions of the Software. 17706f2543Smrg * 18706f2543Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19706f2543Smrg * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20706f2543Smrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21706f2543Smrg * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS 22706f2543Smrg * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 23706f2543Smrg * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 24706f2543Smrg * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25706f2543Smrg * SOFTWARE. 26706f2543Smrg */ 27706f2543Smrg 28706f2543Smrg/* 29706f2543Smrg * Authors: 30706f2543Smrg * Kevin E. Martin <kem@redhat.com> 31706f2543Smrg * David H. Dawes <dawes@xfree86.org> 32706f2543Smrg * Rickard E. (Rik) Faith <faith@redhat.com> 33706f2543Smrg * 34706f2543Smrg */ 35706f2543Smrg 36706f2543Smrg/** \file 37706f2543Smrg * Main header file included by all other DMX-related files. 38706f2543Smrg */ 39706f2543Smrg 40706f2543Smrg/** \mainpage 41706f2543Smrg * - <a href="http://dmx.sourceforge.net">DMX Home Page</a> 42706f2543Smrg * - <a href="http://sourceforge.net/projects/dmx">DMX Project Page (on 43706f2543Smrg * Source Forge)</a> 44706f2543Smrg * - <a href="http://dmx.sourceforge.net/dmx.html">Distributed Multihead 45706f2543Smrg * X design</a>, the design document for DMX 46706f2543Smrg * - <a href="http://dmx.sourceforge.net/DMXSpec.txt">Client-to-Server 47706f2543Smrg * DMX Extension to the X Protocol</a> 48706f2543Smrg */ 49706f2543Smrg 50706f2543Smrg#ifndef DMX_H 51706f2543Smrg#define DMX_H 52706f2543Smrg 53706f2543Smrg#if HAVE_DMX_CONFIG_H 54706f2543Smrg#include <dmx-config.h> 55706f2543Smrg#endif 56706f2543Smrg 57706f2543Smrg#include "gcstruct.h" 58706f2543Smrg 59706f2543Smrg/* Handle client-side include files in one place. */ 60706f2543Smrg#include "dmxclient.h" 61706f2543Smrg 62706f2543Smrg#include "globals.h" 63706f2543Smrg#include "scrnintstr.h" 64706f2543Smrg 65706f2543Smrg#include "picturestr.h" 66706f2543Smrg 67706f2543Smrg#ifdef GLXEXT 68706f2543Smrg#include <GL/glx.h> 69706f2543Smrg#include <GL/glxint.h> 70706f2543Smrg#endif 71706f2543Smrg 72706f2543Smrgtypedef enum { 73706f2543Smrg PosNone = -1, 74706f2543Smrg PosAbsolute = 0, 75706f2543Smrg PosRightOf, 76706f2543Smrg PosLeftOf, 77706f2543Smrg PosAbove, 78706f2543Smrg PosBelow, 79706f2543Smrg PosRelative 80706f2543Smrg} PositionType; 81706f2543Smrg 82706f2543Smrg/** Provide the typedef globally, but keep the contents opaque outside 83706f2543Smrg * of the input routines. \see dmxinput.h */ 84706f2543Smrgtypedef struct _DMXInputInfo DMXInputInfo; 85706f2543Smrg 86706f2543Smrg/** Provide the typedef globally, but keep the contents opaque outside 87706f2543Smrg * of the XSync statistic routines. \see dmxstat.c */ 88706f2543Smrgtypedef struct _DMXStatInfo DMXStatInfo; 89706f2543Smrg 90706f2543Smrg/** Global structure containing information about each backend screen. */ 91706f2543Smrgtypedef struct _DMXScreenInfo { 92706f2543Smrg const char *name; /**< Name from command line or config file */ 93706f2543Smrg int index; /**< Index into dmxScreens global */ 94706f2543Smrg 95706f2543Smrg /*---------- Back-end X server information ----------*/ 96706f2543Smrg 97706f2543Smrg Display *beDisplay; /**< Back-end X server's display */ 98706f2543Smrg int beWidth; /**< Width of BE display */ 99706f2543Smrg int beHeight; /**< Height of BE display */ 100706f2543Smrg int beDepth; /**< Depth of BE display */ 101706f2543Smrg int beBPP; /**< Bits per pixel of BE display */ 102706f2543Smrg int beXDPI; /**< Horizontal dots per inch of BE */ 103706f2543Smrg int beYDPI; /**< Vertical dots per inch of BE */ 104706f2543Smrg 105706f2543Smrg int beNumDepths; /**< Number of depths on BE server */ 106706f2543Smrg int *beDepths; /**< Depths from BE server */ 107706f2543Smrg 108706f2543Smrg int beNumPixmapFormats; /**< Number of pixmap formats on BE */ 109706f2543Smrg XPixmapFormatValues *bePixmapFormats; /**< Pixmap formats on BE */ 110706f2543Smrg 111706f2543Smrg int beNumVisuals; /**< Number of visuals on BE */ 112706f2543Smrg XVisualInfo *beVisuals; /**< Visuals from BE server */ 113706f2543Smrg int beDefVisualIndex; /**< Default visual index of BE */ 114706f2543Smrg 115706f2543Smrg int beNumDefColormaps; /**< Number of default colormaps */ 116706f2543Smrg Colormap *beDefColormaps; /**< Default colormaps for DMX server */ 117706f2543Smrg 118706f2543Smrg Pixel beBlackPixel; /**< Default black pixel for BE */ 119706f2543Smrg Pixel beWhitePixel; /**< Default white pixel for BE */ 120706f2543Smrg 121706f2543Smrg /*---------- Screen window information ----------*/ 122706f2543Smrg 123706f2543Smrg Window scrnWin; /**< "Screen" window on backend display */ 124706f2543Smrg int scrnX; /**< X offset of "screen" WRT BE display */ 125706f2543Smrg int scrnY; /**< Y offset of "screen" WRT BE display */ 126706f2543Smrg int scrnWidth; /**< Width of "screen" */ 127706f2543Smrg int scrnHeight; /**< Height of "screen" */ 128706f2543Smrg int scrnXSign; /**< X offset sign of "screen" */ 129706f2543Smrg int scrnYSign; /**< Y offset sign of "screen" */ 130706f2543Smrg 131706f2543Smrg /** Default drawables for "screen" */ 132706f2543Smrg Drawable scrnDefDrawables[MAXFORMATS]; 133706f2543Smrg 134706f2543Smrg struct _DMXScreenInfo *next; /**< List of "screens" on same display */ 135706f2543Smrg struct _DMXScreenInfo *over; /**< List of "screens" that overlap */ 136706f2543Smrg 137706f2543Smrg /*---------- Root window information ----------*/ 138706f2543Smrg 139706f2543Smrg Window rootWin; /**< "Root" window on backend display */ 140706f2543Smrg int rootX; /**< X offset of "root" window WRT "screen"*/ 141706f2543Smrg int rootY; /**< Y offset of "root" window WRT "screen"*/ 142706f2543Smrg int rootWidth; /**< Width of "root" window */ 143706f2543Smrg int rootHeight; /**< Height of "root" window */ 144706f2543Smrg 145706f2543Smrg int rootXOrigin; /**< Global X origin of "root" window */ 146706f2543Smrg int rootYOrigin; /**< Global Y origin of "root" window */ 147706f2543Smrg 148706f2543Smrg /*---------- Shadow framebuffer information ----------*/ 149706f2543Smrg 150706f2543Smrg void *shadow; /**< Shadow framebuffer data (if enabled) */ 151706f2543Smrg XlibGC shadowGC; /**< Default GC used by shadow FB code */ 152706f2543Smrg XImage *shadowFBImage; /**< Screen image used by shadow FB code */ 153706f2543Smrg 154706f2543Smrg /*---------- Other related information ----------*/ 155706f2543Smrg 156706f2543Smrg int shared; /**< Non-zero if another Xdmx is running */ 157706f2543Smrg 158706f2543Smrg Bool WMRunningOnBE; 159706f2543Smrg 160706f2543Smrg Cursor noCursor; 161706f2543Smrg Cursor curCursor; 162706f2543Smrg /* Support for cursors on overlapped 163706f2543Smrg * backend displays. */ 164706f2543Smrg CursorPtr cursor; 165706f2543Smrg int cursorVisible; 166706f2543Smrg int cursorNotShared; /* for overlapping screens on a backend */ 167706f2543Smrg 168706f2543Smrg PositionType where; /**< Relative layout information */ 169706f2543Smrg int whereX; /**< Relative layout information */ 170706f2543Smrg int whereY; /**< Relative layout information */ 171706f2543Smrg int whereRefScreen; /**< Relative layout information */ 172706f2543Smrg 173706f2543Smrg int savedTimeout; /**< Original screen saver timeout */ 174706f2543Smrg int dpmsCapable; /**< Non-zero if backend is DPMS capable */ 175706f2543Smrg int dpmsEnabled; /**< Non-zero if DPMS enabled */ 176706f2543Smrg int dpmsStandby; /**< Original DPMS standby value */ 177706f2543Smrg int dpmsSuspend; /**< Original DPMS suspend value */ 178706f2543Smrg int dpmsOff; /**< Original DPMS off value */ 179706f2543Smrg 180706f2543Smrg DMXStatInfo *stat; /**< Statistics about XSync */ 181706f2543Smrg Bool needsSync; /**< True if an XSync is pending */ 182706f2543Smrg 183706f2543Smrg#ifdef GLXEXT 184706f2543Smrg /** Visual information for glxProxy */ 185706f2543Smrg int numGlxVisuals; 186706f2543Smrg __GLXvisualConfig *glxVisuals; 187706f2543Smrg int glxMajorOpcode; 188706f2543Smrg int glxErrorBase; 189706f2543Smrg 190706f2543Smrg /** FB config information for glxProxy */ 191706f2543Smrg __GLXFBConfig *fbconfigs; 192706f2543Smrg int numFBConfigs; 193706f2543Smrg#endif 194706f2543Smrg 195706f2543Smrg /** Function pointers to wrapped screen 196706f2543Smrg * functions */ 197706f2543Smrg CloseScreenProcPtr CloseScreen; 198706f2543Smrg SaveScreenProcPtr SaveScreen; 199706f2543Smrg 200706f2543Smrg CreateGCProcPtr CreateGC; 201706f2543Smrg 202706f2543Smrg CreateWindowProcPtr CreateWindow; 203706f2543Smrg DestroyWindowProcPtr DestroyWindow; 204706f2543Smrg PositionWindowProcPtr PositionWindow; 205706f2543Smrg ChangeWindowAttributesProcPtr ChangeWindowAttributes; 206706f2543Smrg RealizeWindowProcPtr RealizeWindow; 207706f2543Smrg UnrealizeWindowProcPtr UnrealizeWindow; 208706f2543Smrg RestackWindowProcPtr RestackWindow; 209706f2543Smrg WindowExposuresProcPtr WindowExposures; 210706f2543Smrg CopyWindowProcPtr CopyWindow; 211706f2543Smrg 212706f2543Smrg ResizeWindowProcPtr ResizeWindow; 213706f2543Smrg ReparentWindowProcPtr ReparentWindow; 214706f2543Smrg 215706f2543Smrg ChangeBorderWidthProcPtr ChangeBorderWidth; 216706f2543Smrg 217706f2543Smrg GetImageProcPtr GetImage; 218706f2543Smrg GetSpansProcPtr GetSpans; 219706f2543Smrg 220706f2543Smrg CreatePixmapProcPtr CreatePixmap; 221706f2543Smrg DestroyPixmapProcPtr DestroyPixmap; 222706f2543Smrg BitmapToRegionProcPtr BitmapToRegion; 223706f2543Smrg 224706f2543Smrg RealizeFontProcPtr RealizeFont; 225706f2543Smrg UnrealizeFontProcPtr UnrealizeFont; 226706f2543Smrg 227706f2543Smrg CreateColormapProcPtr CreateColormap; 228706f2543Smrg DestroyColormapProcPtr DestroyColormap; 229706f2543Smrg InstallColormapProcPtr InstallColormap; 230706f2543Smrg StoreColorsProcPtr StoreColors; 231706f2543Smrg 232706f2543Smrg SetShapeProcPtr SetShape; 233706f2543Smrg 234706f2543Smrg CreatePictureProcPtr CreatePicture; 235706f2543Smrg DestroyPictureProcPtr DestroyPicture; 236706f2543Smrg ChangePictureClipProcPtr ChangePictureClip; 237706f2543Smrg DestroyPictureClipProcPtr DestroyPictureClip; 238706f2543Smrg 239706f2543Smrg ChangePictureProcPtr ChangePicture; 240706f2543Smrg ValidatePictureProcPtr ValidatePicture; 241706f2543Smrg 242706f2543Smrg CompositeProcPtr Composite; 243706f2543Smrg GlyphsProcPtr Glyphs; 244706f2543Smrg CompositeRectsProcPtr CompositeRects; 245706f2543Smrg 246706f2543Smrg InitIndexedProcPtr InitIndexed; 247706f2543Smrg CloseIndexedProcPtr CloseIndexed; 248706f2543Smrg UpdateIndexedProcPtr UpdateIndexed; 249706f2543Smrg 250706f2543Smrg TrapezoidsProcPtr Trapezoids; 251706f2543Smrg TrianglesProcPtr Triangles; 252706f2543Smrg TriStripProcPtr TriStrip; 253706f2543Smrg TriFanProcPtr TriFan; 254706f2543Smrg} DMXScreenInfo; 255706f2543Smrg 256706f2543Smrg/* Global variables available to all Xserver/hw/dmx routines. */ 257706f2543Smrgextern int dmxNumScreens; /**< Number of dmxScreens */ 258706f2543Smrgextern DMXScreenInfo *dmxScreens; /**< List of outputs */ 259706f2543Smrgextern int dmxShadowFB; /**< Non-zero if using 260706f2543Smrg * shadow frame-buffer 261706f2543Smrg * (deprecated) */ 262706f2543Smrgextern XErrorEvent dmxLastErrorEvent; /**< Last error that 263706f2543Smrg * occurred */ 264706f2543Smrgextern Bool dmxErrorOccurred; /**< True if an error 265706f2543Smrg * occurred */ 266706f2543Smrgextern Bool dmxOffScreenOpt; /**< True if using off 267706f2543Smrg * screen 268706f2543Smrg * optimizations */ 269706f2543Smrgextern Bool dmxSubdividePrimitives; /**< True if using the 270706f2543Smrg * primitive subdivision 271706f2543Smrg * optimization */ 272706f2543Smrgextern Bool dmxLazyWindowCreation; /**< True if using the 273706f2543Smrg * lazy window creation 274706f2543Smrg * optimization */ 275706f2543Smrgextern Bool dmxUseXKB; /**< True if the XKB 276706f2543Smrg * extension should be 277706f2543Smrg * used with the backend 278706f2543Smrg * servers */ 279706f2543Smrgextern int dmxDepth; /**< Requested depth if 280706f2543Smrg * non-zero */ 281706f2543Smrg#ifdef GLXEXT 282706f2543Smrgextern Bool dmxGLXProxy; /**< True if glxProxy 283706f2543Smrg * support is enabled */ 284706f2543Smrgextern Bool dmxGLXSwapGroupSupport; /**< True if glxProxy 285706f2543Smrg * support for swap 286706f2543Smrg * groups and barriers 287706f2543Smrg * is enabled */ 288706f2543Smrgextern Bool dmxGLXSyncSwap; /**< True if glxProxy 289706f2543Smrg * should force an XSync 290706f2543Smrg * request after each 291706f2543Smrg * swap buffers call */ 292706f2543Smrgextern Bool dmxGLXFinishSwap; /**< True if glxProxy 293706f2543Smrg * should force a 294706f2543Smrg * glFinish request 295706f2543Smrg * after each swap 296706f2543Smrg * buffers call */ 297706f2543Smrg#endif 298706f2543Smrgextern char *dmxFontPath; /**< NULL if no font 299706f2543Smrg * path is set on the 300706f2543Smrg * command line; 301706f2543Smrg * otherwise, a string 302706f2543Smrg * of comma separated 303706f2543Smrg * paths built from the 304706f2543Smrg * command line 305706f2543Smrg * specified font 306706f2543Smrg * paths */ 307706f2543Smrgextern Bool dmxIgnoreBadFontPaths; /**< True if bad font 308706f2543Smrg * paths should be 309706f2543Smrg * ignored during server 310706f2543Smrg * init */ 311706f2543Smrgextern Bool dmxAddRemoveScreens; /**< True if add and 312706f2543Smrg * remove screens support 313706f2543Smrg * is enabled */ 314706f2543Smrg 315706f2543Smrg/** Wrap screen or GC function pointer */ 316706f2543Smrg#define DMX_WRAP(_entry, _newfunc, _saved, _actual) \ 317706f2543Smrgdo { \ 318706f2543Smrg (_saved)->_entry = (_actual)->_entry; \ 319706f2543Smrg (_actual)->_entry = (_newfunc); \ 320706f2543Smrg} while (0) 321706f2543Smrg 322706f2543Smrg/** Unwrap screen or GC function pointer */ 323706f2543Smrg#define DMX_UNWRAP(_entry, _saved, _actual) \ 324706f2543Smrgdo { \ 325706f2543Smrg (_actual)->_entry = (_saved)->_entry; \ 326706f2543Smrg} while (0) 327706f2543Smrg 328706f2543Smrg/* Define the MAXSCREENSALLOC/FREE macros, when MAXSCREENS patch has not 329706f2543Smrg * been applied to sources. */ 330706f2543Smrg#ifdef MAXSCREENS 331706f2543Smrg#define MAXSCREEN_MAKECONSTSTR1(x) #x 332706f2543Smrg#define MAXSCREEN_MAKECONSTSTR2(x) MAXSCREEN_MAKECONSTSTR1(x) 333706f2543Smrg 334706f2543Smrg#define MAXSCREEN_FAILED_TXT "Failed at [" \ 335706f2543Smrg MAXSCREEN_MAKECONSTSTR2(__LINE__) ":" __FILE__ "] to allocate object: " 336706f2543Smrg 337706f2543Smrg#define _MAXSCREENSALLOCF(o,size,fatal) \ 338706f2543Smrg do { \ 339706f2543Smrg if (!o) { \ 340706f2543Smrg o = calloc((size), sizeof(*(o))); \ 341706f2543Smrg if (!o && fatal) FatalError(MAXSCREEN_FAILED_TXT #o); \ 342706f2543Smrg } \ 343706f2543Smrg } while (0) 344706f2543Smrg#define _MAXSCREENSALLOCR(o,size,retval) \ 345706f2543Smrg do { \ 346706f2543Smrg if (!o) { \ 347706f2543Smrg o = calloc((size), sizeof(*(o))); \ 348706f2543Smrg if (!o) return retval; \ 349706f2543Smrg } \ 350706f2543Smrg } while (0) 351706f2543Smrg 352706f2543Smrg#define MAXSCREENSFREE(o) \ 353706f2543Smrg do { \ 354706f2543Smrg free(o); \ 355706f2543Smrg o = NULL; \ 356706f2543Smrg } while (0) 357706f2543Smrg 358706f2543Smrg#define MAXSCREENSALLOC(o) _MAXSCREENSALLOCF(o,MAXSCREENS, 0) 359706f2543Smrg#define MAXSCREENSALLOC_FATAL(o) _MAXSCREENSALLOCF(o,MAXSCREENS, 1) 360706f2543Smrg#define MAXSCREENSALLOC_RETURN(o,r) _MAXSCREENSALLOCR(o,MAXSCREENS, (r)) 361706f2543Smrg#define MAXSCREENSALLOCPLUSONE(o) _MAXSCREENSALLOCF(o,MAXSCREENS+1,0) 362706f2543Smrg#define MAXSCREENSALLOCPLUSONE_FATAL(o) _MAXSCREENSALLOCF(o,MAXSCREENS+1,1) 363706f2543Smrg#define MAXSCREENSCALLOC(o,m) _MAXSCREENSALLOCF(o,MAXSCREENS*(m),0) 364706f2543Smrg#define MAXSCREENSCALLOC_FATAL(o,m) _MAXSCREENSALLOCF(o,MAXSCREENS*(m),1) 365706f2543Smrg#endif 366706f2543Smrg 367706f2543Smrgextern DevPrivateKeyRec dmxGCPrivateKeyRec; 368706f2543Smrg#define dmxGCPrivateKey (&dmxGCPrivateKeyRec) /**< Private index for GCs */ 369706f2543Smrg 370706f2543Smrgextern DevPrivateKeyRec dmxWinPrivateKeyRec; 371706f2543Smrg#define dmxWinPrivateKey (&dmxWinPrivateKeyRec) /**< Private index for Windows */ 372706f2543Smrg 373706f2543Smrgextern DevPrivateKeyRec dmxPixPrivateKeyRec; 374706f2543Smrg#define dmxPixPrivateKey (&dmxPixPrivateKeyRec) /**< Private index for Pixmaps */ 375706f2543Smrg 376706f2543Smrgextern int dmxFontPrivateIndex; /**< Private index for Fonts */ 377706f2543Smrg 378706f2543Smrgextern DevPrivateKeyRec dmxScreenPrivateKeyRec; 379706f2543Smrg#define dmxScreenPrivateKey (&dmxScreenPrivateKeyRec) /**< Private index for Screens */ 380706f2543Smrg 381706f2543Smrgextern DevPrivateKeyRec dmxColormapPrivateKeyRec; 382706f2543Smrg#define dmxColormapPrivateKey (&dmxColormapPrivateKeyRec) /**< Private index for Colormaps */ 383706f2543Smrg 384706f2543Smrgextern DevPrivateKeyRec dmxPictPrivateKeyRec; 385706f2543Smrg#define dmxPictPrivateKey (&dmxPictPrivateKeyRec) /**< Private index for Picts */ 386706f2543Smrg 387706f2543Smrgextern DevPrivateKeyRec dmxGlyphSetPrivateKeyRec; 388706f2543Smrg#define dmxGlyphSetPrivateKey (&dmxGlyphSetPrivateKeyRec) /**< Private index for GlyphSets */ 389706f2543Smrg 390706f2543Smrg#endif /* DMX_H */ 391