xserver/hw/dmx/dmx.h
David Reveman a1dd3fe551 Add selection support.
Selections are automatically shared with back-end servers. This provides
seamless communication between back-end server clients and local clients.

Some selections are not appropriate to share as they will cause
unwanted conflicts. E.g. most manager selections.  These selections
can still be shared by adding a unique identifier to them. Selections
that need this identifier can be specified using a command line option.
2008-10-30 03:37:47 -04:00

449 lines
16 KiB
C

/*
* Copyright 2001-2003 Red Hat Inc., Durham, North Carolina.
*
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation on the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/*
* Authors:
* Kevin E. Martin <kem@redhat.com>
* David H. Dawes <dawes@xfree86.org>
* Rickard E. (Rik) Faith <faith@redhat.com>
*
*/
/** \file
* Main header file included by all other DMX-related files.
*/
/** \mainpage
* - <a href="http://dmx.sourceforge.net">DMX Home Page</a>
* - <a href="http://sourceforge.net/projects/dmx">DMX Project Page (on
* Source Forge)</a>
* - <a href="http://dmx.sourceforge.net/dmx.html">Distributed Multihead
* X design</a>, the design document for DMX
* - <a href="http://dmx.sourceforge.net/DMXSpec.txt">Client-to-Server
* DMX Extension to the X Protocol</a>
*/
#ifndef DMX_H
#define DMX_H
#if HAVE_DMX_CONFIG_H
#include <dmx-config.h>
#endif
#include "gcstruct.h"
/* Handle client-side include files in one place. */
#include "dmxclient.h"
#include "globals.h"
#include "scrnintstr.h"
#ifdef RENDER
#include "picturestr.h"
#endif
#ifdef GLXEXT
#include <GL/glx.h>
#include <GL/glxint.h>
#endif
#include <xcb/xcb.h>
#include <xcb/xcbext.h>
#include <X11/Xlib-xcb.h>
#include "dmxxlibio.h"
typedef enum {
PosNone = -1,
PosAbsolute = 0,
PosRightOf,
PosLeftOf,
PosAbove,
PosBelow,
PosRelative
} PositionType;
typedef struct _DMXSequence {
struct _DMXSequence *next;
unsigned long sequence;
} DMXSequence;
typedef struct _DMXQueue {
DMXSequence *head;
DMXSequence **tail;
} DMXQueue;
typedef struct _DMXPropTrans {
const char *name;
const char *format;
Atom type;
} DMXPropTrans;
typedef struct _DMXSelectionMap {
const char *name;
Atom atom;
Atom beAtom;
} DMXSelectionMap;
#define DMX_DETACHED 0xff
/** Number of backend selection conversion requests that can be
processed simultaneously . */
#define DMX_N_SELECTION_PROXY 10
/** Provide the typedef globally, but keep the contents opaque outside
* of the XSync statistic routines. \see dmxstat.c */
typedef struct _DMXStatInfo DMXStatInfo;
typedef struct _DMXInputInfo {
DeviceIntPtr *devs;
int numDevs;
int eventBase;
} DMXInputInfo;
/** Global structure containing information about each backend screen. */
typedef struct _DMXScreenInfo {
DMXInputInfo input;
char *name; /**< Name that uniquely identifies screen */
char *display; /**< Name from command line or config file */
int index; /**< Index into dmxScreens global */
/*---------- Back-end X server information ----------*/
int fd;
int inDispatch;
xcb_connection_t *connection;
xcb_get_input_focus_cookie_t sync;
Atom *atomTable;
int atomTableSize;
Atom *beAtomTable;
int beAtomTableSize;
Display *beDisplay; /**< Back-end X server's display */
int beWidth; /**< Width of BE display */
int beHeight; /**< Height of BE display */
int beDepth; /**< Depth of BE display */
int beBPP; /**< Bits per pixel of BE display */
int beXDPI; /**< Horizontal dots per inch of BE */
int beYDPI; /**< Vertical dots per inch of BE */
int beNumDepths; /**< Number of depths on BE server */
int *beDepths; /**< Depths from BE server */
int alive;
int broken;
int beNumPixmapFormats; /**< Number of pixmap formats on BE */
XPixmapFormatValues *bePixmapFormats; /**< Pixmap formats on BE */
int beNumVisuals; /**< Number of visuals on BE */
XVisualInfo *beVisuals; /**< Visuals from BE server */
int beDefVisualIndex; /**< Default visual index of BE */
int beNumDefColormaps; /**< Number of default colormaps */
Colormap *beDefColormaps; /**< Default colormaps for DMX server */
Pixel beBlackPixel; /**< Default black pixel for BE */
Pixel beWhitePixel; /**< Default white pixel for BE */
#ifdef RANDR
Bool beRandr; /**< Use RANDR support on BE server */
Bool beRandrPending;
int beRandrEventBase;
#endif
#ifdef MITSHM
Bool beShm; /**< Use MIT-SHM support on BE server */
int beShmEventBase;
#endif
Display *beAttachedDisplay; /**< Disabld X server's display */
char *authType;
int authTypeLen;
char *authData;
int authDataLen;
int virtualFb;
/*---------- Screen window information ----------*/
Window scrnWin; /**< "Screen" window on backend display */
int scrnWidth; /**< Width of "screen" */
int scrnHeight; /**< Height of "screen" */
/** Default drawables for "screen" */
Drawable scrnDefDrawables[MAXFORMATS];
struct _DMXScreenInfo *next; /**< List of "screens" on same display */
struct _DMXScreenInfo *over; /**< List of "screens" that overlap */
/*---------- Root window information ----------*/
Window rootWin; /**< "Root" window on backend display */
int rootX; /**< X offset of "root" window WRT "screen"*/
int rootY; /**< Y offset of "root" window WRT "screen"*/
int rootEventMask;
/*---------- Selection information ----------*/
Atom selectionAtom;
Window selectionOwner;
xcb_get_selection_owner_cookie_t getSelectionOwner;
Window getSelectionOwnerResult;
XID selectionProxyWid[DMX_N_SELECTION_PROXY];
WindowPtr pSelectionProxyWin[DMX_N_SELECTION_PROXY];
Atom incrAtom;
/*---------- Other related information ----------*/
int dpmsCapable; /**< Non-zero if backend is DPMS capable */
int dpmsEnabled; /**< Non-zero if DPMS enabled */
int dpmsStandby; /**< Original DPMS standby value */
int dpmsSuspend; /**< Original DPMS suspend value */
int dpmsOff; /**< Original DPMS off value */
DMXStatInfo *stat; /**< Statistics about XSync */
Bool needsSync; /**< True if an XSync is pending */
DMXQueue ignore;
DMXQueue request;
#ifdef GLXEXT
/** Visual information for glxProxy */
int numGlxVisuals;
__GLXvisualConfig *glxVisuals;
int glxMajorOpcode;
int glxErrorBase;
/** FB config information for glxProxy */
__GLXFBConfig *fbconfigs;
int numFBConfigs;
#endif
/** Function pointers to wrapped screen
* functions */
CloseScreenProcPtr CloseScreen;
SaveScreenProcPtr SaveScreen;
CreateGCProcPtr CreateGC;
CreateWindowProcPtr CreateWindow;
DestroyWindowProcPtr DestroyWindow;
PositionWindowProcPtr PositionWindow;
ChangeWindowAttributesProcPtr ChangeWindowAttributes;
RealizeWindowProcPtr RealizeWindow;
UnrealizeWindowProcPtr UnrealizeWindow;
RestackWindowProcPtr RestackWindow;
WindowExposuresProcPtr WindowExposures;
CopyWindowProcPtr CopyWindow;
ResizeWindowProcPtr ResizeWindow;
HandleExposuresProcPtr HandleExposures;
ReparentWindowProcPtr ReparentWindow;
ChangeBorderWidthProcPtr ChangeBorderWidth;
ModifyPixmapHeaderProcPtr ModifyPixmapHeader;
SetWindowPixmapProcPtr SetWindowPixmap;
GetImageProcPtr GetImage;
GetSpansProcPtr GetSpans;
CreatePixmapProcPtr CreatePixmap;
DestroyPixmapProcPtr DestroyPixmap;
BitmapToRegionProcPtr BitmapToRegion;
RealizeFontProcPtr RealizeFont;
UnrealizeFontProcPtr UnrealizeFont;
CreateColormapProcPtr CreateColormap;
DestroyColormapProcPtr DestroyColormap;
InstallColormapProcPtr InstallColormap;
StoreColorsProcPtr StoreColors;
SetShapeProcPtr SetShape;
#ifdef RENDER
CreatePictureProcPtr CreatePicture;
DestroyPictureProcPtr DestroyPicture;
ChangePictureClipProcPtr ChangePictureClip;
DestroyPictureClipProcPtr DestroyPictureClip;
ChangePictureProcPtr ChangePicture;
ValidatePictureProcPtr ValidatePicture;
CompositeProcPtr Composite;
GlyphsProcPtr Glyphs;
CompositeRectsProcPtr CompositeRects;
InitIndexedProcPtr InitIndexed;
CloseIndexedProcPtr CloseIndexed;
UpdateIndexedProcPtr UpdateIndexed;
TrapezoidsProcPtr Trapezoids;
TrianglesProcPtr Triangles;
TriStripProcPtr TriStrip;
TriFanProcPtr TriFan;
RealizeGlyphProcPtr RealizeGlyph;
UnrealizeGlyphProcPtr UnrealizeGlyph;
#endif
} DMXScreenInfo;
/* Global variables available to all Xserver/hw/dmx routines. */
extern int dmxNumScreens; /**< Number of dmxScreens */
extern DMXScreenInfo *dmxScreens; /**< List of outputs */
extern XErrorEvent dmxLastErrorEvent; /**< Last error that
* occurred */
extern Bool dmxErrorOccurred; /**< True if an error
* occurred */
extern Bool dmxOffScreenOpt; /**< True if using off
* screen
* optimizations */
extern Bool dmxSubdividePrimitives; /**< True if using the
* primitive subdivision
* optimization */
extern Bool dmxLazyWindowCreation; /**< True if using the
* lazy window creation
* optimization */
extern Bool dmxUseXKB; /**< True if the XKB
* extension should be
* used with the backend
* servers */
extern int dmxDepth; /**< Requested depth if
* non-zero */
#ifdef GLXEXT
extern Bool dmxGLXProxy; /**< True if glxProxy
* support is enabled */
extern Bool dmxGLXSwapGroupSupport; /**< True if glxProxy
* support for swap
* groups and barriers
* is enabled */
extern Bool dmxGLXSyncSwap; /**< True if glxProxy
* should force an XSync
* request after each
* swap buffers call */
extern Bool dmxGLXFinishSwap; /**< True if glxProxy
* should force a
* glFinish request
* after each swap
* buffers call */
#endif
extern char *dmxFontPath; /**< NULL if no font
* path is set on the
* command line;
* otherwise, a string
* of comma separated
* paths built from the
* command line
* specified font
* paths */
extern Bool dmxIgnoreBadFontPaths; /**< True if bad font
* paths should be
* ignored during server
* init */
extern Bool dmxAddRemoveScreens; /**< True if add and
* remove screens support
* is enabled */
#ifdef RANDR
extern int xRROutputsPerScreen;
extern int xRRCrtcsPerScreen;
#endif
extern DMXPropTrans *dmxPropTrans;
extern int dmxPropTransNum;
extern DMXSelectionMap *dmxSelectionMap;
extern int dmxSelectionMapNum;
#ifdef XV
extern char **dmxXvImageFormats;
extern int dmxXvImageFormatsNum;
#endif
extern char dmxDigest[64];
/** Wrap screen or GC function pointer */
#define DMX_WRAP(_entry, _newfunc, _saved, _actual) \
do { \
(_saved)->_entry = (_actual)->_entry; \
(_actual)->_entry = (_newfunc); \
} while (0)
/** Unwrap screen or GC function pointer */
#define DMX_UNWRAP(_entry, _saved, _actual) \
do { \
(_actual)->_entry = (_saved)->_entry; \
} while (0)
/* Define the MAXSCREENSALLOC/FREE macros, when MAXSCREENS patch has not
* been applied to sources. */
#ifdef MAXSCREENS
#define MAXSCREEN_MAKECONSTSTR1(x) #x
#define MAXSCREEN_MAKECONSTSTR2(x) MAXSCREEN_MAKECONSTSTR1(x)
#define MAXSCREEN_FAILED_TXT "Failed at [" \
MAXSCREEN_MAKECONSTSTR2(__LINE__) ":" __FILE__ "] to allocate object: "
#define _MAXSCREENSALLOCF(o,size,fatal) \
do { \
if (!o) { \
o = xcalloc((size), sizeof(*(o))); \
if (!o && fatal) FatalError(MAXSCREEN_FAILED_TXT #o); \
} \
} while (0)
#define _MAXSCREENSALLOCR(o,size,retval) \
do { \
if (!o) { \
o = xcalloc((size), sizeof(*(o))); \
if (!o) return retval; \
} \
} while (0)
#define MAXSCREENSFREE(o) \
do { \
if (o) xfree(o); \
o = NULL; \
} while (0)
#define MAXSCREENSALLOC(o) _MAXSCREENSALLOCF(o,MAXSCREENS, 0)
#define MAXSCREENSALLOC_FATAL(o) _MAXSCREENSALLOCF(o,MAXSCREENS, 1)
#define MAXSCREENSALLOC_RETURN(o,r) _MAXSCREENSALLOCR(o,MAXSCREENS, (r))
#define MAXSCREENSALLOCPLUSONE(o) _MAXSCREENSALLOCF(o,MAXSCREENS+1,0)
#define MAXSCREENSALLOCPLUSONE_FATAL(o) _MAXSCREENSALLOCF(o,MAXSCREENS+1,1)
#define MAXSCREENSCALLOC(o,m) _MAXSCREENSALLOCF(o,MAXSCREENS*(m),0)
#define MAXSCREENSCALLOC_FATAL(o,m) _MAXSCREENSALLOCF(o,MAXSCREENS*(m),1)
#endif
char *dmxMemDup (const char *data, int Len);
#endif /* DMX_H */