Fix the bug that we can't copy & paste multi-byte string to Unicode-base

Windows application. Rename fUnicodeSupport to fUseUnicode, because it
    don't mean wheather Windows support Unicode or not.
This commit is contained in:
Kensuke Matsuzaki 2004-08-03 03:56:41 +00:00
parent 9d1e08f4c3
commit a6098447e9
34 changed files with 18677 additions and 26 deletions

939
GL/mesa/X/xf86glx.c Normal file
View file

@ -0,0 +1,939 @@
/* $XFree86: xc/programs/Xserver/GL/mesa/src/X/xf86glx.c,v 1.19 2003/07/16 01:38:27 dawes Exp $ */
/**************************************************************************
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
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 the rights to use, copy, modify, merge, publish,
distribute, sub license, 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 PRECISION INSIGHT AND/OR ITS 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 <kevin@precisioninsight.com>
* Brian E. Paul <brian@precisioninsight.com>
*
*/
#include <regionstr.h>
#include <resource.h>
#include <GL/gl.h>
#include <GL/glxint.h>
#include <GL/glxtokens.h>
#include <scrnintstr.h>
#include <config.h>
#include <glxserver.h>
#include <glxscreens.h>
#include <glxdrawable.h>
#include <glxcontext.h>
#include <glxext.h>
#include <glxutil.h>
#include "xf86glxint.h"
#include "context.h"
#include "xmesaP.h"
#include <GL/xf86glx.h>
#include "context.h"
/*
* This define is for the glcore.h header file.
* If you add it here, then make sure you also add it in
* ../../../glx/Imakefile.
*/
#if 0
#define DEBUG
#include <GL/internal/glcore.h>
#undef DEBUG
#else
#include <GL/internal/glcore.h>
#endif
#include "glcontextmodes.h"
/*
* This structure is statically allocated in the __glXScreens[]
* structure. This struct is not used anywhere other than in
* __glXScreenInit to initialize each of the active screens
* (__glXActiveScreens[]). Several of the fields must be initialized by
* the screenProbe routine before they are copied to the active screens
* struct. In particular, the contextCreate, pGlxVisual, numVisuals,
* and numUsableVisuals fields must be initialized.
*/
static __GLXscreenInfo __glDDXScreenInfo = {
__MESA_screenProbe, /* Must be generic and handle all screens */
__MESA_createContext, /* Substitute screen's createContext routine */
__MESA_createBuffer, /* Substitute screen's createBuffer routine */
NULL, /* Set up modes in probe */
NULL, /* Set up pVisualPriv in probe */
0, /* Set up numVisuals in probe */
0, /* Set up numUsableVisuals in probe */
"Vendor String", /* GLXvendor is overwritten by __glXScreenInit */
"Version String", /* GLXversion is overwritten by __glXScreenInit */
"Extensions String", /* GLXextensions is overwritten by __glXScreenInit */
NULL /* WrappedPositionWindow is overwritten */
};
void *__glXglDDXScreenInfo(void) {
return &__glDDXScreenInfo;
}
static __GLXextensionInfo __glDDXExtensionInfo = {
GL_CORE_MESA,
__MESA_resetExtension,
__MESA_initVisuals,
__MESA_setVisualConfigs
};
void *__glXglDDXExtensionInfo(void) {
return &__glDDXExtensionInfo;
}
static __MESA_screen MESAScreens[MAXSCREENS];
static __GLcontext *MESA_CC = NULL;
static int numConfigs = 0;
static __GLXvisualConfig *visualConfigs = NULL;
static void **visualPrivates = NULL;
static int count_bits(unsigned int n)
{
int bits = 0;
while (n > 0) {
if (n & 1) bits++;
n >>= 1;
}
return bits;
}
static XMesaVisual find_mesa_visual(int screen, VisualID vid)
{
__MESA_screen * const pMScr = &MESAScreens[screen];
const __GLcontextModes *modes;
unsigned i = 0;
for ( modes = pMScr->modes ; modes != NULL ; modes = modes->next ) {
if ( modes->visualID == vid ) {
break;
}
i++;
}
return (modes != NULL) ? pMScr->xm_vis[i] : NULL;
}
/*
* In the case the driver defines no GLX visuals we'll use these.
* Note that for TrueColor and DirectColor visuals, bufferSize is the
* sum of redSize, greenSize, blueSize and alphaSize, which may be larger
* than the nplanes/rootDepth of the server's X11 visuals
*/
#define NUM_FALLBACK_CONFIGS 5
static __GLXvisualConfig FallbackConfigs[NUM_FALLBACK_CONFIGS] = {
/* [0] = RGB, double buffered, Z */
{
-1, /* vid */
-1, /* class */
True, /* rgba */
-1, -1, -1, 0, /* rgba sizes */
-1, -1, -1, 0, /* rgba masks */
0, 0, 0, 0, /* rgba accum sizes */
True, /* doubleBuffer */
False, /* stereo */
-1, /* bufferSize */
16, /* depthSize */
0, /* stencilSize */
0, /* auxBuffers */
0, /* level */
GLX_NONE, /* visualRating */
GLX_NONE, /* transparentPixel */
0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
0 /* transparentIndex */
},
/* [1] = RGB, double buffered, Z, stencil, accum */
{
-1, /* vid */
-1, /* class */
True, /* rgba */
-1, -1, -1, 0, /* rgba sizes */
-1, -1, -1, 0, /* rgba masks */
16, 16, 16, 0, /* rgba accum sizes */
True, /* doubleBuffer */
False, /* stereo */
-1, /* bufferSize */
16, /* depthSize */
8, /* stencilSize */
0, /* auxBuffers */
0, /* level */
GLX_NONE, /* visualRating */
GLX_NONE, /* transparentPixel */
0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
0 /* transparentIndex */
},
/* [2] = RGB+Alpha, double buffered, Z, stencil, accum */
{
-1, /* vid */
-1, /* class */
True, /* rgba */
-1, -1, -1, 8, /* rgba sizes */
-1, -1, -1, -1, /* rgba masks */
16, 16, 16, 16, /* rgba accum sizes */
True, /* doubleBuffer */
False, /* stereo */
-1, /* bufferSize */
16, /* depthSize */
8, /* stencilSize */
0, /* auxBuffers */
0, /* level */
GLX_NONE, /* visualRating */
GLX_NONE, /* transparentPixel */
0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
0 /* transparentIndex */
},
/* [3] = RGB+Alpha, single buffered, Z, stencil, accum */
{
-1, /* vid */
-1, /* class */
True, /* rgba */
-1, -1, -1, 8, /* rgba sizes */
-1, -1, -1, -1, /* rgba masks */
16, 16, 16, 16, /* rgba accum sizes */
False, /* doubleBuffer */
False, /* stereo */
-1, /* bufferSize */
16, /* depthSize */
8, /* stencilSize */
0, /* auxBuffers */
0, /* level */
GLX_NONE, /* visualRating */
GLX_NONE, /* transparentPixel */
0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
0 /* transparentIndex */
},
/* [4] = CI, double buffered, Z */
{
-1, /* vid */
-1, /* class */
False, /* rgba? (false = color index) */
-1, -1, -1, 0, /* rgba sizes */
-1, -1, -1, 0, /* rgba masks */
0, 0, 0, 0, /* rgba accum sizes */
True, /* doubleBuffer */
False, /* stereo */
-1, /* bufferSize */
16, /* depthSize */
0, /* stencilSize */
0, /* auxBuffers */
0, /* level */
GLX_NONE, /* visualRating */
GLX_NONE, /* transparentPixel */
0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
0 /* transparentIndex */
},
};
static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
VisualID *defaultVisp,
int ndepth, DepthPtr pdepth,
int rootDepth)
{
int numRGBconfigs;
int numCIconfigs;
int numVisuals = *nvisualp;
int numNewVisuals;
int numNewConfigs;
VisualPtr pVisual = *visualp;
VisualPtr pVisualNew = NULL;
VisualID *orig_vid = NULL;
__GLcontextModes *modes;
__GLXvisualConfig *pNewVisualConfigs = NULL;
void **glXVisualPriv;
void **pNewVisualPriv;
int found_default;
int i, j, k;
if (numConfigs > 0)
numNewConfigs = numConfigs;
else
numNewConfigs = NUM_FALLBACK_CONFIGS;
/* Alloc space for the list of new GLX visuals */
pNewVisualConfigs = (__GLXvisualConfig *)
__glXMalloc(numNewConfigs * sizeof(__GLXvisualConfig));
if (!pNewVisualConfigs) {
return FALSE;
}
/* Alloc space for the list of new GLX visual privates */
pNewVisualPriv = (void **) __glXMalloc(numNewConfigs * sizeof(void *));
if (!pNewVisualPriv) {
__glXFree(pNewVisualConfigs);
return FALSE;
}
/*
** If SetVisualConfigs was not called, then use default GLX
** visual configs.
*/
if (numConfigs == 0) {
memcpy(pNewVisualConfigs, FallbackConfigs,
NUM_FALLBACK_CONFIGS * sizeof(__GLXvisualConfig));
memset(pNewVisualPriv, 0, NUM_FALLBACK_CONFIGS * sizeof(void *));
}
else {
/* copy driver's visual config info */
for (i = 0; i < numConfigs; i++) {
pNewVisualConfigs[i] = visualConfigs[i];
pNewVisualPriv[i] = visualPrivates[i];
}
}
/* Count the number of RGB and CI visual configs */
numRGBconfigs = 0;
numCIconfigs = 0;
for (i = 0; i < numNewConfigs; i++) {
if (pNewVisualConfigs[i].rgba)
numRGBconfigs++;
else
numCIconfigs++;
}
/* Count the total number of visuals to compute */
numNewVisuals = 0;
for (i = 0; i < numVisuals; i++) {
numNewVisuals +=
(pVisual[i].class == TrueColor || pVisual[i].class == DirectColor)
? numRGBconfigs : numCIconfigs;
}
/* Reset variables for use with the next screen/driver's visual configs */
visualConfigs = NULL;
numConfigs = 0;
/* Alloc temp space for the list of orig VisualIDs for each new visual */
orig_vid = (VisualID *)__glXMalloc(numNewVisuals * sizeof(VisualID));
if (!orig_vid) {
__glXFree(pNewVisualPriv);
__glXFree(pNewVisualConfigs);
return FALSE;
}
/* Alloc space for the list of glXVisuals */
modes = _gl_context_modes_create(numNewVisuals, sizeof(__GLcontextModes));
if (modes == NULL) {
__glXFree(orig_vid);
__glXFree(pNewVisualPriv);
__glXFree(pNewVisualConfigs);
return FALSE;
}
/* Alloc space for the list of glXVisualPrivates */
glXVisualPriv = (void **)__glXMalloc(numNewVisuals * sizeof(void *));
if (!glXVisualPriv) {
_gl_context_modes_destroy( modes );
__glXFree(orig_vid);
__glXFree(pNewVisualPriv);
__glXFree(pNewVisualConfigs);
return FALSE;
}
/* Alloc space for the new list of the X server's visuals */
pVisualNew = (VisualPtr)__glXMalloc(numNewVisuals * sizeof(VisualRec));
if (!pVisualNew) {
__glXFree(glXVisualPriv);
_gl_context_modes_destroy( modes );
__glXFree(orig_vid);
__glXFree(pNewVisualPriv);
__glXFree(pNewVisualConfigs);
return FALSE;
}
/* Initialize the new visuals */
found_default = FALSE;
MESAScreens[screenInfo.numScreens-1].modes = modes;
for (i = j = 0; i < numVisuals; i++) {
int is_rgb = (pVisual[i].class == TrueColor ||
pVisual[i].class == DirectColor);
for (k = 0; k < numNewConfigs; k++) {
if (pNewVisualConfigs[k].rgba != is_rgb)
continue;
assert( modes != NULL );
/* Initialize the new visual */
pVisualNew[j] = pVisual[i];
pVisualNew[j].vid = FakeClientID(0);
/* Check for the default visual */
if (!found_default && pVisual[i].vid == *defaultVisp) {
*defaultVisp = pVisualNew[j].vid;
found_default = TRUE;
}
/* Save the old VisualID */
orig_vid[j] = pVisual[i].vid;
/* Initialize the glXVisual */
_gl_copy_visual_to_context_mode( modes, & pNewVisualConfigs[k] );
modes->visualID = pVisualNew[j].vid;
/*
* If the class is -1, then assume the X visual information
* is identical to what GLX needs, and take them from the X
* visual. NOTE: if class != -1, then all other fields MUST
* be initialized.
*/
if (modes->visualType == GLX_NONE) {
modes->visualType = _gl_convert_from_x_visual_type( pVisual[i].class );
modes->redBits = count_bits(pVisual[i].redMask);
modes->greenBits = count_bits(pVisual[i].greenMask);
modes->blueBits = count_bits(pVisual[i].blueMask);
modes->alphaBits = modes->alphaBits;
modes->redMask = pVisual[i].redMask;
modes->greenMask = pVisual[i].greenMask;
modes->blueMask = pVisual[i].blueMask;
modes->alphaMask = modes->alphaMask;
modes->rgbBits = (is_rgb)
? (modes->redBits + modes->greenBits +
modes->blueBits + modes->alphaBits)
: rootDepth;
}
/* Save the device-dependent private for this visual */
glXVisualPriv[j] = pNewVisualPriv[k];
j++;
modes = modes->next;
}
}
assert(j <= numNewVisuals);
/* Save the GLX visuals in the screen structure */
MESAScreens[screenInfo.numScreens-1].num_vis = numNewVisuals;
MESAScreens[screenInfo.numScreens-1].private = glXVisualPriv;
/* Set up depth's VisualIDs */
for (i = 0; i < ndepth; i++) {
int numVids = 0;
VisualID *pVids = NULL;
int k, n = 0;
/* Count the new number of VisualIDs at this depth */
for (j = 0; j < pdepth[i].numVids; j++)
for (k = 0; k < numNewVisuals; k++)
if (pdepth[i].vids[j] == orig_vid[k])
numVids++;
/* Allocate a new list of VisualIDs for this depth */
pVids = (VisualID *)__glXMalloc(numVids * sizeof(VisualID));
/* Initialize the new list of VisualIDs for this depth */
for (j = 0; j < pdepth[i].numVids; j++)
for (k = 0; k < numNewVisuals; k++)
if (pdepth[i].vids[j] == orig_vid[k])
pVids[n++] = pVisualNew[k].vid;
/* Update this depth's list of VisualIDs */
__glXFree(pdepth[i].vids);
pdepth[i].vids = pVids;
pdepth[i].numVids = numVids;
}
/* Update the X server's visuals */
*nvisualp = numNewVisuals;
*visualp = pVisualNew;
/* Free the old list of the X server's visuals */
__glXFree(pVisual);
/* Clean up temporary allocations */
__glXFree(orig_vid);
__glXFree(pNewVisualPriv);
__glXFree(pNewVisualConfigs);
/* Free the private list created by DDX HW driver */
if (visualPrivates)
xfree(visualPrivates);
visualPrivates = NULL;
return TRUE;
}
void __MESA_setVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
void **privates)
{
numConfigs = nconfigs;
visualConfigs = configs;
visualPrivates = privates;
}
Bool __MESA_initVisuals(VisualPtr *visualp, DepthPtr *depthp,
int *nvisualp, int *ndepthp, int *rootDepthp,
VisualID *defaultVisp, unsigned long sizes,
int bitsPerRGB)
{
/*
* Setup the visuals supported by this particular screen.
*/
return init_visuals(nvisualp, visualp, defaultVisp,
*ndepthp, *depthp, *rootDepthp);
}
static void fixup_visuals(int screen)
{
ScreenPtr pScreen = screenInfo.screens[screen];
__MESA_screen *pMScr = &MESAScreens[screen];
int j;
__GLcontextModes *modes;
for ( modes = pMScr->modes ; modes != NULL ; modes = modes->next ) {
const int vis_class = _gl_convert_to_x_visual_type( modes->visualType );
const int nplanes = (modes->rgbBits - modes->alphaBits);
const VisualPtr pVis = pScreen->visuals;
/* Find a visual that matches the GLX visual's class and size */
for (j = 0; j < pScreen->numVisuals; j++) {
if (pVis[j].class == vis_class &&
pVis[j].nplanes == nplanes) {
/* Fixup the masks */
modes->redMask = pVis[j].redMask;
modes->greenMask = pVis[j].greenMask;
modes->blueMask = pVis[j].blueMask;
/* Recalc the sizes */
modes->redBits = count_bits(modes->redMask);
modes->greenBits = count_bits(modes->greenMask);
modes->blueBits = count_bits(modes->blueMask);
}
}
}
}
static void init_screen_visuals(int screen)
{
ScreenPtr pScreen = screenInfo.screens[screen];
__GLcontextModes *modes;
XMesaVisual *pXMesaVisual;
int *used;
int i, j;
/* Alloc space for the list of XMesa visuals */
pXMesaVisual = (XMesaVisual *)__glXMalloc(MESAScreens[screen].num_vis *
sizeof(XMesaVisual));
__glXMemset(pXMesaVisual, 0,
MESAScreens[screen].num_vis * sizeof(XMesaVisual));
/* FIXME: Change 'used' to be a array of bits (rather than of ints),
* FIXME: create a stack array of 8 or 16 bytes. If 'numVisuals' is less
* FIXME: than 64 or 128 the stack array can be used instead of calling
* FIXME: __glXMalloc / __glXFree. If nothing else, convert 'used' to
* FIXME: array of bytes instead of ints!
*/
used = (int *)__glXMalloc(pScreen->numVisuals * sizeof(int));
__glXMemset(used, 0, pScreen->numVisuals * sizeof(int));
i = 0;
for ( modes = MESAScreens[screen].modes
; modes != NULL
; modes = modes->next ) {
const int vis_class = _gl_convert_to_x_visual_type( modes->visualType );
const int nplanes = (modes->rgbBits - modes->alphaBits);
const VisualPtr pVis = pScreen->visuals;
for (j = 0; j < pScreen->numVisuals; j++) {
if (pVis[j].class == vis_class &&
pVis[j].nplanes == nplanes &&
pVis[j].redMask == modes->redMask &&
pVis[j].greenMask == modes->greenMask &&
pVis[j].blueMask == modes->blueMask &&
!used[j]) {
/* Create the XMesa visual */
pXMesaVisual[i] =
XMesaCreateVisual(pScreen,
pVis,
modes->rgbMode,
(modes->alphaBits > 0),
modes->doubleBufferMode,
modes->stereoMode,
GL_TRUE, /* ximage_flag */
modes->depthBits,
modes->stencilBits,
modes->accumRedBits,
modes->accumGreenBits,
modes->accumBlueBits,
modes->accumAlphaBits,
modes->samples,
modes->level,
modes->visualRating);
/* Set the VisualID */
modes->visualID = pVis[j].vid;
/* Mark this visual used */
used[j] = 1;
break;
}
}
if ( j == pScreen->numVisuals ) {
ErrorF("No matching visual for __GLcontextMode with "
"visual class = %d (%d), nplanes = %u\n",
vis_class,
modes->visualType,
(modes->rgbBits - modes->alphaBits) );
}
else if ( modes->visualID == -1 ) {
FatalError( "Matching visual found, but visualID still -1!\n" );
}
i++;
}
__glXFree(used);
MESAScreens[screen].xm_vis = pXMesaVisual;
}
Bool __MESA_screenProbe(int screen)
{
/*
* Set up the current screen's visuals.
*/
__glDDXScreenInfo.modes = MESAScreens[screen].modes;
__glDDXScreenInfo.pVisualPriv = MESAScreens[screen].private;
__glDDXScreenInfo.numVisuals =
__glDDXScreenInfo.numUsableVisuals = MESAScreens[screen].num_vis;
/*
* Set the current screen's createContext routine. This could be
* wrapped by a DDX GLX context creation routine.
*/
__glDDXScreenInfo.createContext = __MESA_createContext;
/*
* The ordering of the rgb compenents might have been changed by the
* driver after mi initialized them.
*/
fixup_visuals(screen);
/*
* Find the GLX visuals that are supported by this screen and create
* XMesa's visuals.
*/
init_screen_visuals(screen);
return TRUE;
}
extern void __MESA_resetExtension(void)
{
int i, j;
XMesaReset();
for (i = 0; i < screenInfo.numScreens; i++) {
for (j = 0; j < MESAScreens[i].num_vis; j++) {
if (MESAScreens[i].xm_vis[j]) {
XMesaDestroyVisual(MESAScreens[i].xm_vis[j]);
MESAScreens[i].xm_vis[j] = NULL;
}
}
_gl_context_modes_destroy( MESAScreens[i].modes );
MESAScreens[i].modes = NULL;
__glXFree(MESAScreens[i].private);
MESAScreens[i].private = NULL;
__glXFree(MESAScreens[i].xm_vis);
MESAScreens[i].xm_vis = NULL;
MESAScreens[i].num_vis = 0;
}
__glDDXScreenInfo.modes = NULL;
MESA_CC = NULL;
}
void __MESA_createBuffer(__GLXdrawablePrivate *glxPriv)
{
DrawablePtr pDraw = glxPriv->pDraw;
XMesaVisual xm_vis = find_mesa_visual(pDraw->pScreen->myNum,
glxPriv->modes->visualID);
__GLdrawablePrivate *glPriv = &glxPriv->glPriv;
__MESA_buffer buf;
if (xm_vis == NULL) {
ErrorF("find_mesa_visual returned NULL for visualID = 0x%04x\n",
glxPriv->modes->visualID);
}
buf = (__MESA_buffer)__glXMalloc(sizeof(struct __MESA_bufferRec));
/* Create Mesa's buffers */
if (glxPriv->type == DRAWABLE_WINDOW) {
buf->xm_buf = (void *)XMesaCreateWindowBuffer(xm_vis,
(WindowPtr)pDraw);
} else {
buf->xm_buf = (void *)XMesaCreatePixmapBuffer(xm_vis,
(PixmapPtr)pDraw, 0);
}
/* Wrap the front buffer's resize routine */
buf->fbresize = glPriv->frontBuffer.resize;
glPriv->frontBuffer.resize = __MESA_resizeBuffers;
/* Wrap the swap buffers routine */
buf->fbswap = glxPriv->swapBuffers;
glxPriv->swapBuffers = __MESA_swapBuffers;
/* Save Mesa's private buffer structure */
glPriv->private = (void *)buf;
glPriv->freePrivate = __MESA_destroyBuffer;
}
GLboolean __MESA_resizeBuffers(__GLdrawableBuffer *buffer,
GLint x, GLint y,
GLuint width, GLuint height,
__GLdrawablePrivate *glPriv,
GLuint bufferMask)
{
__MESA_buffer buf = (__MESA_buffer)glPriv->private;
if (buf->xm_buf)
XMesaResizeBuffers(buf->xm_buf);
return (*buf->fbresize)(buffer, x, y, width, height, glPriv, bufferMask);
}
GLboolean __MESA_swapBuffers(__GLXdrawablePrivate *glxPriv)
{
__MESA_buffer buf = (__MESA_buffer)glxPriv->glPriv.private;
/*
** Do not call the wrapped swap buffers routine since Mesa has
** already done the swap.
*/
XMesaSwapBuffers(buf->xm_buf);
return GL_TRUE;
}
void __MESA_destroyBuffer(__GLdrawablePrivate *glPriv)
{
__MESA_buffer buf = (__MESA_buffer)glPriv->private;
__GLXdrawablePrivate *glxPriv = (__GLXdrawablePrivate *)glPriv->other;
/* Destroy Mesa's buffers */
if (buf->xm_buf)
XMesaDestroyBuffer(buf->xm_buf);
/* Unwrap these routines */
glxPriv->swapBuffers = buf->fbswap;
glPriv->frontBuffer.resize = buf->fbresize;
__glXFree(glPriv->private);
glPriv->private = NULL;
}
__GLinterface *__MESA_createContext(__GLimports *imports,
__GLcontextModes *modes,
__GLinterface *shareGC)
{
__GLcontext *gl_ctx = NULL;
__GLcontext *m_share = NULL;
__GLXcontext *glxc = (__GLXcontext *)imports->other;
XMesaVisual xm_vis;
if (shareGC)
m_share = (__GLcontext *)shareGC;
xm_vis = find_mesa_visual(glxc->pScreen->myNum, glxc->modes->visualID);
if (xm_vis) {
XMesaContext xmshare = m_share ? m_share->DriverCtx : 0;
XMesaContext xmctx = XMesaCreateContext(xm_vis, xmshare);
gl_ctx = xmctx ? &xmctx->mesa : 0;
}
else {
ErrorF("find_mesa_visual returned NULL for visualID = 0x%04x\n",
glxc->modes->visualID);
}
if (!gl_ctx)
return NULL;
gl_ctx->imports = *imports;
gl_ctx->exports.destroyContext = __MESA_destroyContext;
gl_ctx->exports.loseCurrent = __MESA_loseCurrent;
gl_ctx->exports.makeCurrent = __MESA_makeCurrent;
gl_ctx->exports.shareContext = __MESA_shareContext;
gl_ctx->exports.copyContext = __MESA_copyContext;
gl_ctx->exports.forceCurrent = __MESA_forceCurrent;
gl_ctx->exports.notifyResize = __MESA_notifyResize;
gl_ctx->exports.notifyDestroy = __MESA_notifyDestroy;
gl_ctx->exports.notifySwapBuffers = __MESA_notifySwapBuffers;
gl_ctx->exports.dispatchExec = __MESA_dispatchExec;
gl_ctx->exports.beginDispatchOverride = __MESA_beginDispatchOverride;
gl_ctx->exports.endDispatchOverride = __MESA_endDispatchOverride;
return (__GLinterface *)gl_ctx;
}
GLboolean __MESA_destroyContext(__GLcontext *gc)
{
XMesaContext xmesa = (XMesaContext) gc->DriverCtx;
XMesaDestroyContext( xmesa );
return GL_TRUE;
}
GLboolean __MESA_loseCurrent(__GLcontext *gc)
{
XMesaContext xmesa = (XMesaContext) gc->DriverCtx;
MESA_CC = NULL;
__glXLastContext = NULL;
return XMesaLoseCurrent(xmesa);
}
GLboolean __MESA_makeCurrent(__GLcontext *gc)
{
__GLdrawablePrivate *drawPriv = gc->imports.getDrawablePrivate( gc );
__MESA_buffer drawBuf = (__MESA_buffer)drawPriv->private;
__GLdrawablePrivate *readPriv = gc->imports.getReadablePrivate( gc );
__MESA_buffer readBuf = (__MESA_buffer)readPriv->private;
XMesaContext xmesa = (XMesaContext) gc->DriverCtx;
MESA_CC = gc;
return XMesaMakeCurrent2(xmesa, drawBuf->xm_buf, readBuf->xm_buf);
}
GLboolean __MESA_shareContext(__GLcontext *gc, __GLcontext *gcShare)
{
/* NOT_DONE */
/* XXX I don't see where/how this could ever be called */
ErrorF("__MESA_shareContext\n");
return GL_FALSE;
}
GLboolean __MESA_copyContext(__GLcontext *dst, const __GLcontext *src,
GLuint mask)
{
XMesaContext xm_dst = (XMesaContext) dst->DriverCtx;
const XMesaContext xm_src = (const XMesaContext) src->DriverCtx;
_mesa_copy_context(&xm_src->mesa, &xm_dst->mesa, mask);
return GL_TRUE;
}
GLboolean __MESA_forceCurrent(__GLcontext *gc)
{
XMesaContext xmesa = (XMesaContext) gc->DriverCtx;
MESA_CC = gc;
return XMesaForceCurrent(xmesa);
}
GLboolean __MESA_notifyResize(__GLcontext *gc)
{
/* NOT_DONE */
ErrorF("__MESA_notifyResize\n");
return GL_FALSE;
}
void __MESA_notifyDestroy(__GLcontext *gc)
{
/* NOT_DONE */
ErrorF("__MESA_notifyDestroy\n");
return;
}
void __MESA_notifySwapBuffers(__GLcontext *gc)
{
_mesa_notifySwapBuffers(gc);
}
struct __GLdispatchStateRec *__MESA_dispatchExec(__GLcontext *gc)
{
/* NOT_DONE */
ErrorF("__MESA_dispatchExec\n");
return NULL;
}
void __MESA_beginDispatchOverride(__GLcontext *gc)
{
/* NOT_DONE */
ErrorF("__MESA_beginDispatchOverride\n");
return;
}
void __MESA_endDispatchOverride(__GLcontext *gc)
{
/* NOT_DONE */
ErrorF("__MESA_endDispatchOverride\n");
return;
}
/*
* Server-side GLX uses these functions which are normally defined
* in the OpenGL SI.
*/
GLint __glEvalComputeK(GLenum target)
{
switch (target) {
case GL_MAP1_VERTEX_4:
case GL_MAP1_COLOR_4:
case GL_MAP1_TEXTURE_COORD_4:
case GL_MAP2_VERTEX_4:
case GL_MAP2_COLOR_4:
case GL_MAP2_TEXTURE_COORD_4:
return 4;
case GL_MAP1_VERTEX_3:
case GL_MAP1_TEXTURE_COORD_3:
case GL_MAP1_NORMAL:
case GL_MAP2_VERTEX_3:
case GL_MAP2_TEXTURE_COORD_3:
case GL_MAP2_NORMAL:
return 3;
case GL_MAP1_TEXTURE_COORD_2:
case GL_MAP2_TEXTURE_COORD_2:
return 2;
case GL_MAP1_TEXTURE_COORD_1:
case GL_MAP2_TEXTURE_COORD_1:
case GL_MAP1_INDEX:
case GL_MAP2_INDEX:
return 1;
default:
return 0;
}
}
GLuint __glFloorLog2(GLuint val)
{
int c = 0;
while (val > 1) {
c++;
val >>= 1;
}
return c;
}

371
Xext/xevie.c Normal file
View file

@ -0,0 +1,371 @@
/************************************************************
Copyright 2003 Sun Microsystems, Inc.
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 the rights to use, copy, modify, merge, publish,
distribute, and/or sell copies of the Software, and to permit persons
to whom the Software is furnished to do so, provided that the above
copyright notice(s) and this permission notice appear in all copies of
the Software and that both the above copyright notice(s) and this
permission notice appear in supporting documentation.
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 NONINFRINGEMENT
OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Except as contained in this notice, the name of a copyright holder
shall not be used in advertising or otherwise to promote the sale, use
or other dealings in this Software without prior written authorization
of the copyright holder.
************************************************************/
#define NEED_REPLIES
#define NEED_EVENTS
#include "X.h"
#include "Xproto.h"
#include "misc.h"
#include "dixstruct.h"
#include "extnsionst.h"
#include "colormapst.h"
#include "scrnintstr.h"
#include "servermd.h"
#define _XEVIE_SERVER_
#include "Xeviestr.h"
#include "Xfuncproto.h"
#include "input.h"
#include "../os/osdep.h"
#define NoSuchEvent 0x80000000
extern Bool noXkbExtension;
extern int xeviegrabState;
static int ProcDispatch (), SProcDispatch ();
static void ResetProc ();
static unsigned char ReqCode = 0;
static int ErrorBase;
int xevieFlag = 0;
int xevieClientIndex = 0;
DeviceIntPtr xeviekb = NULL;
DeviceIntPtr xeviemouse = NULL;
Mask xevieMask = 0;
int xevieEventSent = 0;
int xevieKBEventSent = 0;
Mask xevieFilters[128] =
{
NoSuchEvent, /* 0 */
NoSuchEvent, /* 1 */
KeyPressMask, /* KeyPress */
KeyReleaseMask, /* KeyRelease */
ButtonPressMask, /* ButtonPress */
ButtonReleaseMask, /* ButtonRelease */
PointerMotionMask /* MotionNotify (initial state) */
};
static void XevieEnd(int clientIndex);
static void XevieClientStateCallback(CallbackListPtr *pcbl, pointer nulldata,
pointer calldata);
static void XevieServerGrabStateCallback(CallbackListPtr *pcbl,
pointer nulldata,
pointer calldata);
void
XevieExtensionInit ()
{
ExtensionEntry* extEntry;
if (!AddCallback(&ServerGrabCallback,XevieServerGrabStateCallback,NULL))
return;
if (extEntry = AddExtension (XEVIENAME,
0,
XevieNumberErrors,
ProcDispatch,
SProcDispatch,
ResetProc,
StandardMinorOpcode)) {
ReqCode = (unsigned char)extEntry->base;
ErrorBase = extEntry->errorBase;
}
/* PC servers initialize the desktop colors (citems) here! */
}
/*ARGSUSED*/
static
void ResetProc (extEntry)
ExtensionEntry* extEntry;
{
}
static
int ProcQueryVersion (client)
register ClientPtr client;
{
REQUEST (xXevieQueryVersionReq);
xXevieQueryVersionReply rep;
register int n;
REQUEST_SIZE_MATCH (xXevieQueryVersionReq);
rep.type = X_Reply;
rep.length = 0;
rep.sequence_number = client->sequence;
rep.server_major_version = XEVIE_MAJOR_VERSION;
rep.server_minor_version = XEVIE_MINOR_VERSION;
WriteToClient (client, sizeof (xXevieQueryVersionReply), (char *)&rep);
return client->noClientException;
}
static
int ProcStart (client)
register ClientPtr client;
{
REQUEST (xXevieStartReq);
xXevieStartReply rep;
register int n;
REQUEST_SIZE_MATCH (xXevieStartReq);
rep.pad1 = 0;
if(!xevieFlag){
if (AddCallback(&ClientStateCallback,XevieClientStateCallback,NULL)) {
xevieFlag = 1;
rep.pad1 = 1;
xevieClientIndex = client->index;
} else
return BadAlloc;
} else
return BadAccess;
rep.type = X_Reply;
rep.sequence_number = client->sequence;
WriteToClient (client, sizeof (xXevieStartReply), (char *)&rep);
return client->noClientException;
}
static
int ProcEnd (client)
register ClientPtr client;
{
xXevieEndReply rep;
XevieEnd(xevieClientIndex);
rep.type = X_Reply;
rep.sequence_number = client->sequence;
WriteToClient (client, sizeof (xXevieEndReply), (char *)&rep);
return client->noClientException;
}
static
int ProcSend (client)
register ClientPtr client;
{
REQUEST (xXevieSendReq);
xXevieSendReply rep;
xEvent *xE;
OsCommPtr oc;
static unsigned char lastDetail = 0, lastType = 0;
xE = (xEvent *)&stuff->event;
rep.type = X_Reply;
rep.sequence_number = client->sequence;
WriteToClient (client, sizeof (xXevieSendReply), (char *)&rep);
switch(xE->u.u.type) {
case KeyPress:
case KeyRelease:
xevieKBEventSent = 1;
#ifdef XKB
if(noXkbExtension)
#endif
CoreProcessKeyboardEvent (xE, xeviekb, 1);
break;
case ButtonPress:
case ButtonRelease:
case MotionNotify:
xevieEventSent = 1;
CoreProcessPointerEvent(xE, xeviemouse, 1);
break;
default:
break;
}
lastType = xE->u.u.type;
lastDetail = xE->u.u.detail;
return client->noClientException;
}
static
int ProcSelectInput (client)
register ClientPtr client;
{
REQUEST (xXevieSelectInputReq);
xXevieSelectInputReply rep;
xevieMask = (long)stuff->event_mask;
rep.type = X_Reply;
rep.sequence_number = client->sequence;
WriteToClient (client, sizeof (xXevieSelectInputReply), (char *)&rep);
return client->noClientException;
}
static
int ProcDispatch (client)
register ClientPtr client;
{
REQUEST (xReq);
switch (stuff->data)
{
case X_XevieQueryVersion:
return ProcQueryVersion (client);
case X_XevieStart:
return ProcStart (client);
case X_XevieEnd:
return ProcEnd (client);
case X_XevieSend:
return ProcSend (client);
case X_XevieSelectInput:
return ProcSelectInput(client);
default:
return BadRequest;
}
}
static
int SProcQueryVersion (client)
register ClientPtr client;
{
register int n;
REQUEST(xXevieQueryVersionReq);
swaps(&stuff->length, n);
return ProcQueryVersion(client);
}
static
int SProcStart (client)
ClientPtr client;
{
register int n;
REQUEST (xXevieStartReq);
swaps (&stuff->length, n);
swapl (&stuff->screen, n);
REQUEST_AT_LEAST_SIZE (xXevieStartReq);
return ProcStart (client);
}
static
int SProcEnd (client)
ClientPtr client;
{
register int n;
int count;
xColorItem* pItem;
REQUEST (xXevieEndReq);
swaps (&stuff->length, n);
REQUEST_AT_LEAST_SIZE (xXevieEndReq);
swapl(&stuff->cmap, n);
return ProcEnd (client);
}
static
int SProcSend (client)
ClientPtr client;
{
register int n;
int count;
REQUEST (xXevieSendReq);
swaps (&stuff->length, n);
REQUEST_AT_LEAST_SIZE (xXevieSendReq);
swapl(&stuff->event, n);
return ProcSend (client);
}
static
int SProcSelectInput (client)
ClientPtr client;
{
register int n;
int count;
REQUEST (xXevieSelectInputReq);
swaps (&stuff->length, n);
REQUEST_AT_LEAST_SIZE (xXevieSendReq);
swapl(&stuff->event_mask, n);
return ProcSelectInput (client);
}
static
int SProcDispatch (client)
register ClientPtr client;
{
REQUEST(xReq);
switch (stuff->data)
{
case X_XevieQueryVersion:
return SProcQueryVersion (client);
case X_XevieStart:
return SProcStart (client);
case X_XevieEnd:
return SProcEnd (client);
case X_XevieSend:
return SProcSend (client);
case X_XevieSelectInput:
return SProcSelectInput(client);
default:
return BadRequest;
}
}
static void
XevieEnd(int clientIndex)
{
if (!clientIndex || clientIndex == xevieClientIndex) {
xevieFlag = 0;
xevieClientIndex = 0;
DeleteCallback (&ClientStateCallback, XevieClientStateCallback, NULL);
}
}
static void
XevieClientStateCallback(CallbackListPtr *pcbl, pointer nulldata,
pointer calldata)
{
NewClientInfoRec *pci = (NewClientInfoRec *)calldata;
ClientPtr client = pci->client;
if (client->clientState == ClientStateGone
|| client->clientState == ClientStateRetained)
XevieEnd(client->index);
}
static void
XevieServerGrabStateCallback(CallbackListPtr *pcbl, pointer nulldata,
pointer calldata)
{
ServerGrabInfoRec *grbinfo = (ServerGrabInfoRec *)calldata;
if (grbinfo->grabstate == SERVER_GRABBED)
xeviegrabState = TRUE;
else
xeviegrabState = FALSE;
}

408
composite/compext.c Normal file
View file

@ -0,0 +1,408 @@
/*
* $Id$
*
* Copyright © 2003 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "compint.h"
static CARD8 CompositeReqCode;
int CompositeClientPrivateIndex;
RESTYPE CompositeClientWindowType;
RESTYPE CompositeClientSubwindowsType;
typedef struct _CompositeClient {
int major_version;
int minor_version;
} CompositeClientRec, *CompositeClientPtr;
#define GetCompositeClient(pClient) ((CompositeClientPtr) (pClient)->devPrivates[CompositeClientPrivateIndex].ptr)
static void
CompositeClientCallback (CallbackListPtr *list,
pointer closure,
pointer data)
{
NewClientInfoRec *clientinfo = (NewClientInfoRec *) data;
ClientPtr pClient = clientinfo->client;
CompositeClientPtr pCompositeClient = GetCompositeClient (pClient);
pCompositeClient->major_version = 0;
pCompositeClient->minor_version = 0;
}
static void
CompositeResetProc (ExtensionEntry *extEntry)
{
}
static int
FreeCompositeClientWindow (pointer value, XID ccwid)
{
WindowPtr pWin = value;
compFreeClientWindow (pWin, ccwid);
return Success;
}
static int
FreeCompositeClientSubwindows (pointer value, XID ccwid)
{
WindowPtr pWin = value;
compFreeClientSubwindows (pWin, ccwid);
return Success;
}
static int
ProcCompositeQueryVersion (ClientPtr client)
{
CompositeClientPtr pCompositeClient = GetCompositeClient (client);
xCompositeQueryVersionReply rep;
register int n;
REQUEST(xCompositeQueryVersionReq);
REQUEST_SIZE_MATCH(xCompositeQueryVersionReq);
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
if (stuff->majorVersion < COMPOSITE_MAJOR) {
rep.majorVersion = stuff->majorVersion;
rep.minorVersion = stuff->minorVersion;
} else {
rep.majorVersion = COMPOSITE_MAJOR;
if (stuff->majorVersion == COMPOSITE_MAJOR &&
stuff->minorVersion < COMPOSITE_MINOR)
rep.minorVersion = stuff->minorVersion;
else
rep.minorVersion = COMPOSITE_MINOR;
}
pCompositeClient->major_version = rep.majorVersion;
pCompositeClient->minor_version = rep.minorVersion;
if (client->swapped) {
swaps(&rep.sequenceNumber, n);
swapl(&rep.length, n);
swapl(&rep.majorVersion, n);
swapl(&rep.minorVersion, n);
}
WriteToClient(client, sizeof(xCompositeQueryVersionReply), (char *)&rep);
return(client->noClientException);
}
static int
ProcCompositeRedirectWindow (ClientPtr client)
{
WindowPtr pWin;
REQUEST(xCompositeRedirectWindowReq);
REQUEST_SIZE_MATCH(xCompositeRedirectWindowReq);
pWin = (WindowPtr) LookupIDByType (stuff->window, RT_WINDOW);
if (!pWin)
{
client->errorValue = stuff->window;
return BadWindow;
}
return compRedirectWindow (client, pWin, stuff->update);
}
static int
ProcCompositeRedirectSubwindows (ClientPtr client)
{
WindowPtr pWin;
REQUEST(xCompositeRedirectSubwindowsReq);
REQUEST_SIZE_MATCH(xCompositeRedirectSubwindowsReq);
pWin = (WindowPtr) LookupIDByType (stuff->window, RT_WINDOW);
if (!pWin)
{
client->errorValue = stuff->window;
return BadWindow;
}
return compRedirectSubwindows (client, pWin, stuff->update);
}
static int
ProcCompositeUnredirectWindow (ClientPtr client)
{
WindowPtr pWin;
REQUEST(xCompositeUnredirectWindowReq);
REQUEST_SIZE_MATCH(xCompositeUnredirectWindowReq);
pWin = (WindowPtr) LookupIDByType (stuff->window, RT_WINDOW);
if (!pWin)
{
client->errorValue = stuff->window;
return BadWindow;
}
return compUnredirectWindow (client, pWin, stuff->update);
}
static int
ProcCompositeUnredirectSubwindows (ClientPtr client)
{
WindowPtr pWin;
REQUEST(xCompositeUnredirectSubwindowsReq);
REQUEST_SIZE_MATCH(xCompositeUnredirectSubwindowsReq);
pWin = (WindowPtr) LookupIDByType (stuff->window, RT_WINDOW);
if (!pWin)
{
client->errorValue = stuff->window;
return BadWindow;
}
return compUnredirectSubwindows (client, pWin, stuff->update);
}
static int
ProcCompositeCreateRegionFromBorderClip (ClientPtr client)
{
WindowPtr pWin;
CompWindowPtr cw;
RegionPtr pBorderClip, pRegion;
REQUEST(xCompositeCreateRegionFromBorderClipReq);
REQUEST_SIZE_MATCH(xCompositeCreateRegionFromBorderClipReq);
pWin = (WindowPtr) LookupIDByType (stuff->window, RT_WINDOW);
if (!pWin)
{
client->errorValue = stuff->window;
return BadWindow;
}
LEGAL_NEW_RESOURCE (stuff->region, client);
cw = GetCompWindow (pWin);
if (cw)
pBorderClip = &cw->borderClip;
else
pBorderClip = &pWin->borderClip;
pRegion = XFixesRegionCopy (pBorderClip);
if (!pRegion)
return BadAlloc;
REGION_TRANSLATE (pScreen, pRegion, -pWin->drawable.x, -pWin->drawable.y);
if (!AddResource (stuff->region, RegionResType, (pointer) pRegion))
return BadAlloc;
return(client->noClientException);
}
static int
ProcCompositeNameWindowPixmap (ClientPtr client)
{
WindowPtr pWin;
CompWindowPtr cw;
PixmapPtr pPixmap;
REQUEST(xCompositeNameWindowPixmapReq);
REQUEST_SIZE_MATCH(xCompositeNameWindowPixmapReq);
pWin = (WindowPtr) LookupIDByType (stuff->window, RT_WINDOW);
if (!pWin)
{
client->errorValue = stuff->window;
return BadWindow;
}
LEGAL_NEW_RESOURCE (stuff->pixmap, client);
cw = GetCompWindow (pWin);
if (!cw)
return BadMatch;
pPixmap = (*pWin->drawable.pScreen->GetWindowPixmap) (pWin);
if (!pPixmap)
return BadMatch;
++pPixmap->refcnt;
if (!AddResource (stuff->pixmap, RT_PIXMAP, (pointer) pPixmap))
return BadAlloc;
return(client->noClientException);
}
int (*ProcCompositeVector[CompositeNumberRequests])(ClientPtr) = {
ProcCompositeQueryVersion,
ProcCompositeRedirectWindow,
ProcCompositeRedirectSubwindows,
ProcCompositeUnredirectWindow,
ProcCompositeUnredirectSubwindows,
ProcCompositeCreateRegionFromBorderClip,
ProcCompositeNameWindowPixmap,
};
static int
ProcCompositeDispatch (ClientPtr client)
{
REQUEST(xReq);
if (stuff->data < CompositeNumberRequests)
return (*ProcCompositeVector[stuff->data]) (client);
else
return BadRequest;
}
static int
SProcCompositeQueryVersion (ClientPtr client)
{
int n;
REQUEST(xCompositeQueryVersionReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xCompositeQueryVersionReq);
swapl(&stuff->majorVersion, n);
swapl(&stuff->minorVersion, n);
return (*ProcCompositeVector[stuff->compositeReqType]) (client);
}
static int
SProcCompositeRedirectWindow (ClientPtr client)
{
int n;
REQUEST(xCompositeRedirectWindowReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xCompositeRedirectWindowReq);
swapl (&stuff->window, n);
return (*ProcCompositeVector[stuff->compositeReqType]) (client);
}
static int
SProcCompositeRedirectSubwindows (ClientPtr client)
{
int n;
REQUEST(xCompositeRedirectSubwindowsReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xCompositeRedirectSubwindowsReq);
swapl (&stuff->window, n);
return (*ProcCompositeVector[stuff->compositeReqType]) (client);
}
static int
SProcCompositeUnredirectWindow (ClientPtr client)
{
int n;
REQUEST(xCompositeUnredirectWindowReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xCompositeUnredirectWindowReq);
swapl (&stuff->window, n);
return (*ProcCompositeVector[stuff->compositeReqType]) (client);
}
static int
SProcCompositeUnredirectSubwindows (ClientPtr client)
{
int n;
REQUEST(xCompositeUnredirectSubwindowsReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xCompositeUnredirectSubwindowsReq);
swapl (&stuff->window, n);
return (*ProcCompositeVector[stuff->compositeReqType]) (client);
}
static int
SProcCompositeCreateRegionFromBorderClip (ClientPtr client)
{
int n;
REQUEST(xCompositeCreateRegionFromBorderClipReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xCompositeCreateRegionFromBorderClipReq);
swapl (&stuff->region, n);
swapl (&stuff->window, n);
return (*ProcCompositeVector[stuff->compositeReqType]) (client);
}
static int
SProcCompositeNameWindowPixmap (ClientPtr client)
{
int n;
REQUEST(xCompositeNameWindowPixmapReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xCompositeNameWindowPixmapReq);
swapl (&stuff->window, n);
swapl (&stuff->pixmap, n);
return (*ProcCompositeVector[stuff->compositeReqType]) (client);
}
int (*SProcCompositeVector[CompositeNumberRequests])(ClientPtr) = {
SProcCompositeQueryVersion,
SProcCompositeRedirectWindow,
SProcCompositeRedirectSubwindows,
SProcCompositeUnredirectWindow,
SProcCompositeUnredirectSubwindows,
SProcCompositeCreateRegionFromBorderClip,
SProcCompositeNameWindowPixmap,
};
static int
SProcCompositeDispatch (ClientPtr client)
{
REQUEST(xReq);
if (stuff->data < CompositeNumberRequests)
return (*SProcCompositeVector[stuff->data]) (client);
else
return BadRequest;
}
void
CompositeExtensionInit (void)
{
ExtensionEntry *extEntry;
int s;
CompositeClientWindowType = CreateNewResourceType (FreeCompositeClientWindow);
if (!CompositeClientWindowType)
return;
CompositeClientSubwindowsType = CreateNewResourceType (FreeCompositeClientSubwindows);
if (!CompositeClientSubwindowsType)
return;
CompositeClientPrivateIndex = AllocateClientPrivateIndex ();
if (!AllocateClientPrivate (CompositeClientPrivateIndex,
sizeof (CompositeClientRec)))
return;
if (!AddCallback (&ClientStateCallback, CompositeClientCallback, 0))
return;
extEntry = AddExtension (COMPOSITE_NAME, 0, 0,
ProcCompositeDispatch, SProcCompositeDispatch,
CompositeResetProc, StandardMinorOpcode);
if (!extEntry)
return;
CompositeReqCode = (CARD8) extEntry->base;
for (s = 0; s < screenInfo.numScreens; s++)
if (!compScreenInit (screenInfo.screens[s]))
return;
miRegisterRedirectBorderClipProc (compSetRedirectBorderClip,
compGetRedirectBorderClip);
}

480
damageext/damageext.c Executable file
View file

@ -0,0 +1,480 @@
/*
* $Id$
*
* Copyright © 2002 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "damageextint.h"
unsigned char DamageReqCode;
int DamageEventBase;
int DamageErrorBase;
int DamageClientPrivateIndex;
RESTYPE DamageExtType;
RESTYPE DamageExtWinType;
#define prScreen screenInfo.screens[0]
static void
DamageExtNotify (DamageExtPtr pDamageExt, BoxPtr pBoxes, int nBoxes)
{
ClientPtr pClient = pDamageExt->pClient;
DamageClientPtr pDamageClient = GetDamageClient (pClient);
DrawablePtr pDrawable = pDamageExt->pDrawable;
xDamageNotifyEvent ev;
int i;
UpdateCurrentTimeIf ();
ev.type = DamageEventBase + XDamageNotify;
ev.level = pDamageExt->level;
ev.sequenceNumber = pClient->sequence;
ev.drawable = pDrawable->id;
ev.damage = pDamageExt->id;
ev.timestamp = currentTime.milliseconds;
ev.geometry.x = pDrawable->x;
ev.geometry.y = pDrawable->y;
ev.geometry.width = pDrawable->width;
ev.geometry.height = pDrawable->height;
if (pBoxes)
{
for (i = 0; i < nBoxes; i++)
{
ev.level = pDamageExt->level;
if (i < nBoxes - 1)
ev.level |= DamageNotifyMore;
ev.area.x = pBoxes[i].x1;
ev.area.y = pBoxes[i].y1;
ev.area.width = pBoxes[i].x2 - pBoxes[i].x1;
ev.area.height = pBoxes[i].y2 - pBoxes[i].y1;
if (!pClient->clientGone)
WriteEventsToClient (pClient, 1, (xEvent *) &ev);
}
}
else
{
ev.area.x = 0;
ev.area.y = 0;
ev.area.width = pDrawable->width;
ev.area.height = pDrawable->height;
if (!pClient->clientGone)
WriteEventsToClient (pClient, 1, (xEvent *) &ev);
}
/* Composite extension marks clients with manual Subwindows as critical */
if (pDamageClient->critical > 0)
{
SetCriticalOutputPending ();
#ifdef SMART_SCHEDULE
pClient->smart_priority = SMART_MAX_PRIORITY;
#endif
}
}
static void
DamageExtReport (DamagePtr pDamage, RegionPtr pRegion, void *closure)
{
DamageExtPtr pDamageExt = closure;
switch (pDamageExt->level) {
case DamageReportRawRegion:
case DamageReportDeltaRegion:
DamageExtNotify (pDamageExt, REGION_RECTS(pRegion), REGION_NUM_RECTS(pRegion));
break;
case DamageReportBoundingBox:
DamageExtNotify (pDamageExt, REGION_EXTENTS(prScreen, pRegion), 1);
break;
case DamageReportNonEmpty:
DamageExtNotify (pDamageExt, NullBox, 0);
break;
case DamageReportNone:
break;
}
}
static void
DamageExtDestroy (DamagePtr pDamage, void *closure)
{
DamageExtPtr pDamageExt = closure;
pDamageExt->pDamage = 0;
if (pDamageExt->id)
FreeResource (pDamageExt->id, RT_NONE);
}
void
DamageExtSetCritical (ClientPtr pClient, Bool critical)
{
DamageClientPtr pDamageClient = GetDamageClient (pClient);
if (pDamageClient)
pDamageClient->critical += critical ? 1 : -1;
}
static int
ProcDamageQueryVersion(ClientPtr client)
{
DamageClientPtr pDamageClient = GetDamageClient (client);
xDamageQueryVersionReply rep;
register int n;
REQUEST(xDamageQueryVersionReq);
REQUEST_SIZE_MATCH(xDamageQueryVersionReq);
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
if (stuff->majorVersion < DAMAGE_MAJOR) {
rep.majorVersion = stuff->majorVersion;
rep.minorVersion = stuff->minorVersion;
} else {
rep.majorVersion = DAMAGE_MAJOR;
if (stuff->majorVersion == DAMAGE_MAJOR &&
stuff->minorVersion < DAMAGE_MINOR)
rep.minorVersion = stuff->minorVersion;
else
rep.minorVersion = DAMAGE_MINOR;
}
pDamageClient->major_version = rep.majorVersion;
pDamageClient->minor_version = rep.minorVersion;
if (client->swapped) {
swaps(&rep.sequenceNumber, n);
swapl(&rep.length, n);
swapl(&rep.majorVersion, n);
swapl(&rep.minorVersion, n);
}
WriteToClient(client, sizeof(xDamageQueryVersionReply), (char *)&rep);
return(client->noClientException);
}
static int
ProcDamageCreate (ClientPtr client)
{
DrawablePtr pDrawable;
DamageExtPtr pDamageExt;
DamageReportLevel level;
RegionPtr pRegion;
REQUEST(xDamageCreateReq);
REQUEST_SIZE_MATCH(xDamageCreateReq);
LEGAL_NEW_RESOURCE(stuff->damage, client);
SECURITY_VERIFY_DRAWABLE (pDrawable, stuff->drawable, client,
SecurityReadAccess);
switch (stuff->level) {
case XDamageReportRawRectangles:
level = DamageReportRawRegion;
break;
case XDamageReportDeltaRectangles:
level = DamageReportDeltaRegion;
break;
case XDamageReportBoundingBox:
level = DamageReportBoundingBox;
break;
case XDamageReportNonEmpty:
level = DamageReportNonEmpty;
break;
default:
client->errorValue = stuff->level;
return BadValue;
}
pDamageExt = xalloc (sizeof (DamageExtRec));
if (!pDamageExt)
return BadAlloc;
pDamageExt->id = stuff->damage;
pDamageExt->pDrawable = pDrawable;
pDamageExt->level = level;
pDamageExt->pClient = client;
pDamageExt->pDamage = DamageCreate (DamageExtReport,
DamageExtDestroy,
level,
FALSE,
pDrawable->pScreen,
pDamageExt);
if (!pDamageExt->pDamage)
{
xfree (pDamageExt);
return BadAlloc;
}
if (!AddResource (stuff->damage, DamageExtType, (pointer) pDamageExt))
return BadAlloc;
DamageRegister (pDamageExt->pDrawable, pDamageExt->pDamage);
if (pDrawable->type == DRAWABLE_WINDOW)
{
pRegion = &((WindowPtr) pDrawable)->borderClip;
DamageDamageRegion (pDrawable, pRegion);
}
return (client->noClientException);
}
static int
ProcDamageDestroy (ClientPtr client)
{
REQUEST(xDamageDestroyReq);
DamageExtPtr pDamageExt;
REQUEST_SIZE_MATCH(xDamageDestroyReq);
VERIFY_DAMAGEEXT(pDamageExt, stuff->damage, client, SecurityWriteAccess);
FreeResource (stuff->damage, RT_NONE);
return (client->noClientException);
}
static int
ProcDamageSubtract (ClientPtr client)
{
REQUEST(xDamageSubtractReq);
DamageExtPtr pDamageExt;
RegionPtr pRepair;
RegionPtr pParts;
REQUEST_SIZE_MATCH(xDamageSubtractReq);
VERIFY_DAMAGEEXT(pDamageExt, stuff->damage, client, SecurityWriteAccess);
VERIFY_REGION_OR_NONE(pRepair, stuff->repair, client, SecurityWriteAccess);
VERIFY_REGION_OR_NONE(pParts, stuff->parts, client, SecurityWriteAccess);
if (pDamageExt->level != DamageReportRawRegion)
{
DamagePtr pDamage = pDamageExt->pDamage;
if (pRepair)
{
if (pParts)
REGION_INTERSECT (prScreen, pParts, DamageRegion (pDamage), pRepair);
if (DamageSubtract (pDamage, pRepair))
DamageExtReport (pDamage, DamageRegion (pDamage), (void *) pDamageExt);
}
else
{
if (pParts)
REGION_COPY (prScreen, pParts, DamageRegion (pDamage));
DamageEmpty (pDamage);
}
}
return (client->noClientException);
}
/* Major version controls available requests */
static const int version_requests[] = {
X_DamageQueryVersion, /* before client sends QueryVersion */
X_DamageSubtract, /* Version 1 */
};
#define NUM_VERSION_REQUESTS (sizeof (version_requests) / sizeof (version_requests[0]))
int (*ProcDamageVector[XDamageNumberRequests])(ClientPtr) = {
/*************** Version 1 ******************/
ProcDamageQueryVersion,
ProcDamageCreate,
ProcDamageDestroy,
ProcDamageSubtract,
};
static int
ProcDamageDispatch (ClientPtr client)
{
REQUEST(xDamageReq);
DamageClientPtr pDamageClient = GetDamageClient (client);
if (pDamageClient->major_version > NUM_VERSION_REQUESTS)
return BadRequest;
if (stuff->damageReqType > version_requests[pDamageClient->major_version])
return BadRequest;
return (*ProcDamageVector[stuff->damageReqType]) (client);
}
static int
SProcDamageQueryVersion(ClientPtr client)
{
register int n;
REQUEST(xDamageQueryVersionReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xDamageQueryVersionReq);
swapl(&stuff->majorVersion, n);
swapl(&stuff->minorVersion, n);
return (*ProcDamageVector[stuff->damageReqType]) (client);
}
static int
SProcDamageCreate (ClientPtr client)
{
register int n;
REQUEST(xDamageCreateReq);
swaps (&stuff->length, n);
REQUEST_SIZE_MATCH(xDamageCreateReq);
swapl (&stuff->damage, n);
swapl (&stuff->drawable, n);
return (*ProcDamageVector[stuff->damageReqType]) (client);
}
static int
SProcDamageDestroy (ClientPtr client)
{
register int n;
REQUEST(xDamageDestroyReq);
swaps (&stuff->length, n);
REQUEST_SIZE_MATCH(xDamageDestroyReq);
swapl (&stuff->damage, n);
return (*ProcDamageVector[stuff->damageReqType]) (client);
}
static int
SProcDamageSubtract (ClientPtr client)
{
register int n;
REQUEST(xDamageSubtractReq);
swaps (&stuff->length, n);
REQUEST_SIZE_MATCH(xDamageSubtractReq);
swapl (&stuff->damage, n);
swapl (&stuff->repair, n);
swapl (&stuff->parts, n);
return (*ProcDamageVector[stuff->damageReqType]) (client);
}
int (*SProcDamageVector[XDamageNumberRequests])(ClientPtr) = {
/*************** Version 1 ******************/
SProcDamageQueryVersion,
SProcDamageCreate,
SProcDamageDestroy,
SProcDamageSubtract,
};
static int
SProcDamageDispatch (ClientPtr client)
{
REQUEST(xDamageReq);
if (stuff->damageReqType >= XDamageNumberRequests)
return BadRequest;
return (*SProcDamageVector[stuff->damageReqType]) (client);
}
static void
DamageClientCallback (CallbackListPtr *list,
pointer closure,
pointer data)
{
NewClientInfoRec *clientinfo = (NewClientInfoRec *) data;
ClientPtr pClient = clientinfo->client;
DamageClientPtr pDamageClient = GetDamageClient (pClient);
pDamageClient->critical = 0;
pDamageClient->major_version = 0;
pDamageClient->minor_version = 0;
}
/*ARGSUSED*/
static void
DamageResetProc (ExtensionEntry *extEntry)
{
DeleteCallback (&ClientStateCallback, DamageClientCallback, 0);
}
static int
FreeDamageExt (pointer value, XID did)
{
DamageExtPtr pDamageExt = (DamageExtPtr) value;
/*
* Get rid of the resource table entry hanging from the window id
*/
pDamageExt->id = 0;
if (WindowDrawable(pDamageExt->pDrawable->type))
FreeResourceByType (pDamageExt->pDrawable->id, DamageExtWinType, TRUE);
if (pDamageExt->pDamage)
{
DamageUnregister (pDamageExt->pDrawable, pDamageExt->pDamage);
DamageDestroy (pDamageExt->pDamage);
}
xfree (pDamageExt);
return Success;
}
static int
FreeDamageExtWin (pointer value, XID wid)
{
DamageExtPtr pDamageExt = (DamageExtPtr) value;
if (pDamageExt->id)
FreeResource (pDamageExt->id, RT_NONE);
return Success;
}
void
SDamageNotifyEvent (xDamageNotifyEvent *from,
xDamageNotifyEvent *to)
{
to->type = from->type;
cpswaps (from->sequenceNumber, to->sequenceNumber);
cpswapl (from->drawable, to->drawable);
cpswapl (from->damage, to->damage);
cpswaps (from->area.x, to->area.x);
cpswaps (from->area.y, to->area.y);
cpswaps (from->area.width, to->area.width);
cpswaps (from->area.height, to->area.height);
cpswaps (from->geometry.x, to->geometry.x);
cpswaps (from->geometry.y, to->geometry.y);
cpswaps (from->geometry.width, to->geometry.width);
cpswaps (from->geometry.height, to->geometry.height);
}
void
DamageExtensionInit(void)
{
ExtensionEntry *extEntry;
int s;
for (s = 0; s < screenInfo.numScreens; s++)
DamageSetup (screenInfo.screens[s]);
DamageExtType = CreateNewResourceType (FreeDamageExt);
if (!DamageExtType)
return;
DamageExtWinType = CreateNewResourceType (FreeDamageExtWin);
if (!DamageExtWinType)
return;
DamageClientPrivateIndex = AllocateClientPrivateIndex ();
if (!AllocateClientPrivate (DamageClientPrivateIndex,
sizeof (DamageClientRec)))
return;
if (!AddCallback (&ClientStateCallback, DamageClientCallback, 0))
return;
if ((extEntry = AddExtension(DAMAGE_NAME, XDamageNumberEvents,
XDamageNumberErrors,
ProcDamageDispatch, SProcDamageDispatch,
DamageResetProc, StandardMinorOpcode)) != 0)
{
DamageReqCode = (unsigned char)extEntry->base;
DamageEventBase = extEntry->eventBase;
DamageErrorBase = extEntry->errorBase;
EventSwapVector[DamageEventBase + XDamageNotify] =
(EventSwapPtr) SDamageNotifyEvent;
}
}

31
damageext/damageext.h Normal file
View file

@ -0,0 +1,31 @@
/*
* $Id$
*
* Copyright © 2002 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _DAMAGEEXT_H_
#define _DAMAGEEXT_H_
void
DamageExtensionInit(void);
#endif /* _DAMAGEEXT_H_ */

84
damageext/damageextint.h Normal file
View file

@ -0,0 +1,84 @@
/*
* $Id$
*
* Copyright © 2002 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _DAMAGEEXTINT_H_
#define _DAMAGEEXTINT_H_
#define NEED_EVENTS
#include <X11/X.h>
#include <X11/Xproto.h>
#include "misc.h"
#include "os.h"
#include "dixstruct.h"
#include "extnsionst.h"
#include <X11/extensions/damageproto.h>
#include "windowstr.h"
#include "selection.h"
#include "scrnintstr.h"
#include "damageext.h"
#include "damage.h"
#include "xfixes.h"
extern unsigned char DamageReqCode;
extern int DamageEventBase;
extern int DamageErrorBase;
extern int DamageClientPrivateIndex;
extern RESTYPE DamageExtType;
extern RESTYPE DamageExtWinType;
typedef struct _DamageClient {
CARD32 major_version;
CARD32 minor_version;
int critical;
} DamageClientRec, *DamageClientPtr;
#define GetDamageClient(pClient) ((DamageClientPtr) (pClient)->devPrivates[DamageClientPrivateIndex].ptr)
typedef struct _DamageExt {
DamagePtr pDamage;
DrawablePtr pDrawable;
DamageReportLevel level;
ClientPtr pClient;
XID id;
} DamageExtRec, *DamageExtPtr;
extern int (*ProcDamageVector[/*XDamageNumberRequests*/])(ClientPtr);
extern int (*SProcDamageVector[/*XDamageNumberRequests*/])(ClientPtr);
#define VERIFY_DAMAGEEXT(pDamageExt, rid, client, mode) { \
pDamageExt = SecurityLookupIDByType (client, rid, DamageExtType, mode); \
if (!pDamageExt) { \
client->errorValue = rid; \
return DamageErrorBase + BadDamage; \
} \
}
void
SDamageNotifyEvent (xDamageNotifyEvent *from,
xDamageNotifyEvent *to);
void
DamageExtSetCritical (ClientPtr pClient, Bool critical);
#endif /* _DAMAGEEXTINT_H_ */

1514
fb/fbmmx.c Normal file

File diff suppressed because it is too large Load diff

160
fb/fbmmx.h Normal file
View file

@ -0,0 +1,160 @@
/*
* Copyright © 2004 Red Hat, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Red Hat not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. Red Hat makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL RED HAT
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Author: Søren Sandmann (sandmann@redhat.com)
*
* Based on work by Owen Taylor
*/
#ifdef USE_GCC34_MMX
Bool fbHaveMMX(void);
#else
#define fbHaveMMX FALSE
#endif
#ifdef USE_GCC34_MMX
void fbCompositeSolidMask_nx8888x0565Cmmx (CARD8 op,
PicturePtr pSrc,
PicturePtr pMask,
PicturePtr pDst,
INT16 xSrc,
INT16 ySrc,
INT16 xMask,
INT16 yMask,
INT16 xDst,
INT16 yDst,
CARD16 width,
CARD16 height);
void fbCompositeSrcAdd_8888x8888mmx (CARD8 op,
PicturePtr pSrc,
PicturePtr pMask,
PicturePtr pDst,
INT16 xSrc,
INT16 ySrc,
INT16 xMask,
INT16 yMask,
INT16 xDst,
INT16 yDst,
CARD16 width,
CARD16 height);
void fbCompositeSolidMask_nx8888x8888Cmmx (CARD8 op,
PicturePtr pSrc,
PicturePtr pMask,
PicturePtr pDst,
INT16 xSrc,
INT16 ySrc,
INT16 xMask,
INT16 yMask,
INT16 xDst,
INT16 yDst,
CARD16 width,
CARD16 height);
void fbCompositeSolidMask_nx8x8888mmx (CARD8 op,
PicturePtr pSrc,
PicturePtr pMask,
PicturePtr pDst,
INT16 xSrc,
INT16 ySrc,
INT16 xMask,
INT16 yMask,
INT16 xDst,
INT16 yDst,
CARD16 width,
CARD16 height);
void fbCompositeSrcAdd_8000x8000mmx (CARD8 op,
PicturePtr pSrc,
PicturePtr pMask,
PicturePtr pDst,
INT16 xSrc,
INT16 ySrc,
INT16 xMask,
INT16 yMask,
INT16 xDst,
INT16 yDst,
CARD16 width,
CARD16 height);
void fbCompositeSrc_8888RevNPx8888mmx (CARD8 op,
PicturePtr pSrc,
PicturePtr pMask,
PicturePtr pDst,
INT16 xSrc,
INT16 ySrc,
INT16 xMask,
INT16 yMask,
INT16 xDst,
INT16 yDst,
CARD16 width,
CARD16 height);
void fbCompositeSrc_8888RevNPx0565mmx (CARD8 op,
PicturePtr pSrc,
PicturePtr pMask,
PicturePtr pDst,
INT16 xSrc,
INT16 ySrc,
INT16 xMask,
INT16 yMask,
INT16 xDst,
INT16 yDst,
CARD16 width,
CARD16 height);
void fbCompositeSolid_nx8888mmx (CARD8 op,
PicturePtr pSrc,
PicturePtr pMask,
PicturePtr pDst,
INT16 xSrc,
INT16 ySrc,
INT16 xMask,
INT16 yMask,
INT16 xDst,
INT16 yDst,
CARD16 width,
CARD16 height);
void fbCompositeSolid_nx0565mmx (CARD8 op,
PicturePtr pSrc,
PicturePtr pMask,
PicturePtr pDst,
INT16 xSrc,
INT16 ySrc,
INT16 xMask,
INT16 yMask,
INT16 xDst,
INT16 yDst,
CARD16 width,
CARD16 height);
void fbCompositeSolidMask_nx8x0565mmx (CARD8 op,
PicturePtr pSrc,
PicturePtr pMask,
PicturePtr pDst,
INT16 xSrc,
INT16 ySrc,
INT16 xMask,
INT16 yMask,
INT16 xDst,
INT16 yDst,
CARD16 width,
CARD16 height);
Bool fbSolidFillmmx (DrawablePtr pDraw,
int x,
int y,
int width,
int height,
FbBits xor);
#endif /* USE_GCC34_MMX */

2330
fb/fbpseudocolor.c Normal file

File diff suppressed because it is too large Load diff

20
fb/fbpseudocolor.h Normal file
View file

@ -0,0 +1,20 @@
#ifndef _FB_XX_H_
# define _FB_XX_H_
typedef void (*xxSyncFunc)(ScreenPtr);
extern Bool xxSetup(ScreenPtr pScreen, int myDepth,
int baseDepth, char *addr, xxSyncFunc sync);
extern void xxPrintVisuals(void);
#endif /* _FB_XX_H_ */

310
hw/darwin/darwinXinput.c Normal file
View file

@ -0,0 +1,310 @@
/* $Xorg: stubs.c,v 1.4 2001/02/09 02:04:35 xorgcvs Exp $ */
/*
* X server support of the XINPUT extension for Darwin
*
* This is currently a copy of mi/stubs.c, but eventually this
* should include more complete XINPUT support.
*/
/************************************************************
Copyright 1989, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice 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 NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP 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.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of Hewlett-Packard not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
********************************************************/
/* $XFree86: xc/programs/Xserver/hw/darwin/darwinXinput.c,v 1.1 2004/05/28 07:44:00 torrey Exp $ */
#define NEED_EVENTS
#include "X.h"
#include "Xproto.h"
#include "inputstr.h"
#include "XI.h"
#include "XIproto.h"
#include "XIstubs.h"
/***********************************************************************
*
* Caller: ProcXChangeKeyboardDevice
*
* This procedure does the implementation-dependent portion of the work
* needed to change the keyboard device.
*
* The X keyboard device has a FocusRec. If the device that has been
* made into the new X keyboard did not have a FocusRec,
* ProcXChangeKeyboardDevice will allocate one for it.
*
* If you do not want clients to be able to focus the old X keyboard
* device, call DeleteFocusClassDeviceStruct to free the FocusRec.
*
* If you support input devices with keys that you do not want to be
* used as the X keyboard, you need to check for them here and return
* a BadDevice error.
*
* The default implementation is to do nothing (assume you do want
* clients to be able to focus the old X keyboard). The commented-out
* sample code shows what you might do if you don't want the default.
*
*/
int
ChangeKeyboardDevice (old_dev, new_dev)
DeviceIntPtr old_dev;
DeviceIntPtr new_dev;
{
/***********************************************************************
DeleteFocusClassDeviceStruct(old_dev); * defined in xchgptr.c *
**********************************************************************/
return BadMatch;
}
/***********************************************************************
*
* Caller: ProcXChangePointerDevice
*
* This procedure does the implementation-dependent portion of the work
* needed to change the pointer device.
*
* The X pointer device does not have a FocusRec. If the device that
* has been made into the new X pointer had a FocusRec,
* ProcXChangePointerDevice will free it.
*
* If you want clients to be able to focus the old pointer device that
* has now become accessible through the input extension, you need to
* add a FocusRec to it here.
*
* The XChangePointerDevice protocol request also allows the client
* to choose which axes of the new pointer device are used to move
* the X cursor in the X- and Y- directions. If the axes are different
* than the default ones, you need to keep track of that here.
*
* If you support input devices with valuators that you do not want to be
* used as the X pointer, you need to check for them here and return a
* BadDevice error.
*
* The default implementation is to do nothing (assume you don't want
* clients to be able to focus the old X pointer). The commented-out
* sample code shows what you might do if you don't want the default.
*
*/
int
ChangePointerDevice (
DeviceIntPtr old_dev,
DeviceIntPtr new_dev,
unsigned char x,
unsigned char y)
{
/***********************************************************************
InitFocusClassDeviceStruct(old_dev); * allow focusing old ptr*
x_axis = x; * keep track of new x-axis*
y_axis = y; * keep track of new y-axis*
if (x_axis != 0 || y_axis != 1)
axes_changed = TRUE; * remember axes have changed*
else
axes_changed = FALSE;
*************************************************************************/
return BadMatch;
}
/***********************************************************************
*
* Caller: ProcXCloseDevice
*
* Take care of implementation-dependent details of closing a device.
* Some implementations may actually close the device, others may just
* remove this clients interest in that device.
*
* The default implementation is to do nothing (assume all input devices
* are initialized during X server initialization and kept open).
*
*/
void
CloseInputDevice (d, client)
DeviceIntPtr d;
ClientPtr client;
{
}
/***********************************************************************
*
* Caller: ProcXListInputDevices
*
* This is the implementation-dependent routine to initialize an input
* device to the point that information about it can be listed.
* Some implementations open all input devices when the server is first
* initialized, and never close them. Other implementations open only
* the X pointer and keyboard devices during server initialization,
* and only open other input devices when some client makes an
* XOpenDevice request. If some other process has the device open, the
* server may not be able to get information about the device to list it.
*
* This procedure should be used by implementations that do not initialize
* all input devices at server startup. It should do device-dependent
* initialization for any devices not previously initialized, and call
* AddInputDevice for each of those devices so that a DeviceIntRec will be
* created for them.
*
* The default implementation is to do nothing (assume all input devices
* are initialized during X server initialization and kept open).
* The commented-out sample code shows what you might do if you don't want
* the default.
*
*/
void
AddOtherInputDevices ()
{
/**********************************************************************
for each uninitialized device, do something like:
DeviceIntPtr dev;
DeviceProc deviceProc;
pointer private;
dev = (DeviceIntPtr) AddInputDevice(deviceProc, TRUE);
dev->public.devicePrivate = private;
RegisterOtherDevice(dev);
dev->inited = ((*dev->deviceProc)(dev, DEVICE_INIT) == Success);
************************************************************************/
}
/***********************************************************************
*
* Caller: ProcXOpenDevice
*
* This is the implementation-dependent routine to open an input device.
* Some implementations open all input devices when the server is first
* initialized, and never close them. Other implementations open only
* the X pointer and keyboard devices during server initialization,
* and only open other input devices when some client makes an
* XOpenDevice request. This entry point is for the latter type of
* implementation.
*
* If the physical device is not already open, do it here. In this case,
* you need to keep track of the fact that one or more clients has the
* device open, and physically close it when the last client that has
* it open does an XCloseDevice.
*
* The default implementation is to do nothing (assume all input devices
* are opened during X server initialization and kept open).
*
*/
void
OpenInputDevice (dev, client, status)
DeviceIntPtr dev;
ClientPtr client;
int *status;
{
}
/****************************************************************************
*
* Caller: ProcXSetDeviceMode
*
* Change the mode of an extension device.
* This function is used to change the mode of a device from reporting
* relative motion to reporting absolute positional information, and
* vice versa.
* The default implementation below is that no such devices are supported.
*
*/
int
SetDeviceMode (client, dev, mode)
register ClientPtr client;
DeviceIntPtr dev;
int mode;
{
return BadMatch;
}
/****************************************************************************
*
* Caller: ProcXSetDeviceValuators
*
* Set the value of valuators on an extension input device.
* This function is used to set the initial value of valuators on
* those input devices that are capable of reporting either relative
* motion or an absolute position, and allow an initial position to be set.
* The default implementation below is that no such devices are supported.
*
*/
int
SetDeviceValuators (client, dev, valuators, first_valuator, num_valuators)
register ClientPtr client;
DeviceIntPtr dev;
int *valuators;
int first_valuator;
int num_valuators;
{
return BadMatch;
}
/****************************************************************************
*
* Caller: ProcXChangeDeviceControl
*
* Change the specified device controls on an extension input device.
*
*/
int
ChangeDeviceControl (client, dev, control)
register ClientPtr client;
DeviceIntPtr dev;
xDeviceCtl *control;
{
switch (control->control)
{
case DEVICE_RESOLUTION:
return (BadMatch);
default:
return (BadMatch);
}
}

374
hw/dmx/dmx.h Normal file
View file

@ -0,0 +1,374 @@
/* $XFree86$ */
/*
* 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
#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
typedef enum {
PosNone = -1,
PosAbsolute = 0,
PosRightOf,
PosLeftOf,
PosAbove,
PosBelow,
PosRelative
} PositionType;
/** Provide the typedef globally, but keep the contents opaque outside
* of the input routines. \see dmxinput.h */
typedef struct _DMXInputInfo DMXInputInfo;
/** Provide the typedef globally, but keep the contents opaque outside
* of the XSync statistic routines. \see dmxstat.c */
typedef struct _DMXStatInfo DMXStatInfo;
/** Global structure containing information about each backend screen. */
typedef struct _DMXScreenInfo {
const char *name; /**< Name from command line or config file */
int index; /**< Index into dmxScreens global */
/*---------- Back-end X server information ----------*/
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 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 */
/*---------- Screen window information ----------*/
Window scrnWin; /**< "Screen" window on backend display */
int scrnX; /**< X offset of "screen" WRT BE display */
int scrnY; /**< Y offset of "screen" WRT BE display */
int scrnWidth; /**< Width of "screen" */
int scrnHeight; /**< Height of "screen" */
int scrnXSign; /**< X offset sign of "screen" */
int scrnYSign; /**< Y offset sign 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 rootWidth; /**< Width of "root" window */
int rootHeight; /**< Height of "root" window */
int rootXOrigin; /**< Global X origin of "root" window */
int rootYOrigin; /**< Global Y origin of "root" window */
/*---------- Shadow framebuffer information ----------*/
void *shadow; /**< Shadow framebuffer data (if enabled) */
XlibGC shadowGC; /**< Default GC used by shadow FB code */
XImage *shadowFBImage; /**< Screen image used by shadow FB code */
/*---------- Other related information ----------*/
int shared; /**< Non-zero if another Xdmx is running */
Bool WMRunningOnBE;
Cursor noCursor;
Cursor curCursor;
/* Support for cursors on overlapped
* backend displays. */
CursorPtr cursor;
int cursorVisible;
int cursorNotShared; /* for overlapping screens on a backend */
PositionType where; /**< Relative layout information */
int whereX; /**< Relative layout information */
int whereY; /**< Relative layout information */
int whereRefScreen; /**< Relative layout information */
int savedTimeout; /**< Original screen saver timeout */
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 */
#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;
PaintWindowBackgroundProcPtr PaintWindowBackground;
PaintWindowBorderProcPtr PaintWindowBorder;
CopyWindowProcPtr CopyWindow;
ResizeWindowProcPtr ResizeWindow;
ReparentWindowProcPtr ReparentWindow;
ChangeBorderWidthProcPtr ChangeBorderWidth;
GetImageProcPtr GetImage;
GetSpansProcPtr GetSpans;
CreatePixmapProcPtr CreatePixmap;
DestroyPixmapProcPtr DestroyPixmap;
BitmapToRegionProcPtr BitmapToRegion;
RealizeFontProcPtr RealizeFont;
UnrealizeFontProcPtr UnrealizeFont;
CreateColormapProcPtr CreateColormap;
DestroyColormapProcPtr DestroyColormap;
InstallColormapProcPtr InstallColormap;
StoreColorsProcPtr StoreColors;
#ifdef SHAPE
SetShapeProcPtr SetShape;
#endif
#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;
#endif
} DMXScreenInfo;
/* Global variables available to all Xserver/hw/dmx routines. */
extern int dmxNumScreens; /**< Number of dmxScreens */
extern DMXScreenInfo *dmxScreens; /**< List of outputs */
extern int dmxShadowFB; /**< Non-zero if using
* shadow frame-buffer
* (deprecated) */
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 */
/** 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 = xalloc((size) * sizeof(*(o))); \
if (o) memset(o, 0, (size) * sizeof(*(o))); \
if (!o && fatal) FatalError(MAXSCREEN_FAILED_TXT #o); \
} \
} while (0)
#define _MAXSCREENSALLOCR(o,size,retval) \
do { \
if (!o) { \
o = xalloc((size) * sizeof(*(o))); \
if (o) memset(o, 0, (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
#endif /* DMX_H */

1493
hw/dmx/dmxextension.c Normal file

File diff suppressed because it is too large Load diff

1058
hw/dmx/dmxinit.c Normal file

File diff suppressed because it is too large Load diff

1081
hw/dmx/dmxwindow.c Normal file

File diff suppressed because it is too large Load diff

1019
hw/dmx/input/dmxconsole.c Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,636 @@
/**
* \file xf86drm.h
* OS-independent header for DRM user-level library interface.
*
* \author Rickard E. (Rik) Faith <faith@valinux.com>
*/
/*
* Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* 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
* 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 NONINFRINGEMENT. IN NO EVENT SHALL
* PRECISION INSIGHT AND/OR ITS 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.
*
*/
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86drm.h,v 1.26 2003/08/16 19:26:37 dawes Exp $ */
#ifndef _XF86DRM_H_
#define _XF86DRM_H_
#include <drm.h>
/* Defaults, if nothing set in xf86config */
#define DRM_DEV_UID 0
#define DRM_DEV_GID 0
/* Default /dev/dri directory permissions 0755 */
#define DRM_DEV_DIRMODE \
(S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH)
#define DRM_DEV_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)
#define DRM_DIR_NAME "/dev/dri"
#define DRM_DEV_NAME "%s/card%d"
#define DRM_PROC_NAME "/proc/dri/" /* For backward Linux compatibility */
#define DRM_ERR_NO_DEVICE (-1001)
#define DRM_ERR_NO_ACCESS (-1002)
#define DRM_ERR_NOT_ROOT (-1003)
#define DRM_ERR_INVALID (-1004)
#define DRM_ERR_NO_FD (-1005)
#define DRM_AGP_NO_HANDLE 0
typedef unsigned int drmSize, *drmSizePtr; /**< For mapped regions */
typedef void *drmAddress, **drmAddressPtr; /**< For mapped regions */
/**
* Driver version information.
*
* \sa drmGetVersion() and drmSetVersion().
*/
typedef struct _drmVersion {
int version_major; /**< Major version */
int version_minor; /**< Minor version */
int version_patchlevel; /**< Patch level */
int name_len; /**< Length of name buffer */
char *name; /**< Name of driver */
int date_len; /**< Length of date buffer */
char *date; /**< User-space buffer to hold date */
int desc_len; /**< Length of desc buffer */
char *desc; /**< User-space buffer to hold desc */
} drmVersion, *drmVersionPtr;
typedef struct _drmStats {
unsigned long count; /**< Number of data */
struct {
unsigned long value; /**< Value from kernel */
const char *long_format; /**< Suggested format for long_name */
const char *long_name; /**< Long name for value */
const char *rate_format; /**< Suggested format for rate_name */
const char *rate_name; /**< Short name for value per second */
int isvalue; /**< True if value (vs. counter) */
const char *mult_names; /**< Multiplier names (e.g., "KGM") */
int mult; /**< Multiplier value (e.g., 1024) */
int verbose; /**< Suggest only in verbose output */
} data[15];
} drmStatsT;
/* All of these enums *MUST* match with the
kernel implementation -- so do *NOT*
change them! (The drmlib implementation
will just copy the flags instead of
translating them.) */
typedef enum {
DRM_FRAME_BUFFER = 0, /**< WC, no caching, no core dump */
DRM_REGISTERS = 1, /**< no caching, no core dump */
DRM_SHM = 2, /**< shared, cached */
DRM_AGP = 3, /**< AGP/GART */
DRM_SCATTER_GATHER = 4 /**< PCI scatter/gather */
} drmMapType;
typedef enum {
DRM_RESTRICTED = 0x0001, /**< Cannot be mapped to client-virtual */
DRM_READ_ONLY = 0x0002, /**< Read-only in client-virtual */
DRM_LOCKED = 0x0004, /**< Physical pages locked */
DRM_KERNEL = 0x0008, /**< Kernel requires access */
DRM_WRITE_COMBINING = 0x0010, /**< Use write-combining, if available */
DRM_CONTAINS_LOCK = 0x0020, /**< SHM page that contains lock */
DRM_REMOVABLE = 0x0040 /**< Removable mapping */
} drmMapFlags;
/**
* \warning These values *MUST* match drm.h
*/
typedef enum {
/** \name Flags for DMA buffer dispatch */
/*@{*/
DRM_DMA_BLOCK = 0x01, /**<
* Block until buffer dispatched.
*
* \note the buffer may not yet have been
* processed by the hardware -- getting a
* hardware lock with the hardware quiescent
* will ensure that the buffer has been
* processed.
*/
DRM_DMA_WHILE_LOCKED = 0x02, /**< Dispatch while lock held */
DRM_DMA_PRIORITY = 0x04, /**< High priority dispatch */
/*@}*/
/** \name Flags for DMA buffer request */
/*@{*/
DRM_DMA_WAIT = 0x10, /**< Wait for free buffers */
DRM_DMA_SMALLER_OK = 0x20, /**< Smaller-than-requested buffers OK */
DRM_DMA_LARGER_OK = 0x40 /**< Larger-than-requested buffers OK */
/*@}*/
} drmDMAFlags;
typedef enum {
DRM_PAGE_ALIGN = 0x01,
DRM_AGP_BUFFER = 0x02,
DRM_SG_BUFFER = 0x04
} drmBufDescFlags;
typedef enum {
DRM_LOCK_READY = 0x01, /**< Wait until hardware is ready for DMA */
DRM_LOCK_QUIESCENT = 0x02, /**< Wait until hardware quiescent */
DRM_LOCK_FLUSH = 0x04, /**< Flush this context's DMA queue first */
DRM_LOCK_FLUSH_ALL = 0x08, /**< Flush all DMA queues first */
/* These *HALT* flags aren't supported yet
-- they will be used to support the
full-screen DGA-like mode. */
DRM_HALT_ALL_QUEUES = 0x10, /**< Halt all current and future queues */
DRM_HALT_CUR_QUEUES = 0x20 /**< Halt all current queues */
} drmLockFlags;
typedef enum {
DRM_CONTEXT_PRESERVED = 0x01, /**< This context is preserved and
never swapped. */
DRM_CONTEXT_2DONLY = 0x02 /**< This context is for 2D rendering only. */
} drm_context_tFlags, *drm_context_tFlagsPtr;
typedef struct _drmBufDesc {
int count; /**< Number of buffers of this size */
int size; /**< Size in bytes */
int low_mark; /**< Low water mark */
int high_mark; /**< High water mark */
} drmBufDesc, *drmBufDescPtr;
typedef struct _drmBufInfo {
int count; /**< Number of buffers described in list */
drmBufDescPtr list; /**< List of buffer descriptions */
} drmBufInfo, *drmBufInfoPtr;
typedef struct _drmBuf {
int idx; /**< Index into the master buffer list */
int total; /**< Buffer size */
int used; /**< Amount of buffer in use (for DMA) */
drmAddress address; /**< Address */
} drmBuf, *drmBufPtr;
/**
* Buffer mapping information.
*
* Used by drmMapBufs() and drmUnmapBufs() to store information about the
* mapped buffers.
*/
typedef struct _drmBufMap {
int count; /**< Number of buffers mapped */
drmBufPtr list; /**< Buffers */
} drmBufMap, *drmBufMapPtr;
typedef struct _drmLock {
volatile unsigned int lock;
char padding[60];
/* This is big enough for most current (and future?) architectures:
DEC Alpha: 32 bytes
Intel Merced: ?
Intel P5/PPro/PII/PIII: 32 bytes
Intel StrongARM: 32 bytes
Intel i386/i486: 16 bytes
MIPS: 32 bytes (?)
Motorola 68k: 16 bytes
Motorola PowerPC: 32 bytes
Sun SPARC: 32 bytes
*/
} drmLock, *drmLockPtr;
/**
* Indices here refer to the offset into
* list in drmBufInfo
*/
typedef struct _drmDMAReq {
drm_context_t context; /**< Context handle */
int send_count; /**< Number of buffers to send */
int *send_list; /**< List of handles to buffers */
int *send_sizes; /**< Lengths of data to send, in bytes */
drmDMAFlags flags; /**< Flags */
int request_count; /**< Number of buffers requested */
int request_size; /**< Desired size of buffers requested */
int *request_list; /**< Buffer information */
int *request_sizes; /**< Minimum acceptable sizes */
int granted_count; /**< Number of buffers granted at this size */
} drmDMAReq, *drmDMAReqPtr;
typedef struct _drmRegion {
drm_handle_t handle;
unsigned int offset;
drmSize size;
drmAddress map;
} drmRegion, *drmRegionPtr;
typedef struct _drmTextureRegion {
unsigned char next;
unsigned char prev;
unsigned char in_use;
unsigned char padding; /**< Explicitly pad this out */
unsigned int age;
} drmTextureRegion, *drmTextureRegionPtr;
typedef enum {
DRM_VBLANK_ABSOLUTE = 0x0, /**< Wait for specific vblank sequence number */
DRM_VBLANK_RELATIVE = 0x1, /**< Wait for given number of vblanks */
DRM_VBLANK_SIGNAL = 0x40000000 /* Send signal instead of blocking */
} drmVBlankSeqType;
typedef struct _drmVBlankReq {
drmVBlankSeqType type;
unsigned int sequence;
unsigned long signal;
} drmVBlankReq, *drmVBlankReqPtr;
typedef struct _drmVBlankReply {
drmVBlankSeqType type;
unsigned int sequence;
long tval_sec;
long tval_usec;
} drmVBlankReply, *drmVBlankReplyPtr;
typedef union _drmVBlank {
drmVBlankReq request;
drmVBlankReply reply;
} drmVBlank, *drmVBlankPtr;
typedef struct _drmSetVersion {
int drm_di_major;
int drm_di_minor;
int drm_dd_major;
int drm_dd_minor;
} drmSetVersion, *drmSetVersionPtr;
#define __drm_dummy_lock(lock) (*(__volatile__ unsigned int *)lock)
#define DRM_LOCK_HELD 0x80000000 /**< Hardware lock is held */
#define DRM_LOCK_CONT 0x40000000 /**< Hardware lock is contended */
#if defined(__GNUC__) && (__GNUC__ >= 2)
# if defined(__i386) || defined(__AMD64__)
/* Reflect changes here to drmP.h */
#define DRM_CAS(lock,old,new,__ret) \
do { \
int __dummy; /* Can't mark eax as clobbered */ \
__asm__ __volatile__( \
"lock ; cmpxchg %4,%1\n\t" \
"setnz %0" \
: "=d" (__ret), \
"=m" (__drm_dummy_lock(lock)), \
"=a" (__dummy) \
: "2" (old), \
"r" (new)); \
} while (0)
#elif defined(__alpha__)
#define DRM_CAS(lock, old, new, ret) \
do { \
int old32; \
int cur32; \
__asm__ __volatile__( \
" mb\n" \
" zap %4, 0xF0, %0\n" \
" ldl_l %1, %2\n" \
" zap %1, 0xF0, %1\n" \
" cmpeq %0, %1, %1\n" \
" beq %1, 1f\n" \
" bis %5, %5, %1\n" \
" stl_c %1, %2\n" \
"1: xor %1, 1, %1\n" \
" stl %1, %3" \
: "+r" (old32), \
"+&r" (cur32), \
"=m" (__drm_dummy_lock(lock)),\
"=m" (ret) \
: "r" (old), \
"r" (new)); \
} while(0)
#elif defined(__sparc__)
#define DRM_CAS(lock,old,new,__ret) \
do { register unsigned int __old __asm("o0"); \
register unsigned int __new __asm("o1"); \
register volatile unsigned int *__lock __asm("o2"); \
__old = old; \
__new = new; \
__lock = (volatile unsigned int *)lock; \
__asm__ __volatile__( \
/*"cas [%2], %3, %0"*/ \
".word 0xd3e29008\n\t" \
/*"membar #StoreStore | #StoreLoad"*/ \
".word 0x8143e00a" \
: "=&r" (__new) \
: "0" (__new), \
"r" (__lock), \
"r" (__old) \
: "memory"); \
__ret = (__new != __old); \
} while(0)
#elif defined(__ia64__)
#ifdef __INTEL_COMPILER
/* this currently generates bad code (missing stop bits)... */
#include <ia64intrin.h>
#define DRM_CAS(lock,old,new,__ret) \
do { \
unsigned long __result, __old = (old) & 0xffffffff; \
__mf(); \
__result = _InterlockedCompareExchange_acq(&__drm_dummy_lock(lock), (new), __old);\
__ret = (__result) != (__old); \
/* __ret = (__sync_val_compare_and_swap(&__drm_dummy_lock(lock), \
(old), (new)) \
!= (old)); */\
} while (0)
#else
#define DRM_CAS(lock,old,new,__ret) \
do { \
unsigned int __result, __old = (old); \
__asm__ __volatile__( \
"mf\n" \
"mov ar.ccv=%2\n" \
";;\n" \
"cmpxchg4.acq %0=%1,%3,ar.ccv" \
: "=r" (__result), "=m" (__drm_dummy_lock(lock)) \
: "r" ((unsigned long)__old), "r" (new) \
: "memory"); \
__ret = (__result) != (__old); \
} while (0)
#endif
#elif defined(__powerpc__)
#define DRM_CAS(lock,old,new,__ret) \
do { \
__asm__ __volatile__( \
"sync;" \
"0: lwarx %0,0,%1;" \
" xor. %0,%3,%0;" \
" bne 1f;" \
" stwcx. %2,0,%1;" \
" bne- 0b;" \
"1: " \
"sync;" \
: "=&r"(__ret) \
: "r"(lock), "r"(new), "r"(old) \
: "cr0", "memory"); \
} while (0)
#endif /* architecture */
#endif /* __GNUC__ >= 2 */
#ifndef DRM_CAS
#define DRM_CAS(lock,old,new,ret) do { ret=1; } while (0) /* FAST LOCK FAILS */
#endif
#if defined(__alpha__) || defined(__powerpc__)
#define DRM_CAS_RESULT(_result) int _result
#else
#define DRM_CAS_RESULT(_result) char _result
#endif
#define DRM_LIGHT_LOCK(fd,lock,context) \
do { \
DRM_CAS_RESULT(__ret); \
DRM_CAS(lock,context,DRM_LOCK_HELD|context,__ret); \
if (__ret) drmGetLock(fd,context,0); \
} while(0)
/* This one counts fast locks -- for
benchmarking only. */
#define DRM_LIGHT_LOCK_COUNT(fd,lock,context,count) \
do { \
DRM_CAS_RESULT(__ret); \
DRM_CAS(lock,context,DRM_LOCK_HELD|context,__ret); \
if (__ret) drmGetLock(fd,context,0); \
else ++count; \
} while(0)
#define DRM_LOCK(fd,lock,context,flags) \
do { \
if (flags) drmGetLock(fd,context,flags); \
else DRM_LIGHT_LOCK(fd,lock,context); \
} while(0)
#define DRM_UNLOCK(fd,lock,context) \
do { \
DRM_CAS_RESULT(__ret); \
DRM_CAS(lock,DRM_LOCK_HELD|context,context,__ret); \
if (__ret) drmUnlock(fd,context); \
} while(0)
/* Simple spin locks */
#define DRM_SPINLOCK(spin,val) \
do { \
DRM_CAS_RESULT(__ret); \
do { \
DRM_CAS(spin,0,val,__ret); \
if (__ret) while ((spin)->lock); \
} while (__ret); \
} while(0)
#define DRM_SPINLOCK_TAKE(spin,val) \
do { \
DRM_CAS_RESULT(__ret); \
int cur; \
do { \
cur = (*spin).lock; \
DRM_CAS(spin,cur,val,__ret); \
} while (__ret); \
} while(0)
#define DRM_SPINLOCK_COUNT(spin,val,count,__ret) \
do { \
int __i; \
__ret = 1; \
for (__i = 0; __ret && __i < count; __i++) { \
DRM_CAS(spin,0,val,__ret); \
if (__ret) for (;__i < count && (spin)->lock; __i++); \
} \
} while(0)
#define DRM_SPINUNLOCK(spin,val) \
do { \
DRM_CAS_RESULT(__ret); \
if ((*spin).lock == val) { /* else server stole lock */ \
do { \
DRM_CAS(spin,val,0,__ret); \
} while (__ret); \
} \
} while(0)
/* General user-level programmer's API: unprivileged */
extern int drmAvailable(void);
extern int drmOpen(const char *name, const char *busid);
extern int drmClose(int fd);
extern drmVersionPtr drmGetVersion(int fd);
extern drmVersionPtr drmGetLibVersion(int fd);
extern void drmFreeVersion(drmVersionPtr);
extern int drmGetMagic(int fd, drm_magic_t * magic);
extern char *drmGetBusid(int fd);
extern int drmGetInterruptFromBusID(int fd, int busnum, int devnum,
int funcnum);
extern int drmGetMap(int fd, int idx, drm_handle_t *offset,
drmSize *size, drmMapType *type,
drmMapFlags *flags, drm_handle_t *handle,
int *mtrr);
extern int drmGetClient(int fd, int idx, int *auth, int *pid,
int *uid, unsigned long *magic,
unsigned long *iocs);
extern int drmGetStats(int fd, drmStatsT *stats);
extern int drmSetInterfaceVersion(int fd, drmSetVersion *version);
extern int drmCommandNone(int fd, unsigned long drmCommandIndex);
extern int drmCommandRead(int fd, unsigned long drmCommandIndex,
void *data, unsigned long size);
extern int drmCommandWrite(int fd, unsigned long drmCommandIndex,
void *data, unsigned long size);
extern int drmCommandWriteRead(int fd, unsigned long drmCommandIndex,
void *data, unsigned long size);
/* General user-level programmer's API: X server (root) only */
extern void drmFreeBusid(const char *busid);
extern int drmSetBusid(int fd, const char *busid);
extern int drmAuthMagic(int fd, drm_magic_t magic);
extern int drmAddMap(int fd,
drm_handle_t offset,
drmSize size,
drmMapType type,
drmMapFlags flags,
drm_handle_t * handle);
extern int drmRmMap(int fd, drm_handle_t handle);
extern int drmAddContextPrivateMapping(int fd, drm_context_t ctx_id,
drm_handle_t handle);
extern int drmAddBufs(int fd, int count, int size,
drmBufDescFlags flags,
int agp_offset);
extern int drmMarkBufs(int fd, double low, double high);
extern int drmCreateContext(int fd, drm_context_t * handle);
extern int drmSetContextFlags(int fd, drm_context_t context,
drm_context_tFlags flags);
extern int drmGetContextFlags(int fd, drm_context_t context,
drm_context_tFlagsPtr flags);
extern int drmAddContextTag(int fd, drm_context_t context, void *tag);
extern int drmDelContextTag(int fd, drm_context_t context);
extern void *drmGetContextTag(int fd, drm_context_t context);
extern drm_context_t * drmGetReservedContextList(int fd, int *count);
extern void drmFreeReservedContextList(drm_context_t *);
extern int drmSwitchToContext(int fd, drm_context_t context);
extern int drmDestroyContext(int fd, drm_context_t handle);
extern int drmCreateDrawable(int fd, drm_drawable_t * handle);
extern int drmDestroyDrawable(int fd, drm_drawable_t handle);
extern int drmCtlInstHandler(int fd, int irq);
extern int drmCtlUninstHandler(int fd);
extern int drmInstallSIGIOHandler(int fd,
void (*f)(int fd,
void *oldctx,
void *newctx));
extern int drmRemoveSIGIOHandler(int fd);
/* General user-level programmer's API: authenticated client and/or X */
extern int drmMap(int fd,
drm_handle_t handle,
drmSize size,
drmAddressPtr address);
extern int drmUnmap(drmAddress address, drmSize size);
extern drmBufInfoPtr drmGetBufInfo(int fd);
extern drmBufMapPtr drmMapBufs(int fd);
extern int drmUnmapBufs(drmBufMapPtr bufs);
extern int drmDMA(int fd, drmDMAReqPtr request);
extern int drmFreeBufs(int fd, int count, int *list);
extern int drmGetLock(int fd,
drm_context_t context,
drmLockFlags flags);
extern int drmUnlock(int fd, drm_context_t context);
extern int drmFinish(int fd, int context, drmLockFlags flags);
extern int drmGetContextPrivateMapping(int fd, drm_context_t ctx_id,
drm_handle_t * handle);
/* AGP/GART support: X server (root) only */
extern int drmAgpAcquire(int fd);
extern int drmAgpRelease(int fd);
extern int drmAgpEnable(int fd, unsigned long mode);
extern int drmAgpAlloc(int fd, unsigned long size,
unsigned long type, unsigned long *address,
unsigned long *handle);
extern int drmAgpFree(int fd, unsigned long handle);
extern int drmAgpBind(int fd, unsigned long handle,
unsigned long offset);
extern int drmAgpUnbind(int fd, unsigned long handle);
/* AGP/GART info: authenticated client and/or X */
extern int drmAgpVersionMajor(int fd);
extern int drmAgpVersionMinor(int fd);
extern unsigned long drmAgpGetMode(int fd);
extern unsigned long drmAgpBase(int fd); /* Physical location */
extern unsigned long drmAgpSize(int fd); /* Bytes */
extern unsigned long drmAgpMemoryUsed(int fd);
extern unsigned long drmAgpMemoryAvail(int fd);
extern unsigned int drmAgpVendorId(int fd);
extern unsigned int drmAgpDeviceId(int fd);
/* PCI scatter/gather support: X server (root) only */
extern int drmScatterGatherAlloc(int fd, unsigned long size,
unsigned long *handle);
extern int drmScatterGatherFree(int fd, unsigned long handle);
extern int drmWaitVBlank(int fd, drmVBlankPtr vbl);
/* Support routines */
extern int drmError(int err, const char *label);
extern void *drmMalloc(int size);
extern void drmFree(void *pt);
/* Hash table routines */
extern void *drmHashCreate(void);
extern int drmHashDestroy(void *t);
extern int drmHashLookup(void *t, unsigned long key, void **value);
extern int drmHashInsert(void *t, unsigned long key, void *value);
extern int drmHashDelete(void *t, unsigned long key);
extern int drmHashFirst(void *t, unsigned long *key, void **value);
extern int drmHashNext(void *t, unsigned long *key, void **value);
/* PRNG routines */
extern void *drmRandomCreate(unsigned long seed);
extern int drmRandomDestroy(void *state);
extern unsigned long drmRandom(void *state);
extern double drmRandomDouble(void *state);
/* Skip list routines */
extern void *drmSLCreate(void);
extern int drmSLDestroy(void *l);
extern int drmSLLookup(void *l, unsigned long key, void **value);
extern int drmSLInsert(void *l, unsigned long key, void *value);
extern int drmSLDelete(void *l, unsigned long key);
extern int drmSLNext(void *l, unsigned long *key, void **value);
extern int drmSLFirst(void *l, unsigned long *key, void **value);
extern void drmSLDump(void *l);
extern int drmSLLookupNeighbors(void *l, unsigned long key,
unsigned long *prev_key, void **prev_value,
unsigned long *next_key, void **next_value);
#endif

View file

@ -0,0 +1,107 @@
/*
* Copyright 2004 Red Hat Inc., Raleigh, 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>
*
*/
#include "xf86Parser.h"
#include "xf86tokens.h"
#include "Configint.h"
extern LexRec val;
static xf86ConfigSymTabRec ExtensionsTab[] =
{
{ENDSECTION, "endsection"},
{OPTION, "option"},
{-1, ""},
};
#define CLEANUP xf86freeExtensions
XF86ConfExtensionsPtr
xf86parseExtensionsSection (void)
{
int token;
parsePrologue (XF86ConfExtensionsPtr, XF86ConfExtensionsRec);
while ((token = xf86getToken (ExtensionsTab)) != ENDSECTION) {
switch (token) {
case OPTION:
ptr->ext_option_lst = xf86parseOption(ptr->ext_option_lst);
break;
case EOF_TOKEN:
Error (UNEXPECTED_EOF_MSG, NULL);
break;
case COMMENT:
ptr->extensions_comment =
xf86addComment(ptr->extensions_comment, val.str);
break;
default:
Error (INVALID_KEYWORD_MSG, xf86tokenString ());
break;
}
}
#ifdef DEBUG
ErrorF("Extensions section parsed\n");
#endif
return ptr;
}
#undef CLEANUP
void
xf86printExtensionsSection (FILE * cf, XF86ConfExtensionsPtr ptr)
{
XF86OptionPtr p;
if (ptr == NULL || ptr->ext_option_lst == NULL)
return;
p = ptr->ext_option_lst;
fprintf (cf, "Section \"Extensions\"\n");
if (ptr->extensions_comment)
fprintf (cf, "%s", ptr->extensions_comment);
xf86printOptionList(cf, p, 1);
fprintf (cf, "EndSection\n\n");
}
void
xf86freeExtensions (XF86ConfExtensionsPtr ptr)
{
if (ptr == NULL)
return;
xf86optionListFree (ptr->ext_option_lst);
TestFree (ptr->extensions_comment);
xf86conffree (ptr);
}

924
hw/xfree86/xaa/xaaWrapper.c Normal file
View file

@ -0,0 +1,924 @@
#include "X.h"
#include "Xproto.h"
#include "scrnintstr.h"
#include "gcstruct.h"
#include "glyphstr.h"
#include "window.h"
#include "windowstr.h"
#include "picture.h"
#include "picturestr.h"
#include "colormapst.h"
#include "xaa.h"
#include "xaalocal.h"
#include "xaaWrapper.h"
void XAASync(ScreenPtr pScreen);
/* #include "render.h" */
#if 0
#define COND(pDraw) \
((pDraw)->depth \
!= (xaaWrapperGetScrPriv(((DrawablePtr)(pDraw))->pScreen))->depth)
#endif
#define COND(pDraw) 1
#if 0
static Bool xaaWrapperPreCreateGC(GCPtr pGC);
#endif
static Bool xaaWrapperCreateGC(GCPtr pGC);
static void xaaWrapperValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDraw);
static void xaaWrapperDestroyGC(GCPtr pGC);
static void xaaWrapperChangeGC (GCPtr pGC, unsigned long mask);
static void xaaWrapperCopyGC (GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst);
static void xaaWrapperChangeClip (GCPtr pGC, int type, pointer pvalue, int nrects);
static void xaaWrapperCopyClip(GCPtr pgcDst, GCPtr pgcSrc);
static void xaaWrapperDestroyClip(GCPtr pGC);
#if 0
static void xaaWrapperFillSpans(DrawablePtr pDraw, GC *pGC, int nInit,
DDXPointPtr pptInit, int *pwidthInit, int fSorted);
static void xaaWrapperSetSpans(DrawablePtr pDraw, GCPtr pGC, char *pcharsrc,
DDXPointPtr pptInit, int *pwidthInit, int nspans,
int fSorted);
static void xaaWrapperPutImage(DrawablePtr pDraw, GCPtr pGC, int depth, int x, int y,
int w, int h,int leftPad, int format, char *pImage);
static RegionPtr xaaWrapperCopyPlane(DrawablePtr pSrc,
DrawablePtr pDst, GCPtr pGC,int srcx, int srcy,
int width, int height, int dstx, int dsty,
unsigned long bitPlane);
static void xaaWrapperPolyPoint(DrawablePtr pDraw, GCPtr pGC, int mode, int npt,
xPoint *pptInit);
static void xaaWrapperPolylines(DrawablePtr pDraw, GCPtr pGC, int mode,
int npt, DDXPointPtr pptInit);
static void xaaWrapperPolySegment(DrawablePtr pDraw, GCPtr pGC, int nseg,
xSegment *pSeg);
static void xaaWrapperPolyRectangle(DrawablePtr pDraw, GCPtr pGC, int nRects,
xRectangle *pRects);
static void xaaWrapperPolyArc( DrawablePtr pDraw, GCPtr pGC, int narcs, xArc *parcs);
static void xaaWrapperFillPolygon(DrawablePtr pDraw, GCPtr pGC, int shape,
int mode, int count, DDXPointPtr pptInit);
static void xaaWrapperPolyFillRect(DrawablePtr pDraw, GCPtr pGC, int nRectsInit,
xRectangle *pRectsInit);
static RegionPtr xaaWrapperCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GC *pGC,
int srcx, int srcy, int width, int height,
int dstx, int dsty);
static void xaaWrapperPolyFillArc(DrawablePtr pDraw, GCPtr pGC, int narcs,
xArc *parcs);
static int xaaWrapperPolyText8(DrawablePtr pDraw, GCPtr pGC, int x, int y, int count,
char *chars);
static int xaaWrapperPolyText16(DrawablePtr pDraw, GCPtr pGC, int x, int y,
int count, unsigned short *chars);
static void xaaWrapperImageText8(DrawablePtr pDraw, GCPtr pGC, int x,
int y, int count, char *chars);
static void xaaWrapperImageText16(DrawablePtr pDraw, GCPtr pGC, int x, int y,
int count, unsigned short *chars);
static void xaaWrapperImageGlyphBlt(DrawablePtr pDraw, GCPtr pGC, int x, int y,
unsigned int nglyph, CharInfoPtr *ppci,
pointer pglyphBase);
static void xaaWrapperPolyGlyphBlt(DrawablePtr pDraw, GCPtr pGC, int x, int y,
unsigned int nglyph, CharInfoPtr *ppci,
pointer pglyphBase);
static void xaaWrapperPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDraw,
int dx, int dy, int xOrg, int yOrg);
#endif
static void
xaaWrapperComposite (CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst,
INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask,
INT16 xDst, INT16 yDst, CARD16 width, CARD16 height);
static void
xaaWrapperGlyphs (CARD8 op, PicturePtr pSrc, PicturePtr pDst,
PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int nlist,
GlyphListPtr list, GlyphPtr *glyphs);
typedef struct {
CloseScreenProcPtr CloseScreen;
CreateScreenResourcesProcPtr CreateScreenResources;
CreateWindowProcPtr CreateWindow;
CopyWindowProcPtr CopyWindow;
PaintWindowProcPtr PaintWindowBackground;
PaintWindowProcPtr PaintWindowBorder;
WindowExposuresProcPtr WindowExposures;
CreateGCProcPtr CreateGC;
CreateColormapProcPtr CreateColormap;
DestroyColormapProcPtr DestroyColormap;
InstallColormapProcPtr InstallColormap;
UninstallColormapProcPtr UninstallColormap;
ListInstalledColormapsProcPtr ListInstalledColormaps;
StoreColorsProcPtr StoreColors;
#ifdef RENDER
CompositeProcPtr Composite;
GlyphsProcPtr Glyphs;
#endif
CloseScreenProcPtr wrapCloseScreen;
CreateScreenResourcesProcPtr wrapCreateScreenResources;
CreateWindowProcPtr wrapCreateWindow;
CopyWindowProcPtr wrapCopyWindow;
PaintWindowProcPtr wrapPaintWindowBackground;
PaintWindowProcPtr wrapPaintWindowBorder;
WindowExposuresProcPtr wrapWindowExposures;
CreateGCProcPtr wrapCreateGC;
CreateColormapProcPtr wrapCreateColormap;
DestroyColormapProcPtr wrapDestroyColormap;
InstallColormapProcPtr wrapInstallColormap;
UninstallColormapProcPtr wrapUninstallColormap;
ListInstalledColormapsProcPtr wrapListInstalledColormaps;
StoreColorsProcPtr wrapStoreColors;
#ifdef RENDER
CompositeProcPtr wrapComposite;
GlyphsProcPtr wrapGlyphs;
#endif
int depth;
} xaaWrapperScrPrivRec, *xaaWrapperScrPrivPtr;
#define xaaWrapperGetScrPriv(s) ((xaaWrapperScrPrivPtr)( \
(xaaWrapperScrPrivateIndex != -1) \
? (s)->devPrivates[xaaWrapperScrPrivateIndex].ptr\
: NULL))
#define xaaWrapperScrPriv(s) xaaWrapperScrPrivPtr pScrPriv = xaaWrapperGetScrPriv(s)
#define wrap(priv,real,mem,func) {\
priv->mem = real->mem; \
real->mem = func; \
}
#if 0
#define wrap_pre(priv,real,real_func,mem,func) {\
priv->mem = real->real_func; \
real->real_func = func; \
}
#endif
#define get(priv,real,func,wrap) \
priv->wrap = real->func;
#define unwrap(priv,real,mem) {\
real->mem = priv->mem; \
}
#if 0
#define unwrap_pre(priv,real,real_func,mem) {\
real->real_func = priv->mem; \
}
#endif
typedef struct _xaaWrapperGCPriv {
GCOps *ops;
Bool wrap;
GCFuncs *funcs;
GCOps *wrapops;
} xaaWrapperGCPrivRec, *xaaWrapperGCPrivPtr;
#define xaaWrapperGetGCPriv(pGC) ((xaaWrapperGCPrivPtr) \
(pGC)->devPrivates[xaaWrapperGCPrivateIndex].ptr)
#define xaaWrapperGCPriv(pGC) xaaWrapperGCPrivPtr pGCPriv = xaaWrapperGetGCPriv(pGC)
static int xaaWrapperScrPrivateIndex = -1;
static int xaaWrapperGCPrivateIndex = -1;
static int xaaWrapperGeneration = -1;
static Bool
xaaWrapperCreateScreenResources(ScreenPtr pScreen)
{
xaaWrapperScrPriv(pScreen);
Bool ret;
unwrap (pScrPriv,pScreen, CreateScreenResources);
ret = pScreen->CreateScreenResources(pScreen);
wrap(pScrPriv,pScreen,CreateScreenResources,xaaWrapperCreateScreenResources);
return ret;
}
static Bool
xaaWrapperCloseScreen (int iScreen, ScreenPtr pScreen)
{
xaaWrapperScrPriv(pScreen);
Bool ret;
unwrap (pScrPriv,pScreen, CloseScreen);
ret = pScreen->CloseScreen(iScreen,pScreen);
return TRUE;
}
static Bool
xaaWrapperCreateWindow(WindowPtr pWin)
{
xaaWrapperScrPriv(pWin->drawable.pScreen);
Bool ret;
unwrap (pScrPriv, pWin->drawable.pScreen, CreateWindow);
if (COND(&pWin->drawable))
pWin->drawable.pScreen->CreateWindow
= pScrPriv->wrapCreateWindow;
ret = pWin->drawable.pScreen->CreateWindow(pWin);
wrap(pScrPriv, pWin->drawable.pScreen, CreateWindow, xaaWrapperCreateWindow);
return ret;
}
static void
xaaWrapperCopyWindow(WindowPtr pWin,
DDXPointRec ptOldOrg,
RegionPtr prgnSrc)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
xaaWrapperScrPriv(pScreen);
unwrap (pScrPriv, pScreen, CopyWindow);
#if 0
if (COND(&pWin->drawable))
pWin->drawable.pScreen->CopyWindow = pScrPriv->wrapCopyWindow;
#endif
pScreen->CopyWindow(pWin, ptOldOrg, prgnSrc);
wrap(pScrPriv, pScreen, CopyWindow, xaaWrapperCopyWindow);
}
static void
xaaWrapperWindowExposures (WindowPtr pWin,
RegionPtr prgn,
RegionPtr other_exposed)
{
xaaWrapperScrPriv(pWin->drawable.pScreen);
unwrap (pScrPriv, pWin->drawable.pScreen, WindowExposures);
if (COND(&pWin->drawable))
pWin->drawable.pScreen->WindowExposures = pScrPriv->wrapWindowExposures;
pWin->drawable.pScreen->WindowExposures(pWin, prgn, other_exposed);
wrap(pScrPriv, pWin->drawable.pScreen, WindowExposures, xaaWrapperWindowExposures);
}
static void
xaaWrapperPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
{
xaaWrapperScrPriv(pWin->drawable.pScreen);
switch (what) {
case PW_BORDER:
unwrap (pScrPriv, pWin->drawable.pScreen, PaintWindowBorder);
if (COND(&pWin->drawable)) {
pWin->drawable.pScreen->PaintWindowBorder
= pScrPriv->wrapPaintWindowBorder;
XAASync(pWin->drawable.pScreen);
}
pWin->drawable.pScreen->PaintWindowBorder (pWin, pRegion, what);
wrap(pScrPriv, pWin->drawable.pScreen, PaintWindowBorder,
xaaWrapperPaintWindow);
break;
case PW_BACKGROUND:
unwrap (pScrPriv, pWin->drawable.pScreen, PaintWindowBackground);
if (COND(&pWin->drawable)) {
pWin->drawable.pScreen->PaintWindowBackground
= pScrPriv->wrapPaintWindowBackground;
XAASync(pWin->drawable.pScreen);
}
pWin->drawable.pScreen->PaintWindowBackground (pWin, pRegion, what);
wrap(pScrPriv, pWin->drawable.pScreen, PaintWindowBackground,
xaaWrapperPaintWindow);
break;
}
}
static Bool
xaaWrapperCreateColormap(ColormapPtr pmap)
{
xaaWrapperScrPriv(pmap->pScreen);
Bool ret;
unwrap(pScrPriv,pmap->pScreen, CreateColormap);
ret = pmap->pScreen->CreateColormap(pmap);
wrap(pScrPriv,pmap->pScreen,CreateColormap,xaaWrapperCreateColormap);
return ret;
}
static void
xaaWrapperDestroyColormap(ColormapPtr pmap)
{
xaaWrapperScrPriv(pmap->pScreen);
unwrap(pScrPriv,pmap->pScreen, DestroyColormap);
pmap->pScreen->DestroyColormap(pmap);
wrap(pScrPriv,pmap->pScreen,DestroyColormap,xaaWrapperDestroyColormap);
}
static void
xaaWrapperStoreColors(ColormapPtr pmap, int nColors, xColorItem *pColors)
{
xaaWrapperScrPriv(pmap->pScreen);
unwrap(pScrPriv,pmap->pScreen, StoreColors);
pmap->pScreen->StoreColors(pmap,nColors,pColors);
wrap(pScrPriv,pmap->pScreen,StoreColors,xaaWrapperStoreColors);
}
static void
xaaWrapperInstallColormap(ColormapPtr pmap)
{
xaaWrapperScrPriv(pmap->pScreen);
unwrap(pScrPriv,pmap->pScreen, InstallColormap);
pmap->pScreen->InstallColormap(pmap);
wrap(pScrPriv,pmap->pScreen,InstallColormap,xaaWrapperInstallColormap);
}
static void
xaaWrapperUninstallColormap(ColormapPtr pmap)
{
xaaWrapperScrPriv(pmap->pScreen);
unwrap(pScrPriv,pmap->pScreen, UninstallColormap);
pmap->pScreen->UninstallColormap(pmap);
wrap(pScrPriv,pmap->pScreen,UninstallColormap,xaaWrapperUninstallColormap);
}
static int
xaaWrapperListInstalledColormaps(ScreenPtr pScreen, Colormap *pCmapIds)
{
int n;
xaaWrapperScrPriv(pScreen);
unwrap(pScrPriv,pScreen, ListInstalledColormaps);
n = pScreen->ListInstalledColormaps(pScreen, pCmapIds);
wrap (pScrPriv,pScreen,ListInstalledColormaps,xaaWrapperListInstalledColormaps);
return n;
}
Bool
xaaSetupWrapper(ScreenPtr pScreen, XAAInfoRecPtr infoPtr, int depth, SyncFunc *func)
{
Bool ret;
xaaWrapperScrPrivPtr pScrPriv;
#ifdef RENDER
PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
#endif
if (xaaWrapperGeneration != serverGeneration) {
xaaWrapperScrPrivateIndex = AllocateScreenPrivateIndex ();
if (xaaWrapperScrPrivateIndex == -1)
return FALSE;
xaaWrapperGCPrivateIndex = AllocateGCPrivateIndex ();
if (xaaWrapperGCPrivateIndex == -1)
return FALSE;
xaaWrapperGeneration = serverGeneration;
}
if (!AllocateGCPrivate (pScreen, xaaWrapperGCPrivateIndex,
sizeof (xaaWrapperGCPrivRec)))
return FALSE;
pScrPriv = (xaaWrapperScrPrivPtr) xalloc (sizeof (xaaWrapperScrPrivRec));
if (!pScrPriv)
return FALSE;
get (pScrPriv, pScreen, CloseScreen, wrapCloseScreen);
get (pScrPriv, pScreen, CreateScreenResources, wrapCreateScreenResources);
get (pScrPriv, pScreen, CreateWindow, wrapCreateWindow);
get (pScrPriv, pScreen, CopyWindow, wrapCopyWindow);
get (pScrPriv, pScreen, PaintWindowBorder, wrapPaintWindowBorder);
get (pScrPriv, pScreen, PaintWindowBackground, wrapPaintWindowBackground);
get (pScrPriv, pScreen, WindowExposures, wrapWindowExposures);
#if 0
wrap_pre (pScrPriv, pScreen, CreateGC, wrapCreateGC, xaaWrapperPreCreateGC);
#else
get (pScrPriv, pScreen, CreateGC, wrapCreateGC);
#endif
get (pScrPriv, pScreen, CreateColormap, wrapCreateColormap);
get (pScrPriv, pScreen, DestroyColormap, wrapDestroyColormap);
get (pScrPriv, pScreen, InstallColormap, wrapInstallColormap);
get (pScrPriv, pScreen, UninstallColormap, wrapUninstallColormap);
get (pScrPriv, pScreen, ListInstalledColormaps, wrapListInstalledColormaps);
get (pScrPriv, pScreen, StoreColors, wrapStoreColors);
#ifdef RENDER
if (ps) {
get (pScrPriv, ps, Glyphs, wrapGlyphs);
get (pScrPriv, ps, Composite, wrapComposite);
}
#endif
if (!(ret = XAAInit(pScreen,infoPtr)))
return FALSE;
wrap (pScrPriv, pScreen, CloseScreen, xaaWrapperCloseScreen);
wrap (pScrPriv, pScreen, CreateScreenResources,
xaaWrapperCreateScreenResources);
wrap (pScrPriv, pScreen, CreateWindow, xaaWrapperCreateWindow);
wrap (pScrPriv, pScreen, CopyWindow, xaaWrapperCopyWindow);
wrap (pScrPriv, pScreen, PaintWindowBorder, xaaWrapperPaintWindow);
wrap (pScrPriv, pScreen, PaintWindowBackground, xaaWrapperPaintWindow);
wrap (pScrPriv, pScreen, WindowExposures, xaaWrapperWindowExposures);
wrap (pScrPriv, pScreen, CreateGC, xaaWrapperCreateGC);
wrap (pScrPriv, pScreen, CreateColormap, xaaWrapperCreateColormap);
wrap (pScrPriv, pScreen, DestroyColormap, xaaWrapperDestroyColormap);
wrap (pScrPriv, pScreen, InstallColormap, xaaWrapperInstallColormap);
wrap (pScrPriv, pScreen, UninstallColormap, xaaWrapperUninstallColormap);
wrap (pScrPriv, pScreen, ListInstalledColormaps,
xaaWrapperListInstalledColormaps);
wrap (pScrPriv, pScreen, StoreColors, xaaWrapperStoreColors);
#ifdef RENDER
if (ps) {
wrap (pScrPriv, ps, Glyphs, xaaWrapperGlyphs);
wrap (pScrPriv, ps, Composite, xaaWrapperComposite);
}
#endif
pScrPriv->depth = depth;
pScreen->devPrivates[xaaWrapperScrPrivateIndex].ptr = (pointer) pScrPriv;
*func = XAASync;
return ret;
}
GCFuncs xaaWrapperGCFuncs = {
xaaWrapperValidateGC, xaaWrapperChangeGC, xaaWrapperCopyGC,
xaaWrapperDestroyGC, xaaWrapperChangeClip, xaaWrapperDestroyClip,
xaaWrapperCopyClip
};
#if 0
GCOps xaaWrapperGCOps = {
xaaWrapperFillSpans, xaaWrapperSetSpans,
xaaWrapperPutImage, xaaWrapperCopyArea,
xaaWrapperCopyPlane, xaaWrapperPolyPoint,
xaaWrapperPolylines, xaaWrapperPolySegment,
xaaWrapperPolyRectangle, xaaWrapperPolyArc,
xaaWrapperFillPolygon, xaaWrapperPolyFillRect,
xaaWrapperPolyFillArc, xaaWrapperPolyText8,
xaaWrapperPolyText16, xaaWrapperImageText8,
xaaWrapperImageText16, xaaWrapperImageGlyphBlt,
xaaWrapperPolyGlyphBlt, xaaWrapperPushPixels,
#ifdef NEED_LINEHELPER
NULL,
#endif
{NULL} /* devPrivate */
};
#endif
#define XAAWRAPPER_GC_FUNC_PROLOGUE(pGC) \
xaaWrapperGCPriv(pGC); \
unwrap(pGCPriv, pGC, funcs); \
if (pGCPriv->wrap) unwrap(pGCPriv, pGC, ops)
#define XAAWRAPPER_GC_FUNC_EPILOGUE(pGC) \
wrap(pGCPriv, pGC, funcs, &xaaWrapperGCFuncs); \
if (pGCPriv->wrap) wrap(pGCPriv, pGC, ops, pGCPriv->wrapops)
#if 0
static Bool
xaaWrapperPreCreateGC(GCPtr pGC)
{
ScreenPtr pScreen = pGC->pScreen;
xaaWrapperScrPriv(pScreen);
xaaWrapperGCPriv(pGC);
Bool ret;
unwrap_pre (pScrPriv, pScreen, CreateGC, wrapCreateGC);
ret = (*pScreen->CreateGC) (pGC);
wrap_pre (pScrPriv, pScreen, CreateGC, wrapCreateGC, xaaWrapperPreCreateGC);
return ret;
}
#endif
static Bool
xaaWrapperCreateGC(GCPtr pGC)
{
ScreenPtr pScreen = pGC->pScreen;
xaaWrapperScrPriv(pScreen);
xaaWrapperGCPriv(pGC);
Bool ret;
unwrap (pScrPriv, pScreen, CreateGC);
if((ret = (*pScreen->CreateGC) (pGC))) {
pGCPriv->wrap = FALSE;
pGCPriv->funcs = pGC->funcs;
pGCPriv->wrapops = pGC->ops;
pGC->funcs = &xaaWrapperGCFuncs;
}
wrap (pScrPriv, pScreen, CreateGC, xaaWrapperCreateGC);
return ret;
}
static void
xaaWrapperValidateGC(
GCPtr pGC,
unsigned long changes,
DrawablePtr pDraw
){
XAAWRAPPER_GC_FUNC_PROLOGUE (pGC);
(*pGC->funcs->ValidateGC)(pGC, changes, pDraw);
if(COND(pDraw))
pGCPriv->wrap = TRUE;
XAAWRAPPER_GC_FUNC_EPILOGUE (pGC);
}
static void
xaaWrapperDestroyGC(GCPtr pGC)
{
XAAWRAPPER_GC_FUNC_PROLOGUE (pGC);
(*pGC->funcs->DestroyGC)(pGC);
XAAWRAPPER_GC_FUNC_EPILOGUE (pGC);
}
static void
xaaWrapperChangeGC (
GCPtr pGC,
unsigned long mask
){
XAAWRAPPER_GC_FUNC_PROLOGUE (pGC);
(*pGC->funcs->ChangeGC) (pGC, mask);
XAAWRAPPER_GC_FUNC_EPILOGUE (pGC);
}
static void
xaaWrapperCopyGC (
GCPtr pGCSrc,
unsigned long mask,
GCPtr pGCDst
){
XAAWRAPPER_GC_FUNC_PROLOGUE (pGCDst);
(*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst);
XAAWRAPPER_GC_FUNC_EPILOGUE (pGCDst);
}
static void
xaaWrapperChangeClip (
GCPtr pGC,
int type,
pointer pvalue,
int nrects
){
XAAWRAPPER_GC_FUNC_PROLOGUE (pGC);
(*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects);
XAAWRAPPER_GC_FUNC_EPILOGUE (pGC);
}
static void
xaaWrapperCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
{
XAAWRAPPER_GC_FUNC_PROLOGUE (pgcDst);
(* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc);
XAAWRAPPER_GC_FUNC_EPILOGUE (pgcDst);
}
static void
xaaWrapperDestroyClip(GCPtr pGC)
{
XAAWRAPPER_GC_FUNC_PROLOGUE (pGC);
(* pGC->funcs->DestroyClip)(pGC);
XAAWRAPPER_GC_FUNC_EPILOGUE (pGC);
}
#if 0
#define XAAWRAPPER_GC_OP_PROLOGUE(pGC,pDraw) \
/* xaaWrapperScrPriv(pDraw->pScreen); */\
xaaWrapperGCPriv(pGC); \
GCFuncs *oldFuncs = pGC->funcs; \
unwrap(pGCPriv, pGC, funcs); \
unwrap(pGCPriv, pGC, ops); \
#define XAAWRAPPER_GC_OP_EPILOGUE(pGC,pDraw) \
wrap(pGCPriv, pGC, funcs, oldFuncs); \
wrap(pGCPriv, pGC, ops, &xaaWrapperGCOps)
static void
xaaWrapperFillSpans(
DrawablePtr pDraw,
GC *pGC,
int nInit,
DDXPointPtr pptInit,
int *pwidthInit,
int fSorted
){
XAAWRAPPER_GC_OP_PROLOGUE(pGC, pDraw);
(*pGC->ops->FillSpans)(pDraw, pGC, nInit, pptInit, pwidthInit, fSorted);
XAAWRAPPER_GC_OP_EPILOGUE(pGC, pDraw);
}
static void
xaaWrapperSetSpans(
DrawablePtr pDraw,
GCPtr pGC,
char *pcharsrc,
DDXPointPtr pptInit,
int *pwidthInit,
int nspans,
int fSorted
){
XAAWRAPPER_GC_OP_PROLOGUE(pGC, pDraw);
(*pGC->ops->SetSpans)(pDraw, pGC, pcharsrc, pptInit,
pwidthInit, nspans, fSorted);
XAAWRAPPER_GC_OP_EPILOGUE(pGC, pDraw);
}
static void
xaaWrapperPutImage(
DrawablePtr pDraw,
GCPtr pGC,
int depth,
int x, int y, int w, int h,
int leftPad,
int format,
char *pImage
){
XAAWRAPPER_GC_OP_PROLOGUE(pGC, pDraw);
(*pGC->ops->PutImage)(pDraw, pGC, depth, x, y, w, h,
leftPad, format, pImage);
XAAWRAPPER_GC_OP_EPILOGUE(pGC, pDraw);
}
static RegionPtr
xaaWrapperCopyArea(
DrawablePtr pSrc,
DrawablePtr pDst,
GC *pGC,
int srcx, int srcy,
int width, int height,
int dstx, int dsty
){
RegionPtr ret;
XAAWRAPPER_GC_OP_PROLOGUE(pGC, pDst);
ret = (*pGC->ops->CopyArea)(pSrc, pDst,
pGC, srcx, srcy, width, height, dstx, dsty);
XAAWRAPPER_GC_OP_EPILOGUE(pGC, pDst);
return ret;
}
static RegionPtr
xaaWrapperCopyPlane(
DrawablePtr pSrc,
DrawablePtr pDst,
GCPtr pGC,
int srcx, int srcy,
int width, int height,
int dstx, int dsty,
unsigned long bitPlane
){
RegionPtr ret;
XAAWRAPPER_GC_OP_PROLOGUE(pGC, pDst);
ret = (*pGC->ops->CopyPlane)(pSrc, pDst,
pGC, srcx, srcy, width, height, dstx, dsty, bitPlane);
XAAWRAPPER_GC_OP_EPILOGUE(pGC, pDst);
return ret;
}
static void
xaaWrapperPolyPoint(
DrawablePtr pDraw,
GCPtr pGC,
int mode,
int npt,
xPoint *pptInit
){
XAAWRAPPER_GC_OP_PROLOGUE(pGC, pDraw);
(*pGC->ops->PolyPoint)(pDraw, pGC, mode, npt, pptInit);
XAAWRAPPER_GC_OP_EPILOGUE(pGC, pDraw);
}
static void
xaaWrapperPolylines(
DrawablePtr pDraw,
GCPtr pGC,
int mode,
int npt,
DDXPointPtr pptInit
){
XAAWRAPPER_GC_OP_PROLOGUE(pGC, pDraw);
(*pGC->ops->Polylines)(pDraw, pGC, mode, npt, pptInit);
XAAWRAPPER_GC_OP_EPILOGUE(pGC, pDraw);
}
static void
xaaWrapperPolySegment(
DrawablePtr pDraw,
GCPtr pGC,
int nseg,
xSegment *pSeg
){
XAAWRAPPER_GC_OP_PROLOGUE(pGC, pDraw);
(*pGC->ops->PolySegment)(pDraw, pGC, nseg, pSeg);
XAAWRAPPER_GC_OP_EPILOGUE(pGC, pDraw);
}
static void
xaaWrapperPolyRectangle(
DrawablePtr pDraw,
GCPtr pGC,
int nRects,
xRectangle *pRects
){
XAAWRAPPER_GC_OP_PROLOGUE(pGC, pDraw);
(*pGC->ops->PolyRectangle)(pDraw, pGC, nRects, pRects);
XAAWRAPPER_GC_OP_EPILOGUE(pGC, pDraw);
}
static void
xaaWrapperPolyArc(
DrawablePtr pDraw,
GCPtr pGC,
int narcs,
xArc *parcs
){
XAAWRAPPER_GC_OP_PROLOGUE(pGC, pDraw);
(*pGC->ops->PolyArc)(pDraw, pGC, narcs, parcs);
XAAWRAPPER_GC_OP_EPILOGUE(pGC, pDraw);
}
static void
xaaWrapperFillPolygon(
DrawablePtr pDraw,
GCPtr pGC,
int shape,
int mode,
int count,
DDXPointPtr pptInit
){
XAAWRAPPER_GC_OP_PROLOGUE(pGC, pDraw);
(*pGC->ops->FillPolygon)(pDraw, pGC, shape, mode, count, pptInit);
XAAWRAPPER_GC_OP_EPILOGUE(pGC, pDraw);
}
static void
xaaWrapperPolyFillRect(
DrawablePtr pDraw,
GCPtr pGC,
int nRectsInit,
xRectangle *pRectsInit
){
XAAWRAPPER_GC_OP_PROLOGUE(pGC, pDraw);
(*pGC->ops->PolyFillRect)(pDraw, pGC, nRectsInit, pRectsInit);
XAAWRAPPER_GC_OP_EPILOGUE(pGC, pDraw);
}
static void
xaaWrapperPolyFillArc(
DrawablePtr pDraw,
GCPtr pGC,
int narcs,
xArc *parcs
){
XAAWRAPPER_GC_OP_PROLOGUE(pGC, pDraw);
(*pGC->ops->PolyFillArc)(pDraw, pGC, narcs, parcs);
XAAWRAPPER_GC_OP_EPILOGUE(pGC, pDraw);
}
static int
xaaWrapperPolyText8(
DrawablePtr pDraw,
GCPtr pGC,
int x,
int y,
int count,
char *chars
){
int width;
XAAWRAPPER_GC_OP_PROLOGUE(pGC, pDraw);
width = (*pGC->ops->PolyText8)(pDraw, pGC, x, y, count, chars);
XAAWRAPPER_GC_OP_EPILOGUE(pGC, pDraw);
return width;
}
static int
xaaWrapperPolyText16(
DrawablePtr pDraw,
GCPtr pGC,
int x,
int y,
int count,
unsigned short *chars
){
int width;
XAAWRAPPER_GC_OP_PROLOGUE(pGC, pDraw);
width = (*pGC->ops->PolyText16)(pDraw, pGC, x, y, count, chars);
XAAWRAPPER_GC_OP_EPILOGUE(pGC, pDraw);
return width;
}
static void
xaaWrapperImageText8(
DrawablePtr pDraw,
GCPtr pGC,
int x,
int y,
int count,
char *chars
){
XAAWRAPPER_GC_OP_PROLOGUE(pGC, pDraw);
(*pGC->ops->ImageText8)(pDraw, pGC, x, y, count, chars);
XAAWRAPPER_GC_OP_EPILOGUE(pGC, pDraw);
}
static void
xaaWrapperImageText16(
DrawablePtr pDraw,
GCPtr pGC,
int x,
int y,
int count,
unsigned short *chars
){
XAAWRAPPER_GC_OP_PROLOGUE(pGC, pDraw);
(*pGC->ops->ImageText16)(pDraw, pGC, x, y, count, chars);
XAAWRAPPER_GC_OP_EPILOGUE(pGC, pDraw);
}
static void
xaaWrapperImageGlyphBlt(
DrawablePtr pDraw,
GCPtr pGC,
int x, int y,
unsigned int nglyph,
CharInfoPtr *ppci,
pointer pglyphBase
){
XAAWRAPPER_GC_OP_PROLOGUE(pGC, pDraw);
(*pGC->ops->ImageGlyphBlt)(pDraw, pGC, x, y, nglyph,
ppci, pglyphBase);
XAAWRAPPER_GC_OP_EPILOGUE(pGC, pDraw);
}
static void
xaaWrapperPolyGlyphBlt(
DrawablePtr pDraw,
GCPtr pGC,
int x, int y,
unsigned int nglyph,
CharInfoPtr *ppci,
pointer pglyphBase
){
XAAWRAPPER_GC_OP_PROLOGUE(pGC, pDraw);
(*pGC->ops->PolyGlyphBlt)(pDraw, pGC, x, y, nglyph,
ppci, pglyphBase);
XAAWRAPPER_GC_OP_EPILOGUE(pGC, pDraw);
}
static void
xaaWrapperPushPixels(
GCPtr pGC,
PixmapPtr pBitMap,
DrawablePtr pDraw,
int dx, int dy, int xOrg, int yOrg
){
XAAWRAPPER_GC_OP_PROLOGUE(pGC, pDraw);
(*pGC->ops->PushPixels)(pGC, pBitMap, pDraw, dx, dy, xOrg, yOrg);
XAAWRAPPER_GC_OP_EPILOGUE(pGC, pDraw);
}
#endif
#ifdef RENDER
static void
xaaWrapperComposite (CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst,
INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask,
INT16 xDst, INT16 yDst, CARD16 width, CARD16 height)
{
ScreenPtr pScreen = pDst->pDrawable->pScreen;
PictureScreenPtr ps = GetPictureScreen(pScreen);
xaaWrapperScrPriv(pScreen);
unwrap (pScrPriv, ps, Composite);
(*ps->Composite) (op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask,
xDst, yDst, width, height);
wrap (pScrPriv, ps, Composite, xaaWrapperComposite);
}
static void
xaaWrapperGlyphs (CARD8 op, PicturePtr pSrc, PicturePtr pDst,
PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int nlist,
GlyphListPtr list, GlyphPtr *glyphs)
{
ScreenPtr pScreen = pDst->pDrawable->pScreen;
PictureScreenPtr ps = GetPictureScreen(pScreen);
xaaWrapperScrPriv(pScreen);
unwrap (pScrPriv, ps, Glyphs);
(*ps->Glyphs) (op, pSrc, pDst, maskFormat, xSrc, ySrc,
nlist, list, glyphs);
wrap (pScrPriv, ps, Glyphs, xaaWrapperGlyphs);
}
#endif
void
XAASync(ScreenPtr pScreen)
{
XAAScreenPtr pScreenPriv =
(XAAScreenPtr) pScreen->devPrivates[XAAScreenIndex].ptr;
XAAInfoRecPtr infoRec = pScreenPriv->AccelInfoRec;
if(infoRec->NeedToSync) {
(*infoRec->Sync)(infoRec->pScrn);
infoRec->NeedToSync = FALSE;
}
}

View file

@ -0,0 +1,9 @@
#ifndef _XAA_WRAPPER_H
# define _XAA_WRAPPER_H
typedef void (*SyncFunc)(ScreenPtr);
Bool xaaSetupWrapper(ScreenPtr pScreen,
XAAInfoRecPtr infoPtr, int depth, SyncFunc *func);
#endif

View file

@ -61,6 +61,7 @@ extern Window g_iClipboardWindow;
static jmp_buf g_jmpEntry;
Bool g_fUnicodeSupport = FALSE;
Bool g_fUseUnicode = FALSE;
/*
@ -91,16 +92,19 @@ winClipboardProc (void *pvNotUsed)
Display *pDisplay = NULL;
Window iWindow = None;
int iRetries;
Bool fUnicodeSupport;
Bool fUseUnicode;
char szDisplay[512];
ErrorF ("winClipboardProc - Hello\n");
/* Do we have Unicode support? */
fUnicodeSupport = g_fUnicodeClipboard && winClipboardDetectUnicodeSupport ();
g_fUnicodeSupport = winClipboardDetectUnicodeSupport ();
/* Do we use Unicode clipboard? */
fUseUnicode = g_fUnicodeClipboard && g_fUnicodeSupport;
/* Save the Unicode support flag in a global */
g_fUnicodeSupport = fUnicodeSupport;
g_fUseUnicode = fUseUnicode;
/* Allow multiple threads to access Xlib */
if (XInitThreads () == 0)
@ -224,9 +228,6 @@ winClipboardProc (void *pvNotUsed)
atomClipboard = XInternAtom (pDisplay, "CLIPBOARD", False);
atomClipboardManager = XInternAtom (pDisplay, "CLIPBOARD_MANAGER", False);
/* FIXME: Save some values as globals for the window proc */
g_fUnicodeSupport = fUnicodeSupport;
/* Create a messaging window */
iWindow = XCreateSimpleWindow (pDisplay,
DefaultRootWindow (pDisplay),
@ -296,7 +297,7 @@ winClipboardProc (void *pvNotUsed)
winClipboardFlushXEvents (hwnd,
iWindow,
pDisplay,
fUnicodeSupport);
fUseUnicode);
/* Pre-flush Windows messages */
if (!winClipboardFlushWindowsMessageQueue (hwnd))
@ -344,7 +345,7 @@ winClipboardProc (void *pvNotUsed)
iReturn = winClipboardFlushXEvents (hwnd,
iWindow,
pDisplay,
fUnicodeSupport);
fUseUnicode);
if (WIN_XEVENTS_SHUTDOWN == iReturn)
{
ErrorF ("winClipboardProc - winClipboardFlushXEvents "

View file

@ -43,7 +43,7 @@
* References to external symbols
*/
extern Bool g_fUnicodeSupport;
extern Bool g_fUseUnicode;
extern void *g_pClipboardDisplay;
extern Window g_iClipboardWindow;
extern Atom g_atomLastOwnedSelection;
@ -55,7 +55,7 @@ extern Atom g_atomLastOwnedSelection;
static Bool
winProcessXEventsTimeout (HWND hwnd, int iWindow, Display *pDisplay,
Bool fUnicodeSupport, int iTimeoutSec);
Bool fUseUnicode, int iTimeoutSec);
/*
@ -64,7 +64,7 @@ winProcessXEventsTimeout (HWND hwnd, int iWindow, Display *pDisplay,
static int
winProcessXEventsTimeout (HWND hwnd, int iWindow, Display *pDisplay,
Bool fUnicodeSupport, int iTimeoutSec)
Bool fUseUnicode, int iTimeoutSec)
{
int iConnNumber;
struct timeval tv;
@ -115,7 +115,7 @@ winProcessXEventsTimeout (HWND hwnd, int iWindow, Display *pDisplay,
iReturn = winClipboardFlushXEvents (hwnd,
iWindow,
pDisplay,
fUnicodeSupport);
fUseUnicode);
if (WIN_XEVENTS_NOTIFY == iReturn
|| WIN_XEVENTS_CONVERT == iReturn)
{
@ -445,7 +445,7 @@ winClipboardWindowProc (HWND hwnd, UINT message,
if (message == WM_RENDERALLFORMATS)
fConvertToUnicode = FALSE;
else
fConvertToUnicode = g_fUnicodeSupport && (CF_UNICODETEXT == wParam);
fConvertToUnicode = g_fUseUnicode && (CF_UNICODETEXT == wParam);
/* Request the selection contents */
iReturn = XConvertSelection (pDisplay,

View file

@ -31,6 +31,13 @@
#include "winclipboard.h"
/*
* References to external symbols
*/
extern Bool g_fUnicodeSupport;
/*
* Process any pending X events
*/
@ -39,7 +46,7 @@ int
winClipboardFlushXEvents (HWND hwnd,
int iWindow,
Display *pDisplay,
Bool fUnicodeSupport)
Bool fUseUnicode)
{
Atom atomLocalProperty = XInternAtom (pDisplay,
WIN_LOCAL_PROPERTY,
@ -173,7 +180,7 @@ winClipboardFlushXEvents (HWND hwnd,
}
/* Check that clipboard format is available */
if (fUnicodeSupport
if (fUseUnicode
&& !IsClipboardFormatAvailable (CF_UNICODETEXT))
{
ErrorF ("winClipboardFlushXEvents - CF_UNICODETEXT is not "
@ -183,7 +190,7 @@ winClipboardFlushXEvents (HWND hwnd,
fAbort = TRUE;
goto winClipboardFlushXEvents_SelectionRequest_Done;
}
else if (!fUnicodeSupport
else if (!fUseUnicode
&& !IsClipboardFormatAvailable (CF_TEXT))
{
ErrorF ("winClipboardFlushXEvents - CF_TEXT is not "
@ -232,7 +239,7 @@ winClipboardFlushXEvents (HWND hwnd,
*/
/* Get a pointer to the clipboard text, in desired format */
if (fUnicodeSupport)
if (fUseUnicode)
{
/* Retrieve clipboard data */
hGlobal = GetClipboardData (CF_UNICODETEXT);
@ -255,7 +262,7 @@ winClipboardFlushXEvents (HWND hwnd,
pszGlobalData = (char *) GlobalLock (hGlobal);
/* Convert the Unicode string to UTF8 (MBCS) */
if (fUnicodeSupport)
if (fUseUnicode)
{
iConvertDataLen = WideCharToMultiByte (CP_UTF8,
0,
@ -293,7 +300,7 @@ winClipboardFlushXEvents (HWND hwnd,
xtpText.value = NULL;
/* Create the text property from the text list */
if (fUnicodeSupport)
if (fUseUnicode)
{
#ifdef X_HAVE_UTF8_STRING
iReturn = Xutf8TextListToTextProperty (pDisplay,
@ -586,7 +593,7 @@ winClipboardFlushXEvents (HWND hwnd,
}
#endif
if (fUnicodeSupport)
if (fUseUnicode)
{
#ifdef X_HAVE_UTF8_STRING
/* Convert the text property to a text list */
@ -657,7 +664,7 @@ winClipboardFlushXEvents (HWND hwnd,
/* Convert the X clipboard string to DOS format */
winClipboardUNIXtoDOS (&pszReturnData, strlen (pszReturnData));
if (fUnicodeSupport)
if (fUseUnicode)
{
/* Find out how much space needed to convert MBCS to Unicode */
iUnicodeLen = MultiByteToWideChar (CP_UTF8,
@ -726,7 +733,7 @@ winClipboardFlushXEvents (HWND hwnd,
}
/* Copy the returned string into the global memory */
if (fUnicodeSupport)
if (fUseUnicode)
{
memcpy (pszGlobalData,
pwszUnicodeStr,
@ -746,7 +753,7 @@ winClipboardFlushXEvents (HWND hwnd,
pszGlobalData = NULL;
/* Push the selection data to the Windows clipboard */
if (fUnicodeSupport)
if (fUseUnicode)
SetClipboardData (CF_UNICODETEXT, hGlobal);
else
SetClipboardData (CF_TEXT, hGlobal);
@ -771,9 +778,9 @@ winClipboardFlushXEvents (HWND hwnd,
free (pwszUnicodeStr);
if (hGlobal && pszGlobalData)
GlobalUnlock (hGlobal);
if (fSetClipboardData && fUnicodeSupport)
if (fSetClipboardData && g_fUnicodeSupport)
SetClipboardData (CF_UNICODETEXT, NULL);
if (fSetClipboardData && !fUnicodeSupport)
if (fSetClipboardData)
SetClipboardData (CF_TEXT, NULL);
return WIN_XEVENTS_NOTIFY;

View file

@ -932,7 +932,7 @@ winMWExtWMWindowProc (HWND hwnd, UINT message,
if ((dwWindowProcessID == dwCurrentProcessID)
&& GetProp (Above, WIN_WINDOW_PROP)
&& !IsIconic (hwnd) ) /* ignore minimized windows */
&& !IsIconic (hWndAbove) ) /* ignore minimized windows */
break;
}
/* If this is top of X windows in Windows stack,

80
miext/damage/damage.h Executable file
View file

@ -0,0 +1,80 @@
/*
* $Id$
*
* Copyright © 2003 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _DAMAGE_H_
#define _DAMAGE_H_
typedef struct _damage *DamagePtr;
typedef enum _damageReportLevel {
DamageReportRawRegion,
DamageReportDeltaRegion,
DamageReportBoundingBox,
DamageReportNonEmpty,
DamageReportNone
} DamageReportLevel;
typedef void (*DamageReportFunc) (DamagePtr pDamage, RegionPtr pRegion, void *closure);
typedef void (*DamageDestroyFunc) (DamagePtr pDamage, void *closure);
Bool
DamageSetup (ScreenPtr pScreen);
DamagePtr
DamageCreate (DamageReportFunc damageReport,
DamageDestroyFunc damageDestroy,
DamageReportLevel damageLevel,
Bool isInternal,
ScreenPtr pScreen,
void * closure);
void
DamageDrawInternal (ScreenPtr pScreen, Bool enable);
void
DamageRegister (DrawablePtr pDrawable,
DamagePtr pDamage);
void
DamageUnregister (DrawablePtr pDrawable,
DamagePtr pDamage);
void
DamageDestroy (DamagePtr pDamage);
Bool
DamageSubtract (DamagePtr pDamage,
const RegionPtr pRegion);
void
DamageEmpty (DamagePtr pDamage);
RegionPtr
DamageRegion (DamagePtr pDamage);
void
DamageDamageRegion (DrawablePtr pDrawable,
const RegionPtr pRegion);
#endif /* _DAMAGE_H_ */

403
miext/rootless/README.txt Normal file
View file

@ -0,0 +1,403 @@
Generic Rootless Layer
Version 1.0
July 13, 2004
Torrey T. Lyons
torrey@xfree86.org
Introduction
The generic rootless layer allows an X server to be implemented
on top of another window server in a cooperative manner. This allows the
X11 windows and native windows of the underlying window server to
coexist on the same screen. The layer is called "rootless" because the root
window of the X server is generally not drawn. Instead, each top-level
child of the root window is represented as a separate on-screen window by
the underlying window server. The layer is referred to as "generic"
because it abstracts away the details of the underlying window system and
contains code that is useful for any rootless X server. The code for the
generic rootless layer is located in xc/programs/Xserver/miext/rootless. To
build a complete rootless X server requires a specific rootless
implementation, which provides functions that allow the generic rootless
layer to interact with the underlying window system.
Concepts
In the context of a rootless X server the term window is used to
mean many fundamentally different things. For X11 a window is a DDX
resource that describes a visible, or potentially visible, rectangle on the
screen. A top-level window is a direct child of the root window. To avoid
confusion, an on-screen native window of the underlying window system
is referred to as a "frame". The generic rootless layer associates each
mapped top-level X11 window with a frame. An X11 window may be said
to be "framed" if it or its top-level parent is represented by a frame.
The generic rootless layer models each frame as being backed at
all times by a backing buffer, which is periodically flushed to the screen.
If the underlying window system does not provide a backing buffer for
frames, this must be done by the rootless implementation. The generic
rootless layer model does not assume it always has access to the frames'
backing buffers. Any drawing to the buffer will be proceeded by a call to
the rootless implementation's StartDrawing() function and StopDrawing()
will be called when the drawing is concluded. The address of the frame's
backing buffer is returned by the StartDrawing() function and it can
change between successive calls.
Because each frame is assumed to have a backing buffer, the
generic rootless layer will stop Expose events being generated when the
regions of visibility of a frame change on screen. This is similar to backing
store, but backing buffers are different in that they always store a copy of
the entire window contents, not just the obscured portions. The price paid
in increased memory consumption is made up by the greatly decreased
complexity in not having to track and record regions as they are obscured.
Rootless Implementation
The specifics of the underlying window system are provided to the
generic rootless layer through rootless implementation functions, compile-
time options, and runtime parameters. The rootless implementation
functions are a list of functions that allow the generic rootless layer to
perform operations such as creating, destroying, moving, and resizing
frames. Some of the implementation functions are optional. A detailed
description of the rootless implementation functions is provided in
Appendix A.
By design, a rootless implementation should only have to include
the rootless.h header file. The rootlessCommon.h file contains definitions
internal to the generic rootless layer. (If you find you need to use
rootlessCommon.h in your implementation, let the generic rootless layer
maintainers know. This could be an area where the generic rootless layer
should be generalized.) A rootless implementation should also modify
rootlessConfig.h to specify compile time options for its platform.
The following compile-time options are defined in
rootlessConfig.h:
o ROOTLESS_ACCEL: If true, use the optional rootless acceleration
functions where possible to a accelerate X11 drawing primitives.
If false, all drawing will be done with fb.
o ROOTLESS_GLOBAL_COORDS: This option controls the way that frame
coordinates are passed to the rootless implementation. If false,
the coordinates are passed per screen relative to the origin of
the screen the frame is currently on. Some implementations may
prefer to work in a single global coordinate space that spans all
screens. If this option is true, the coordinates are passed after
adding the coordinates of the screen origin and an overall offset of
(rootlessGlobalOffsetX, rootlessGlobalOffsetY).
o ROOTLESS_PROTECT_ALPHA: By default for a color bit depth of 24 and
32 bits per pixel, fb will overwrite the "unused" 8 bits to optimize
drawing speed. If this is true, the alpha channel of frames is
protected and is not modified when drawing to them. The bits
containing the alpha channel are defined by the macro
RootlessAlphaMask(bpp), which should return a bit mask for
various bits per pixel.
o ROOTLESS_REDISPLAY_DELAY: Time in milliseconds between updates to
the underlying window server. Most operations will be buffered until
this time has expired.
o ROOTLESS_RESIZE_GRAVITY: If the underlying window system supports it,
some frame resizes can be optimized by relying on the frame contents
maintaining a particular gravity during the resize. In this way less
of the frame contents need to be preserved by the generic rootless
layer. If true, the generic rootless layer will pass gravity hints
during resizing and rely on the frame contents being preserved
accordingly.
o ROOTLESS_TRACK_DAMAGE: The generic rootless layer draws to the
frames' backing buffers and periodically flushes the modified
regions to the underlying window server. If this option is true,
the generic rootless layer will track these damaged regions.
Currently it uses the miRegion code and will not simplify damaged
regions even when updating a bounding region would be more
efficient. Some window systems provide a more efficient way to
track damaged regions. If this option is false, the rootless
implementation function DamageRects() is called whenever a
backing buffer is modified and the rootless implementation is
expected to track the damaged regions itself.
The following runtime options are defined in rootless.h:
o rootlessGlobalOffsetX, rootlessGlobalOffsetY: These are only
used if ROOTLESS_GLOBAL_COORDS is true. They specify the global
offset that is applied to all screens when converting from
screen-local to global coordinates.
o rootless_CopyBytes_threshold, rootless_FillBytes_threshold,
rootless_CompositePixels_threshold, rootless_CopyWindow_threshold:
The minimum number of bytes or pixels for which to use the rootless
implementation's respective acceleration function. The rootless
acceleration functions are all optional so these will only be used
if the respective acceleration function pointer is not NULL.
Accelerated Drawing
The rootless implementation typically does not have direct access
to the hardware. Its access to the graphics hardware is generally through
the API of the underlying window system. This underlying API may not
overlap well with the X11 drawing primitives. The generic rootless layer
falls back to using fb for all its 2-D drawing. Providing optional rootless
implementation acceleration functions can accelerate some graphics
primitives and some window functions. Typically calling through to the
underlying window systems API will not speed up these operations for
small enough areas. The rootless_*_threshold runtime options allow the
rootless implementation to provide hints for when the acceleration
functions should be used instead of fb.
Alpha Channel Protection
If the bits per pixel is greater then the color bit depth, the contents
of the extra bits are undefined by the X11 protocol. Some window systems
will use these extra bits as an alpha channel. The generic rootless layer can
be configured to protect these bits and make sure they are not modified by
other parts of the X server. To protect the alpha channel
ROOTLESS_PROTECT_ALPHA and RootlessAlphaMask(bpp) must be
set appropriately as described under the compile time options. This
ensures that the X11 graphics primitives do not overwrite the alpha
channel in an attempt to optimize drawing. In addition, the window
functions PaintWindow() and Composite() must be replaced by alpha
channel safe variants. These are provided in rootless/safeAlpha.
Credits
The generic rootless layer was originally conceived and developed
by Greg Parker as part of the XDarwin X server on Mac OS X. John
Harper made later optimizations to this code but removed its generic
independence of the underlying window system. Torrey T. Lyons
reintroduced the generic abstractions and made the rootless code suitable
for use by other X servers.
Appendix A: Rootless Implementation Functions
The rootless implementation functions are defined in rootless.h. It
is intended that rootless.h contains the complete interface that is needed by
rootless implementations. The definitions contained in rootlessCommon.h
are intended for internal use by the generic rootless layer and are more
likely to change.
Most of these functions take a RootlessFrameID as a parameter.
The RootlessFrameID is an opaque object that is returned by the
implementation's CreateFrame() function. The generic rootless layer does
not use this frame id other than to pass it back to the rootless
implementation to indicate the frame to operate on.
/*
* Create a new frame.
* The frame is created unmapped.
*
* pFrame RootlessWindowPtr for this frame should be completely
* initialized before calling except for pFrame->wid, which
* is set by this function.
* pScreen Screen on which to place the new frame
* newX, newY Position of the frame. These will be identical to pFrame-x,
* pFrame->y unless ROOTLESS_GLOBAL_COORDS is set.
* pNewShape Shape for the frame (in frame-local coordinates). NULL for
* unshaped frames.
*/
typedef Bool (*RootlessCreateFrameProc)
(RootlessWindowPtr pFrame, ScreenPtr pScreen, int newX, int newY,
RegionPtr pNewShape);
/*
* Destroy a frame.
* Drawing is stopped and all updates are flushed before this is called.
*
* wid Frame id
*/
typedef void (*RootlessDestroyFrameProc)
(RootlessFrameID wid);
/*
* Move a frame on screen.
* Drawing is stopped and all updates are flushed before this is called.
*
* wid Frame id
* pScreen Screen to move the new frame to
* newX, newY New position of the frame
*/
typedef void (*RootlessMoveFrameProc)
(RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY);
/*
* Resize and move a frame.
* Drawing is stopped and all updates are flushed before this is called.
*
* wid Frame id
* pScreen Screen to move the new frame to
* newX, newY New position of the frame
* newW, newH New size of the frame
* gravity Gravity for window contents (rl_gravity_enum). This is always
* RL_GRAVITY_NONE unless ROOTLESS_RESIZE_GRAVITY is set.
*/
typedef void (*RootlessResizeFrameProc)
(RootlessFrameID wid, ScreenPtr pScreen,
int newX, int newY, unsigned int newW, unsigned int newH,
unsigned int gravity);
/*
* Change frame ordering (AKA stacking, layering).
* Drawing is stopped before this is called. Unmapped frames are mapped by
* setting their ordering.
*
* wid Frame id
* nextWid Frame id of frame that is now above this one or NULL if this
* frame is at the top.
*/
typedef void (*RootlessRestackFrameProc)
(RootlessFrameID wid, RootlessFrameID nextWid);
/*
* Change frame's shape.
* Drawing is stopped before this is called.
*
* wid Frame id
* pNewShape New shape for the frame (in frame-local coordinates)
* or NULL if now unshaped.
*/
typedef void (*RootlessReshapeFrameProc)
(RootlessFrameID wid, RegionPtr pNewShape);
/*
* Unmap a frame.
*
* wid Frame id
*/
typedef void (*RootlessUnmapFrameProc)
(RootlessFrameID wid);
/*
* Start drawing to a frame.
* Prepare a frame for direct access to its backing buffer.
*
* wid Frame id
* pixelData Address of the backing buffer (returned)
* bytesPerRow Width in bytes of the backing buffer (returned)
*/
typedef void (*RootlessStartDrawingProc)
(RootlessFrameID wid, char **pixelData, int *bytesPerRow);
/*
* Stop drawing to a frame.
* No drawing to the frame's backing buffer will occur until drawing
* is started again.
*
* wid Frame id
* flush Flush drawing updates for this frame to the screen. This
* will always be FALSE if ROOTLESS_TRACK_DAMAGE is set.
*/
typedef void (*RootlessStopDrawingProc)
(RootlessFrameID wid, Bool flush);
/*
* Flush drawing updates to the screen.
* Drawing is stopped before this is called.
*
* wid Frame id
* pDamage Region containing all the changed pixels in frame-local
* coordinates. This is clipped to the window's clip. This
* will be NULL if ROOTLESS_TRACK_DAMAGE is not set.
*/
typedef void (*RootlessUpdateRegionProc)
(RootlessFrameID wid, RegionPtr pDamage);
/*
* Mark damaged rectangles as requiring redisplay to screen.
* This will only be called if ROOTLESS_TRACK_DAMAGE is not set.
*
* wid Frame id
* nrects Number of damaged rectangles
* rects Array of damaged rectangles in frame-local coordinates
* shift_x, Vector to shift rectangles by
* shift_y
*/
typedef void (*RootlessDamageRectsProc)
(RootlessFrameID wid, int nrects, const BoxRec *rects,
int shift_x, int shift_y);
/*
* Switch the window associated with a frame. (Optional)
* When a framed window is reparented, the frame is resized and set to
* use the new top-level parent. If defined this function will be called
* afterwards for implementation specific bookkeeping.
*
* pFrame Frame whose window has switched
* oldWin Previous window wrapped by this frame
*/
typedef void (*RootlessSwitchWindowProc)
(RootlessWindowPtr pFrame, WindowPtr oldWin);
/*
* Copy bytes. (Optional)
* Source and destinate may overlap and the right thing should happen.
*
* width Bytes to copy per row
* height Number of rows
* src Source data
* srcRowBytes Width of source in bytes
* dst Destination data
* dstRowBytes Width of destination in bytes
*/
typedef void (*RootlessCopyBytesProc)
(unsigned int width, unsigned int height,
const void *src, unsigned int srcRowBytes,
void *dst, unsigned int dstRowBytes);
/*
* Fill memory with 32-bit pattern. (Optional)
*
* width Bytes to fill per row
* height Number of rows
* value 32-bit pattern to fill with
* dst Destination data
* dstRowBytes Width of destination in bytes
*/
typedef void (*RootlessFillBytesProc)
(unsigned int width, unsigned int height, unsigned int value,
void *dst, unsigned int dstRowBytes);
/*
* Composite pixels from source and mask to destination. (Optional)
*
* width, height Size of area to composite to in pizels
* function Composite function built with RL_COMPOSITE_FUNCTION
* src Source data
* srcRowBytes Width of source in bytes (Passing NULL means source
* is a single pixel.
* mask Mask data
* maskRowBytes Width of mask in bytes
* dst Destination data
* dstRowBytes Width of destination in bytes
*
* For src and dst, the first element of the array is the color data. If
* the second element is non-null it implies there is alpha data (which
* may be meshed or planar). Data without alpha is assumed to be opaque.
*
* An X11 error code is returned.
*/
typedef int (*RootlessCompositePixelsProc)
(unsigned int width, unsigned int height, unsigned int function,
void *src[2], unsigned int srcRowBytes[2],
void *mask, unsigned int maskRowBytes,
void *dst[2], unsigned int dstRowBytes[2]);
/*
* Copy area in frame to another part of frame. (Optional)
*
* wid Frame id
* dstNrects Number of rectangles to copy
* dstRects Array of rectangles to copy
* dx, dy Number of pixels away to copy area
*/
typedef void (*RootlessCopyWindowProc)
(RootlessFrameID wid, int dstNrects, const BoxRec *dstRects,
int dx, int dy);

752
xfixes/cursor.c Executable file
View file

@ -0,0 +1,752 @@
/*
* $Id$
*
* Copyright © 2002 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "xfixesint.h"
#include "scrnintstr.h"
#include "cursorstr.h"
#include "dixevents.h"
#include "servermd.h"
#include "inputstr.h"
#include "windowstr.h"
static RESTYPE CursorClientType;
static RESTYPE CursorWindowType;
static int CursorScreenPrivateIndex = -1;
static int CursorGeneration;
static CursorPtr CursorCurrent;
#define VERIFY_CURSOR(pCursor, cursor, client, access) { \
pCursor = (CursorPtr)SecurityLookupIDByType((client), (cursor), \
RT_CURSOR, (access)); \
if (!pCursor) { \
(client)->errorValue = (cursor); \
return BadCursor; \
} \
}
/*
* There is a global list of windows selecting for cursor events
*/
typedef struct _CursorEvent *CursorEventPtr;
typedef struct _CursorEvent {
CursorEventPtr next;
CARD32 eventMask;
ClientPtr pClient;
WindowPtr pWindow;
XID clientResource;
} CursorEventRec;
static CursorEventPtr cursorEvents;
/*
* Wrap DisplayCursor to catch cursor change events
*/
typedef struct _CursorScreen {
DisplayCursorProcPtr DisplayCursor;
CloseScreenProcPtr CloseScreen;
} CursorScreenRec, *CursorScreenPtr;
#define GetCursorScreen(s) ((CursorScreenPtr) ((s)->devPrivates[CursorScreenPrivateIndex].ptr))
#define GetCursorScreenIfSet(s) ((CursorScreenPrivateIndex != -1) ? GetCursorScreen(s) : NULL)
#define SetCursorScreen(s,p) ((s)->devPrivates[CursorScreenPrivateIndex].ptr = (pointer) (p))
#define Wrap(as,s,elt,func) (((as)->elt = (s)->elt), (s)->elt = func)
#define Unwrap(as,s,elt) ((s)->elt = (as)->elt)
static Bool
CursorDisplayCursor (ScreenPtr pScreen,
CursorPtr pCursor)
{
CursorScreenPtr cs = GetCursorScreen(pScreen);
Bool ret;
Unwrap (cs, pScreen, DisplayCursor);
ret = (*pScreen->DisplayCursor) (pScreen, pCursor);
if (pCursor != CursorCurrent)
{
CursorEventPtr e;
CursorCurrent = pCursor;
for (e = cursorEvents; e; e = e->next)
{
if (e->eventMask & XFixesDisplayCursorNotifyMask)
{
xXFixesCursorNotifyEvent ev;
ev.type = XFixesEventBase + XFixesCursorNotify;
ev.subtype = XFixesDisplayCursorNotify;
ev.sequenceNumber = e->pClient->sequence;
ev.window = e->pWindow->drawable.id;
ev.cursorSerial = pCursor->serialNumber;
ev.timestamp = currentTime.milliseconds;
ev.name = pCursor->name;
WriteEventsToClient (e->pClient, 1, (xEvent *) &ev);
}
}
}
Wrap (cs, pScreen, DisplayCursor, CursorDisplayCursor);
return ret;
}
static Bool
CursorCloseScreen (int index, ScreenPtr pScreen)
{
CursorScreenPtr cs = GetCursorScreen (pScreen);
Bool ret;
Unwrap (cs, pScreen, CloseScreen);
Unwrap (cs, pScreen, DisplayCursor);
ret = (*pScreen->CloseScreen) (index, pScreen);
xfree (cs);
if (index == 0)
CursorScreenPrivateIndex = -1;
return ret;
}
#define CursorAllEvents (XFixesDisplayCursorNotifyMask)
static int
XFixesSelectCursorInput (ClientPtr pClient,
WindowPtr pWindow,
CARD32 eventMask)
{
CursorEventPtr *prev, e;
for (prev = &cursorEvents; (e = *prev); prev = &e->next)
{
if (e->pClient == pClient &&
e->pWindow == pWindow)
{
break;
}
}
if (!eventMask)
{
if (e)
{
FreeResource (e->clientResource, 0);
}
return Success;
}
if (!e)
{
e = (CursorEventPtr) xalloc (sizeof (CursorEventRec));
if (!e)
return BadAlloc;
e->next = 0;
e->pClient = pClient;
e->pWindow = pWindow;
e->clientResource = FakeClientID(pClient->index);
/*
* Add a resource hanging from the window to
* catch window destroy
*/
if (!LookupIDByType(pWindow->drawable.id, CursorWindowType))
if (!AddResource (pWindow->drawable.id, CursorWindowType,
(pointer) pWindow))
{
xfree (e);
return BadAlloc;
}
if (!AddResource (e->clientResource, CursorClientType, (pointer) e))
return BadAlloc;
*prev = e;
}
e->eventMask = eventMask;
return Success;
}
int
ProcXFixesSelectCursorInput (ClientPtr client)
{
REQUEST (xXFixesSelectCursorInputReq);
WindowPtr pWin;
REQUEST_SIZE_MATCH (xXFixesSelectCursorInputReq);
pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
SecurityReadAccess);
if (!pWin)
return(BadWindow);
if (stuff->eventMask & ~CursorAllEvents)
{
client->errorValue = stuff->eventMask;
return( BadValue );
}
return XFixesSelectCursorInput (client, pWin, stuff->eventMask);
}
static int
GetBit (unsigned char *line, int x)
{
unsigned char mask;
if (screenInfo.bitmapBitOrder == LSBFirst)
mask = (1 << (x & 7));
else
mask = (0x80 >> (x & 7));
/* XXX assumes byte order is host byte order */
line += (x >> 3);
if (*line & mask)
return 1;
return 0;
}
int
SProcXFixesSelectCursorInput (ClientPtr client)
{
register int n;
REQUEST(xXFixesSelectCursorInputReq);
swaps(&stuff->length, n);
swapl(&stuff->window, n);
swapl(&stuff->eventMask, n);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
void
SXFixesCursorNotifyEvent (xXFixesCursorNotifyEvent *from,
xXFixesCursorNotifyEvent *to)
{
to->type = from->type;
cpswaps (from->sequenceNumber, to->sequenceNumber);
cpswapl (from->window, to->window);
cpswapl (from->cursorSerial, to->cursorSerial);
cpswapl (from->timestamp, to->timestamp);
cpswapl (from->name, to->name);
}
static void
CopyCursorToImage (CursorPtr pCursor, CARD32 *image)
{
int width = pCursor->bits->width;
int height = pCursor->bits->height;
int npixels = width * height;
#ifdef ARGB_CURSOR
if (pCursor->bits->argb)
memcpy (image, pCursor->bits->argb, npixels * sizeof (CARD32));
else
#endif
{
unsigned char *srcLine = pCursor->bits->source;
unsigned char *mskLine = pCursor->bits->mask;
int stride = BitmapBytePad (width);
int x, y;
CARD32 fg, bg;
fg = (0xff000000 |
((pCursor->foreRed & 0xff00) << 8) |
(pCursor->foreGreen & 0xff00) |
(pCursor->foreBlue >> 8));
bg = (0xff000000 |
((pCursor->backRed & 0xff00) << 8) |
(pCursor->backGreen & 0xff00) |
(pCursor->backBlue >> 8));
for (y = 0; y < height; y++)
{
for (x = 0; x < width; x++)
{
if (GetBit (mskLine, x))
{
if (GetBit (srcLine, x))
*image++ = fg;
else
*image++ = bg;
}
else
*image++ = 0;
}
srcLine += stride;
mskLine += stride;
}
}
}
int
ProcXFixesGetCursorImage (ClientPtr client)
{
/* REQUEST(xXFixesGetCursorImageReq); */
xXFixesGetCursorImageReply *rep;
CursorPtr pCursor;
CARD32 *image;
int npixels;
int width, height;
int x, y;
REQUEST_SIZE_MATCH(xXFixesGetCursorImageReq);
pCursor = CursorCurrent;
if (!pCursor)
return BadCursor;
GetSpritePosition (&x, &y);
width = pCursor->bits->width;
height = pCursor->bits->height;
npixels = width * height;
rep = xalloc (sizeof (xXFixesGetCursorImageReply) +
npixels * sizeof (CARD32));
if (!rep)
return BadAlloc;
rep->type = X_Reply;
rep->sequenceNumber = client->sequence;
rep->length = npixels;
rep->width = width;
rep->height = height;
rep->x = x;
rep->y = y;
rep->xhot = pCursor->bits->xhot;
rep->yhot = pCursor->bits->yhot;
rep->cursorSerial = pCursor->serialNumber;
image = (CARD32 *) (rep + 1);
CopyCursorToImage (pCursor, image);
if (client->swapped)
{
int n;
swaps (&rep->sequenceNumber, n);
swapl (&rep->length, n);
swaps (&rep->x, n);
swaps (&rep->y, n);
swaps (&rep->width, n);
swaps (&rep->height, n);
swaps (&rep->xhot, n);
swaps (&rep->yhot, n);
swapl (&rep->cursorSerial, n);
SwapLongs (image, npixels);
}
(void) WriteToClient(client, sizeof (xXFixesGetCursorImageReply) +
(npixels << 2), (char *) rep);
xfree (rep);
return client->noClientException;
}
int
SProcXFixesGetCursorImage (ClientPtr client)
{
int n;
REQUEST(xXFixesGetCursorImageReq);
swaps (&stuff->length, n);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
int
ProcXFixesSetCursorName (ClientPtr client)
{
CursorPtr pCursor;
char *tchar;
REQUEST(xXFixesSetCursorNameReq);
Atom atom;
REQUEST_AT_LEAST_SIZE(xXFixesSetCursorNameReq);
VERIFY_CURSOR(pCursor, stuff->cursor, client, SecurityWriteAccess);
tchar = (char *) &stuff[1];
atom = MakeAtom (tchar, stuff->nbytes, TRUE);
if (atom == BAD_RESOURCE)
return BadAlloc;
pCursor->name = atom;
return(client->noClientException);
}
int
SProcXFixesSetCursorName (ClientPtr client)
{
int n;
REQUEST(xXFixesSetCursorNameReq);
swaps (&stuff->length, n);
REQUEST_AT_LEAST_SIZE(xXFixesSetCursorNameReq);
swapl (&stuff->cursor, n);
swaps (&stuff->nbytes, n);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
int
ProcXFixesGetCursorName (ClientPtr client)
{
CursorPtr pCursor;
xXFixesGetCursorNameReply reply;
REQUEST(xXFixesGetCursorNameReq);
char *str;
int len;
REQUEST_SIZE_MATCH(xXFixesGetCursorNameReq);
VERIFY_CURSOR(pCursor, stuff->cursor, client, SecurityReadAccess);
if (pCursor->name)
str = NameForAtom (pCursor->name);
else
str = "";
len = strlen (str);
reply.type = X_Reply;
reply.length = (len + 3) >> 2;
reply.sequenceNumber = client->sequence;
reply.atom = pCursor->name;
reply.nbytes = len;
if (client->swapped)
{
int n;
swaps (&reply.sequenceNumber, n);
swapl (&reply.length, n);
swapl (&reply.atom, n);
swaps (&reply.nbytes, n);
}
WriteReplyToClient(client, sizeof(xXFixesGetCursorNameReply), &reply);
(void)WriteToClient(client, len, str);
return(client->noClientException);
}
int
SProcXFixesGetCursorName (ClientPtr client)
{
int n;
REQUEST(xXFixesSetCursorNameReq);
swaps (&stuff->length, n);
REQUEST_SIZE_MATCH(xXFixesGetCursorNameReq);
swapl (&stuff->cursor, n);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
int
ProcXFixesGetCursorImageAndName (ClientPtr client)
{
/* REQUEST(xXFixesGetCursorImageAndNameReq); */
xXFixesGetCursorImageAndNameReply *rep;
CursorPtr pCursor;
CARD32 *image;
int npixels;
char *name;
int nbytes, nbytesRound;
int width, height;
int x, y;
REQUEST_SIZE_MATCH(xXFixesGetCursorImageAndNameReq);
pCursor = CursorCurrent;
if (!pCursor)
return BadCursor;
GetSpritePosition (&x, &y);
width = pCursor->bits->width;
height = pCursor->bits->height;
npixels = width * height;
name = pCursor->name ? NameForAtom (pCursor->name) : "";
nbytes = strlen (name);
nbytesRound = (nbytes + 3) & ~3;
rep = xalloc (sizeof (xXFixesGetCursorImageAndNameReply) +
npixels * sizeof (CARD32) + nbytesRound);
if (!rep)
return BadAlloc;
rep->type = X_Reply;
rep->sequenceNumber = client->sequence;
rep->length = npixels + (nbytesRound >> 2);
rep->width = width;
rep->height = height;
rep->x = x;
rep->y = y;
rep->xhot = pCursor->bits->xhot;
rep->yhot = pCursor->bits->yhot;
rep->cursorSerial = pCursor->serialNumber;
rep->cursorName = pCursor->name;
rep->nbytes = nbytes;
image = (CARD32 *) (rep + 1);
CopyCursorToImage (pCursor, image);
memcpy ((image + npixels), name, nbytes);
if (client->swapped)
{
int n;
swaps (&rep->sequenceNumber, n);
swapl (&rep->length, n);
swaps (&rep->x, n);
swaps (&rep->y, n);
swaps (&rep->width, n);
swaps (&rep->height, n);
swaps (&rep->xhot, n);
swaps (&rep->yhot, n);
swapl (&rep->cursorSerial, n);
swapl (&rep->cursorName, n);
swaps (&rep->nbytes, n);
SwapLongs (image, npixels);
}
(void) WriteToClient(client, sizeof (xXFixesGetCursorImageAndNameReply) +
(npixels << 2) + nbytesRound, (char *) rep);
xfree (rep);
return client->noClientException;
}
int
SProcXFixesGetCursorImageAndName (ClientPtr client)
{
int n;
REQUEST(xXFixesGetCursorImageAndNameReq);
swaps (&stuff->length, n);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
/*
* Find every cursor reference in the system, ask testCursor
* whether it should be replaced with a reference to pCursor.
*/
typedef Bool (*TestCursorFunc) (CursorPtr pOld, pointer closure);
typedef struct {
RESTYPE type;
TestCursorFunc testCursor;
CursorPtr pNew;
pointer closure;
} ReplaceCursorLookupRec, *ReplaceCursorLookupPtr;
static const RESTYPE CursorRestypes[] = {
RT_WINDOW, RT_PASSIVEGRAB, RT_CURSOR
};
#define NUM_CURSOR_RESTYPES (sizeof (CursorRestypes) / sizeof (CursorRestypes[0]))
static Bool
ReplaceCursorLookup (pointer value, XID id, pointer closure)
{
ReplaceCursorLookupPtr rcl = (ReplaceCursorLookupPtr) closure;
WindowPtr pWin;
GrabPtr pGrab;
CursorPtr pCursor = 0, *pCursorRef = 0;
XID cursor = 0;
switch (rcl->type) {
case RT_WINDOW:
pWin = (WindowPtr) value;
if (pWin->optional)
{
pCursorRef = &pWin->optional->cursor;
pCursor = *pCursorRef;
}
break;
case RT_PASSIVEGRAB:
pGrab = (GrabPtr) value;
pCursorRef = &pGrab->cursor;
pCursor = *pCursorRef;
break;
case RT_CURSOR:
pCursorRef = 0;
pCursor = (CursorPtr) value;
cursor = id;
break;
}
if (pCursor && pCursor != rcl->pNew)
{
if ((*rcl->testCursor) (pCursor, rcl->closure))
{
rcl->pNew->refcnt++;
/* either redirect reference or update resource database */
if (pCursorRef)
*pCursorRef = rcl->pNew;
else
ChangeResourceValue (id, RT_CURSOR, rcl->pNew);
FreeCursor (pCursor, cursor);
}
}
return FALSE; /* keep walking */
}
static void
ReplaceCursor (CursorPtr pCursor,
TestCursorFunc testCursor,
pointer closure)
{
int clientIndex;
int resIndex;
ReplaceCursorLookupRec rcl;
/*
* Cursors exist only in the resource database, windows and grabs.
* All of these are always pointed at by the resource database. Walk
* the whole thing looking for cursors
*/
rcl.testCursor = testCursor;
rcl.pNew = pCursor;
rcl.closure = closure;
/* for each client */
for (clientIndex = 0; clientIndex < currentMaxClients; clientIndex++)
{
if (!clients[clientIndex])
continue;
for (resIndex = 0; resIndex < NUM_CURSOR_RESTYPES; resIndex++)
{
rcl.type = CursorRestypes[resIndex];
/*
* This function walks the entire client resource database
*/
LookupClientResourceComplex (clients[clientIndex],
rcl.type,
ReplaceCursorLookup,
(pointer) &rcl);
}
}
/* this "knows" that WindowHasNewCursor doesn't depend on it's argument */
WindowHasNewCursor (WindowTable[0]);
}
static Bool
TestForCursor (CursorPtr pCursor, pointer closure)
{
return (pCursor == (CursorPtr) closure);
}
int
ProcXFixesChangeCursor (ClientPtr client)
{
CursorPtr pSource, pDestination;
REQUEST(xXFixesChangeCursorReq);
REQUEST_SIZE_MATCH(xXFixesChangeCursorReq);
VERIFY_CURSOR (pSource, stuff->source, client, SecurityReadAccess);
VERIFY_CURSOR (pDestination, stuff->destination, client, SecurityWriteAccess);
ReplaceCursor (pSource, TestForCursor, (pointer) pDestination);
return (client->noClientException);
}
int
SProcXFixesChangeCursor (ClientPtr client)
{
int n;
REQUEST(xXFixesChangeCursorReq);
swaps (&stuff->length, n);
REQUEST_SIZE_MATCH(xXFixesChangeCursorReq);
swapl (&stuff->source, n);
swapl (&stuff->destination, n);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
static Bool
TestForCursorName (CursorPtr pCursor, pointer closure)
{
return (pCursor->name == (Atom) closure);
}
int
ProcXFixesChangeCursorByName (ClientPtr client)
{
CursorPtr pSource;
Atom name;
char *tchar;
REQUEST(xXFixesChangeCursorByNameReq);
REQUEST_FIXED_SIZE(xXFixesChangeCursorByNameReq, stuff->nbytes);
VERIFY_CURSOR(pSource, stuff->source, client, SecurityReadAccess);
tchar = (char *) &stuff[1];
name = MakeAtom (tchar, stuff->nbytes, FALSE);
if (name)
ReplaceCursor (pSource, TestForCursorName, (pointer) name);
return (client->noClientException);
}
int
SProcXFixesChangeCursorByName (ClientPtr client)
{
int n;
REQUEST(xXFixesChangeCursorByNameReq);
swaps (&stuff->length, n);
REQUEST_AT_LEAST_SIZE (xXFixesChangeCursorByNameReq);
swapl (&stuff->source, n);
swaps (&stuff->nbytes, n);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
static int
CursorFreeClient (pointer data, XID id)
{
CursorEventPtr old = (CursorEventPtr) data;
CursorEventPtr *prev, e;
for (prev = &cursorEvents; (e = *prev); prev = &e->next)
{
if (e == old)
{
*prev = e->next;
xfree (e);
break;
}
}
return 1;
}
static int
CursorFreeWindow (pointer data, XID id)
{
WindowPtr pWindow = (WindowPtr) data;
CursorEventPtr e, next;
for (e = cursorEvents; e; e = next)
{
next = e->next;
if (e->pWindow == pWindow)
{
FreeResource (e->clientResource, 0);
}
}
return 1;
}
Bool
XFixesCursorInit (void)
{
int i;
if (CursorGeneration != serverGeneration)
{
CursorScreenPrivateIndex = AllocateScreenPrivateIndex ();
if (CursorScreenPrivateIndex < 0)
return FALSE;
CursorGeneration = serverGeneration;
}
for (i = 0; i < screenInfo.numScreens; i++)
{
ScreenPtr pScreen = screenInfo.screens[i];
CursorScreenPtr cs;
cs = (CursorScreenPtr) xalloc (sizeof (CursorScreenRec));
if (!cs)
return FALSE;
Wrap (cs, pScreen, CloseScreen, CursorCloseScreen);
Wrap (cs, pScreen, DisplayCursor, CursorDisplayCursor);
SetCursorScreen (pScreen, cs);
}
CursorClientType = CreateNewResourceType(CursorFreeClient);
CursorWindowType = CreateNewResourceType(CursorFreeWindow);
return CursorClientType && CursorWindowType;
}

850
xfixes/region.c Executable file
View file

@ -0,0 +1,850 @@
/*
* $Id$
*
* Copyright © 2003 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "xfixesint.h"
#include "scrnintstr.h"
#ifdef RENDER
#include <picturestr.h>
extern int RenderErrBase;
#endif
#include <regionstr.h>
#include <gcstruct.h>
#include <window.h>
RESTYPE RegionResType;
static int
RegionResFree (pointer data, XID id)
{
RegionPtr pRegion = (RegionPtr) data;
REGION_DESTROY (0, pRegion);
return Success;
}
RegionPtr
XFixesRegionCopy (RegionPtr pRegion)
{
RegionPtr pNew = REGION_CREATE (0, REGION_EXTENTS(0, pRegion),
REGION_NUM_RECTS(pRegion));
if (!pNew)
return 0;
if (!REGION_COPY (0, pNew, pRegion))
{
REGION_DESTROY (0, pNew);
return 0;
}
return pNew;
}
Bool
XFixesRegionInit (void)
{
RegionResType = CreateNewResourceType(RegionResFree);
return TRUE;
}
int
ProcXFixesCreateRegion (ClientPtr client)
{
int things;
RegionPtr pRegion;
REQUEST (xXFixesCreateRegionReq);
REQUEST_AT_LEAST_SIZE(xXFixesCreateRegionReq);
LEGAL_NEW_RESOURCE (stuff->region, client);
things = (client->req_len << 2) - sizeof (xXFixesCreateRegionReq);
if (things & 4)
return BadLength;
things >>= 3;
pRegion = RECTS_TO_REGION(0, things, (xRectangle *) (stuff + 1), CT_UNSORTED);
if (!pRegion)
return BadAlloc;
if (!AddResource (stuff->region, RegionResType, (pointer) pRegion))
return BadAlloc;
return(client->noClientException);
}
int
SProcXFixesCreateRegion (ClientPtr client)
{
register int n;
REQUEST(xXFixesCreateRegionReq);
swaps(&stuff->length, n);
REQUEST_AT_LEAST_SIZE(xXFixesCreateRegionReq);
swapl(&stuff->region, n);
SwapRestS(stuff);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
int
ProcXFixesCreateRegionFromBitmap (ClientPtr client)
{
RegionPtr pRegion;
PixmapPtr pPixmap;
REQUEST (xXFixesCreateRegionFromBitmapReq);
REQUEST_SIZE_MATCH (xXFixesCreateRegionFromBitmapReq);
LEGAL_NEW_RESOURCE (stuff->region, client);
pPixmap = (PixmapPtr) SecurityLookupIDByType (client, stuff->bitmap,
RT_PIXMAP,
SecurityReadAccess);
if (!pPixmap)
{
client->errorValue = stuff->bitmap;
return BadPixmap;
}
if (pPixmap->drawable.depth != 1)
return BadMatch;
pRegion = BITMAP_TO_REGION(pPixmap->drawable.pScreen, pPixmap);
if (!pRegion)
return BadAlloc;
if (!AddResource (stuff->region, RegionResType, (pointer) pRegion))
return BadAlloc;
return(client->noClientException);
}
int
SProcXFixesCreateRegionFromBitmap (ClientPtr client)
{
int n;
REQUEST (xXFixesCreateRegionFromBitmapReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH (xXFixesCreateRegionFromBitmapReq);
swapl(&stuff->region, n);
swapl(&stuff->bitmap, n);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
int
ProcXFixesCreateRegionFromWindow (ClientPtr client)
{
RegionPtr pRegion;
Bool copy = TRUE;
WindowPtr pWin;
REQUEST (xXFixesCreateRegionFromWindowReq);
REQUEST_SIZE_MATCH (xXFixesCreateRegionFromWindowReq);
LEGAL_NEW_RESOURCE (stuff->region, client);
pWin = (WindowPtr) LookupIDByType (stuff->window, RT_WINDOW);
if (!pWin)
{
client->errorValue = stuff->window;
return BadWindow;
}
switch (stuff->kind) {
case WindowRegionBounding:
#ifdef SHAPE
pRegion = wBoundingShape(pWin);
if (!pRegion)
#endif
{
pRegion = CreateBoundingShape (pWin);
copy = FALSE;
}
break;
case WindowRegionClip:
#ifdef SHAPE
pRegion = wClipShape(pWin);
if (!pRegion)
#endif
{
pRegion = CreateClipShape (pWin);
copy = FALSE;
}
break;
default:
client->errorValue = stuff->kind;
return BadValue;
}
if (copy && pRegion)
pRegion = XFixesRegionCopy (pRegion);
if (!pRegion)
return BadAlloc;
if (!AddResource (stuff->region, RegionResType, (pointer) pRegion))
return BadAlloc;
return(client->noClientException);
}
int
SProcXFixesCreateRegionFromWindow (ClientPtr client)
{
int n;
REQUEST (xXFixesCreateRegionFromWindowReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH (xXFixesCreateRegionFromWindowReq);
swapl(&stuff->region, n);
swapl(&stuff->window, n);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
int
ProcXFixesCreateRegionFromGC (ClientPtr client)
{
RegionPtr pRegion, pClip;
GCPtr pGC;
REQUEST (xXFixesCreateRegionFromGCReq);
REQUEST_SIZE_MATCH (xXFixesCreateRegionFromGCReq);
LEGAL_NEW_RESOURCE (stuff->region, client);
SECURITY_VERIFY_GC(pGC, stuff->gc, client, SecurityReadAccess);
switch (pGC->clientClipType) {
case CT_PIXMAP:
pRegion = BITMAP_TO_REGION(pGC->pScreen, (PixmapPtr) pGC->clientClip);
if (!pRegion)
return BadAlloc;
break;
case CT_REGION:
pClip = (RegionPtr) pGC->clientClip;
pRegion = XFixesRegionCopy (pClip);
if (!pRegion)
return BadAlloc;
break;
default:
return BadImplementation; /* assume sane server bits */
}
if (!AddResource (stuff->region, RegionResType, (pointer) pRegion))
return BadAlloc;
return(client->noClientException);
}
int
SProcXFixesCreateRegionFromGC (ClientPtr client)
{
int n;
REQUEST (xXFixesCreateRegionFromGCReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH (xXFixesCreateRegionFromGCReq);
swapl(&stuff->region, n);
swapl(&stuff->gc, n);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
int
ProcXFixesCreateRegionFromPicture (ClientPtr client)
{
#ifdef RENDER
RegionPtr pRegion;
PicturePtr pPicture;
REQUEST (xXFixesCreateRegionFromPictureReq);
REQUEST_SIZE_MATCH (xXFixesCreateRegionFromPictureReq);
LEGAL_NEW_RESOURCE (stuff->region, client);
VERIFY_PICTURE(pPicture, stuff->picture, client, SecurityReadAccess,
RenderErrBase + BadPicture);
switch (pPicture->clientClipType) {
case CT_PIXMAP:
pRegion = BITMAP_TO_REGION(pPicture->pDrawable->pScreen,
(PixmapPtr) pPicture->clientClip);
if (!pRegion)
return BadAlloc;
break;
case CT_REGION:
pRegion = XFixesRegionCopy ((RegionPtr) pPicture->clientClip);
if (!pRegion)
return BadAlloc;
break;
default:
return BadImplementation; /* assume sane server bits */
}
if (!AddResource (stuff->region, RegionResType, (pointer) pRegion))
return BadAlloc;
return(client->noClientException);
#else
return BadRequest;
#endif
}
int
SProcXFixesCreateRegionFromPicture (ClientPtr client)
{
int n;
REQUEST (xXFixesCreateRegionFromPictureReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH (xXFixesCreateRegionFromPictureReq);
swapl(&stuff->region, n);
swapl(&stuff->picture, n);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
int
ProcXFixesDestroyRegion (ClientPtr client)
{
REQUEST (xXFixesDestroyRegionReq);
RegionPtr pRegion;
REQUEST_SIZE_MATCH(xXFixesDestroyRegionReq);
VERIFY_REGION(pRegion, stuff->region, client, SecurityWriteAccess);
FreeResource (stuff->region, RT_NONE);
return(client->noClientException);
}
int
SProcXFixesDestroyRegion (ClientPtr client)
{
int n;
REQUEST (xXFixesDestroyRegionReq);
swaps (&stuff->length, n);
REQUEST_SIZE_MATCH(xXFixesDestroyRegionReq);
swapl (&stuff->region, n);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
int
ProcXFixesSetRegion (ClientPtr client)
{
int things;
RegionPtr pRegion, pNew;
REQUEST (xXFixesSetRegionReq);
REQUEST_AT_LEAST_SIZE(xXFixesSetRegionReq);
VERIFY_REGION(pRegion, stuff->region, client, SecurityWriteAccess);
things = (client->req_len << 2) - sizeof (xXFixesCreateRegionReq);
if (things & 4)
return BadLength;
things >>= 3;
pNew = RECTS_TO_REGION(0, things, (xRectangle *) (stuff + 1), CT_UNSORTED);
if (!pNew)
return BadAlloc;
if (!REGION_COPY (0, pRegion, pNew))
{
REGION_DESTROY (0, pNew);
return BadAlloc;
}
REGION_DESTROY (0, pNew);
return(client->noClientException);
}
int
SProcXFixesSetRegion (ClientPtr client)
{
int n;
REQUEST (xXFixesSetRegionReq);
swaps (&stuff->length, n);
REQUEST_AT_LEAST_SIZE(xXFixesSetRegionReq);
swapl (&stuff->region, n);
SwapRestS(stuff);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
int
ProcXFixesCopyRegion (ClientPtr client)
{
RegionPtr pSource, pDestination;
REQUEST (xXFixesCopyRegionReq);
VERIFY_REGION(pSource, stuff->source, client, SecurityReadAccess);
VERIFY_REGION(pDestination, stuff->destination, client, SecurityWriteAccess);
if (!REGION_COPY(pScreen, pDestination, pSource))
return BadAlloc;
return(client->noClientException);
}
int
SProcXFixesCopyRegion (ClientPtr client)
{
int n;
REQUEST (xXFixesCopyRegionReq);
swaps (&stuff->length, n);
REQUEST_AT_LEAST_SIZE(xXFixesCopyRegionReq);
swapl (&stuff->source, n);
swapl (&stuff->destination, n);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
int
ProcXFixesCombineRegion (ClientPtr client)
{
RegionPtr pSource1, pSource2, pDestination;
int ret = Success;
REQUEST (xXFixesCombineRegionReq);
REQUEST_SIZE_MATCH (xXFixesCombineRegionReq);
VERIFY_REGION(pSource1, stuff->source1, client, SecurityReadAccess);
VERIFY_REGION(pSource2, stuff->source2, client, SecurityReadAccess);
VERIFY_REGION(pDestination, stuff->destination, client, SecurityWriteAccess);
switch (stuff->xfixesReqType) {
case X_XFixesUnionRegion:
if (!REGION_UNION (0, pDestination, pSource1, pSource2))
ret = BadAlloc;
break;
case X_XFixesIntersectRegion:
if (!REGION_INTERSECT (0, pDestination, pSource1, pSource2))
ret = BadAlloc;
break;
case X_XFixesSubtractRegion:
if (!REGION_SUBTRACT (0, pDestination, pSource1, pSource2))
ret = BadAlloc;
break;
}
if (ret == Success)
ret = client->noClientException;
return ret;
}
int
SProcXFixesCombineRegion (ClientPtr client)
{
int n;
REQUEST (xXFixesCombineRegionReq);
swaps (&stuff->length, n);
REQUEST_SIZE_MATCH (xXFixesCombineRegionReq);
swapl (&stuff->source1, n);
swapl (&stuff->source2, n);
swapl (&stuff->destination, n);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
int
ProcXFixesInvertRegion (ClientPtr client)
{
RegionPtr pSource, pDestination;
BoxRec bounds;
int ret = Success;
REQUEST(xXFixesInvertRegionReq);
REQUEST_SIZE_MATCH(xXFixesInvertRegionReq);
VERIFY_REGION(pSource, stuff->source, client, SecurityReadAccess);
VERIFY_REGION(pDestination, stuff->destination, client, SecurityWriteAccess);
/* Compute bounds, limit to 16 bits */
bounds.x1 = stuff->x;
bounds.y1 = stuff->y;
if ((int) stuff->x + (int) stuff->width > MAXSHORT)
bounds.x2 = MAXSHORT;
else
bounds.x2 = stuff->x + stuff->width;
if ((int) stuff->y + (int) stuff->height > MAXSHORT)
bounds.y2 = MAXSHORT;
else
bounds.y2 = stuff->y + stuff->height;
if (!REGION_INVERSE(0, pDestination, pSource, &bounds))
ret = BadAlloc;
if (ret == Success)
ret = client->noClientException;
return ret;
}
int
SProcXFixesInvertRegion (ClientPtr client)
{
int n;
REQUEST(xXFixesInvertRegionReq);
swaps (&stuff->length, n);
REQUEST_SIZE_MATCH(xXFixesInvertRegionReq);
swapl (&stuff->source, n);
swaps (&stuff->x, n);
swaps (&stuff->y, n);
swaps (&stuff->width, n);
swaps (&stuff->height, n);
swapl (&stuff->destination, n);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
int
ProcXFixesTranslateRegion (ClientPtr client)
{
RegionPtr pRegion;
REQUEST(xXFixesTranslateRegionReq);
REQUEST_SIZE_MATCH(xXFixesTranslateRegionReq);
VERIFY_REGION(pRegion, stuff->region, client, SecurityWriteAccess);
REGION_TRANSLATE(pScreen, pRegion, stuff->dx, stuff->dy);
return (client->noClientException);
}
int
SProcXFixesTranslateRegion (ClientPtr client)
{
int n;
REQUEST(xXFixesTranslateRegionReq);
swaps (&stuff->length, n);
REQUEST_SIZE_MATCH(xXFixesTranslateRegionReq);
swapl (&stuff->region, n);
swaps (&stuff->dx, n);
swaps (&stuff->dy, n);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
int
ProcXFixesRegionExtents (ClientPtr client)
{
RegionPtr pSource, pDestination;
REQUEST(xXFixesRegionExtentsReq);
REQUEST_SIZE_MATCH(xXFixesRegionExtentsReq);
VERIFY_REGION(pSource, stuff->source, client, SecurityReadAccess);
VERIFY_REGION(pDestination, stuff->destination, client, SecurityWriteAccess);
REGION_RESET (0, pDestination, REGION_EXTENTS (0, pSource));
return (client->noClientException);
}
int
SProcXFixesRegionExtents (ClientPtr client)
{
int n;
REQUEST(xXFixesRegionExtentsReq);
swaps (&stuff->length, n);
REQUEST_SIZE_MATCH(xXFixesRegionExtentsReq);
swapl (&stuff->source, n);
swapl (&stuff->destination, n);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
int
ProcXFixesFetchRegion (ClientPtr client)
{
RegionPtr pRegion;
xXFixesFetchRegionReply *reply;
xRectangle *pRect;
BoxPtr pExtent;
BoxPtr pBox;
int i, nBox;
REQUEST(xXFixesFetchRegionReq);
REQUEST_SIZE_MATCH(xXFixesFetchRegionReq);
VERIFY_REGION(pRegion, stuff->region, client, SecurityReadAccess);
pExtent = REGION_EXTENTS (0, pRegion);
pBox = REGION_RECTS (pRegion);
nBox = REGION_NUM_RECTS (pRegion);
reply = xalloc (sizeof (xXFixesFetchRegionReply) +
nBox * sizeof (xRectangle));
if (!reply)
return BadAlloc;
reply->type = X_Reply;
reply->sequenceNumber = client->sequence;
reply->length = nBox << 1;
reply->x = pExtent->x1;
reply->y = pExtent->y1;
reply->width = pExtent->x2 - pExtent->x1;
reply->height = pExtent->y2 - pExtent->y1;
pRect = (xRectangle *) (reply + 1);
for (i = 0; i < nBox; i++)
{
pRect[i].x = pBox[i].x1;
pRect[i].y = pBox[i].y1;
pRect[i].width = pBox[i].x2 - pBox[i].x1;
pRect[i].height = pBox[i].y2 - pBox[i].y1;
}
if (client->swapped)
{
int n;
swaps (&reply->sequenceNumber, n);
swapl (&reply->length, n);
swaps (&reply->x, n);
swaps (&reply->y, n);
swaps (&reply->width, n);
swaps (&reply->height, n);
SwapShorts ((INT16 *) pRect, nBox * 4);
}
(void) WriteToClient(client, sizeof (xXFixesFetchRegionReply) +
nBox * sizeof (xRectangle), (char *) reply);
xfree (reply);
return (client->noClientException);
}
int
SProcXFixesFetchRegion (ClientPtr client)
{
int n;
REQUEST(xXFixesFetchRegionReq);
swaps (&stuff->length, n);
REQUEST_SIZE_MATCH(xXFixesFetchRegionReq);
swapl (&stuff->region, n);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
int
ProcXFixesSetGCClipRegion (ClientPtr client)
{
GCPtr pGC;
RegionPtr pRegion;
XID vals[2];
REQUEST(xXFixesSetGCClipRegionReq);
REQUEST_SIZE_MATCH(xXFixesSetGCClipRegionReq);
SECURITY_VERIFY_GC(pGC, stuff->gc, client, SecurityWriteAccess);
VERIFY_REGION_OR_NONE (pRegion, stuff->region, client, SecurityReadAccess);
if (pRegion)
{
pRegion = XFixesRegionCopy (pRegion);
if (!pRegion)
return BadAlloc;
}
vals[0] = stuff->xOrigin;
vals[1] = stuff->yOrigin;
DoChangeGC (pGC, GCClipXOrigin|GCClipYOrigin, vals, 0);
(*pGC->funcs->ChangeClip)(pGC, pRegion ? CT_REGION : CT_NONE, (pointer)pRegion, 0);
return (client->noClientException);
}
int
SProcXFixesSetGCClipRegion (ClientPtr client)
{
int n;
REQUEST(xXFixesSetGCClipRegionReq);
swaps (&stuff->length, n);
REQUEST_SIZE_MATCH(xXFixesSetGCClipRegionReq);
swapl (&stuff->gc, n);
swapl (&stuff->region, n);
swaps (&stuff->xOrigin, n);
swaps (&stuff->yOrigin, n);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
typedef RegionPtr (*CreateDftPtr)(WindowPtr pWin);
int
ProcXFixesSetWindowShapeRegion (ClientPtr client)
{
#ifdef SHAPE
WindowPtr pWin;
ScreenPtr pScreen;
RegionPtr pRegion;
RegionPtr *pDestRegion;
int destBounding;
REQUEST(xXFixesSetWindowShapeRegionReq);
REQUEST_SIZE_MATCH(xXFixesSetWindowShapeRegionReq);
pWin = (WindowPtr) LookupIDByType (stuff->dest, RT_WINDOW);
if (!pWin)
{
client->errorValue = stuff->dest;
return BadWindow;
}
VERIFY_REGION_OR_NONE(pRegion, stuff->region, client, SecurityWriteAccess);
switch (stuff->destKind) {
case ShapeBounding:
destBounding = 1;
break;
case ShapeClip:
destBounding = 0;
break;
default:
client->errorValue = stuff->destKind;
return BadValue;
}
pScreen = pWin->drawable.pScreen;
if (pRegion)
{
pRegion = XFixesRegionCopy (pRegion);
if (!pRegion)
return BadAlloc;
if (!pWin->optional)
MakeWindowOptional (pWin);
if (destBounding)
pDestRegion = &pWin->optional->boundingShape;
else
pDestRegion = &pWin->optional->clipShape;
if (stuff->xOff || stuff->yOff)
REGION_TRANSLATE (0, pRegion, stuff->xOff, stuff->yOff);
}
else
{
if (pWin->optional)
{
if (destBounding)
pDestRegion = &pWin->optional->boundingShape;
else
pDestRegion = &pWin->optional->clipShape;
}
else
pDestRegion = &pRegion; /* a NULL region pointer */
}
if (*pDestRegion)
REGION_DESTROY(pScreen, *pDestRegion);
*pDestRegion = pRegion;
(*pScreen->SetShape) (pWin);
SendShapeNotify (pWin, stuff->destKind);
return (client->noClientException);
#else
return BadRequest;
#endif
}
int
SProcXFixesSetWindowShapeRegion (ClientPtr client)
{
int n;
REQUEST(xXFixesSetWindowShapeRegionReq);
swaps (&stuff->length, n);
REQUEST_SIZE_MATCH(xXFixesSetWindowShapeRegionReq);
swapl (&stuff->dest, n);
swaps (&stuff->xOff, n);
swaps (&stuff->yOff, n);
swapl (&stuff->region, n);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
int
ProcXFixesSetPictureClipRegion (ClientPtr client)
{
#ifdef RENDER
PicturePtr pPicture;
RegionPtr pRegion;
ScreenPtr pScreen;
PictureScreenPtr ps;
REQUEST(xXFixesSetPictureClipRegionReq);
REQUEST_SIZE_MATCH (xXFixesSetPictureClipRegionReq);
VERIFY_PICTURE(pPicture, stuff->picture, client, SecurityWriteAccess,
RenderErrBase + BadPicture);
pScreen = pPicture->pDrawable->pScreen;
ps = GetPictureScreen (pScreen);
VERIFY_REGION_OR_NONE(pRegion, stuff->region, client, SecurityReadAccess);
return SetPictureClipRegion (pPicture, stuff->xOrigin, stuff->yOrigin,
pRegion);
#else
return BadRequest;
#endif
}
int
SProcXFixesSetPictureClipRegion (ClientPtr client)
{
int n;
REQUEST(xXFixesSetPictureClipRegionReq);
swaps (&stuff->length, n);
REQUEST_SIZE_MATCH (xXFixesSetPictureClipRegionReq);
swapl (&stuff->picture, n);
swapl (&stuff->region, n);
swaps (&stuff->xOrigin, n);
swaps (&stuff->yOrigin, n);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
int
ProcXFixesExpandRegion (ClientPtr client)
{
RegionPtr pSource, pDestination;
int ret = Success;
REQUEST (xXFixesExpandRegionReq);
BoxPtr pTmp;
BoxPtr pSrc;
int nBoxes;
int i;
REQUEST_SIZE_MATCH (xXFixesExpandRegionReq);
VERIFY_REGION(pSource, stuff->source, client, SecurityReadAccess);
VERIFY_REGION(pDestination, stuff->destination, client, SecurityWriteAccess);
nBoxes = REGION_NUM_RECTS(pSource);
pSrc = REGION_RECTS(pSource);
if (nBoxes)
{
pTmp = xalloc (nBoxes * sizeof (BoxRec));
if (!pTmp)
return BadAlloc;
for (i = 0; i < nBoxes; i++)
{
pTmp[i].x1 = pSrc[i].x1 - stuff->left;
pTmp[i].x2 = pSrc[i].x2 + stuff->right;
pTmp[i].y1 = pSrc[i].y1 - stuff->top;
pTmp[i].y2 = pSrc[i].y2 + stuff->bottom;
}
REGION_EMPTY (pScreen, pDestination);
for (i = 0; i < nBoxes; i++)
{
RegionRec r;
REGION_INIT (pScreen, &r, &pTmp[i], 0);
REGION_UNION (pScreen, pDestination, pDestination, &r);
}
}
if (ret == Success)
ret = client->noClientException;
return ret;
}
int
SProcXFixesExpandRegion (ClientPtr client)
{
int n;
REQUEST (xXFixesExpandRegionReq);
swaps (&stuff->length, n);
REQUEST_SIZE_MATCH (xXFixesExpandRegionReq);
swapl (&stuff->source, n);
swapl (&stuff->destination, n);
swaps (&stuff->left, n);
swaps (&stuff->right, n);
swaps (&stuff->top, n);
swaps (&stuff->bottom, n);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}

78
xfixes/saveset.c Executable file
View file

@ -0,0 +1,78 @@
/*
* $Id$
*
* Copyright © 2002 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "xfixesint.h"
int
ProcXFixesChangeSaveSet(ClientPtr client)
{
Bool toRoot, remap;
int result;
WindowPtr pWin;
REQUEST(xXFixesChangeSaveSetReq);
REQUEST_SIZE_MATCH(xXFixesChangeSaveSetReq);
pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
SecurityReadAccess);
if (!pWin)
return(BadWindow);
if (client->clientAsMask == (CLIENT_BITS(pWin->drawable.id)))
return BadMatch;
if ((stuff->mode != SetModeInsert) && (stuff->mode != SetModeDelete))
{
client->errorValue = stuff->mode;
return( BadValue );
}
if ((stuff->target != SaveSetNearest) && (stuff->target != SaveSetRoot))
{
client->errorValue = stuff->target;
return( BadValue );
}
if ((stuff->map != SaveSetMap) && (stuff->map != SaveSetUnmap))
{
client->errorValue = stuff->map;
return( BadValue );
}
toRoot = (stuff->target == SaveSetRoot);
remap = (stuff->map == SaveSetMap);
result = AlterSaveSetForClient(client, pWin, stuff->mode, toRoot, remap);
if (client->noClientException != Success)
return(client->noClientException);
else
return(result);
}
int
SProcXFixesChangeSaveSet(ClientPtr client)
{
register int n;
REQUEST(xXFixesChangeSaveSetReq);
swaps(&stuff->length, n);
swapl(&stuff->window, n);
return ProcXFixesChangeSaveSet(client);
}

278
xfixes/select.c Executable file
View file

@ -0,0 +1,278 @@
/*
* $Id$
*
* Copyright © 2002 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "xfixesint.h"
static RESTYPE SelectionClientType, SelectionWindowType;
static Bool SelectionCallbackRegistered = FALSE;
/*
* There is a global list of windows selecting for selection events
* on every selection. This should be plenty efficient for the
* expected usage, if it does become a problem, it should be easily
* replaced with a hash table of some kind keyed off the selection atom
*/
typedef struct _SelectionEvent *SelectionEventPtr;
typedef struct _SelectionEvent {
SelectionEventPtr next;
Atom selection;
CARD32 eventMask;
ClientPtr pClient;
WindowPtr pWindow;
XID clientResource;
} SelectionEventRec;
static SelectionEventPtr selectionEvents;
static void
XFixesSelectionCallback (CallbackListPtr *callbacks, pointer data, pointer args)
{
SelectionEventPtr e;
SelectionInfoRec *info = (SelectionInfoRec *) args;
Selection *selection = info->selection;
int subtype;
CARD32 eventMask;
switch (info->kind) {
case SelectionSetOwner:
subtype = XFixesSetSelectionOwnerNotify;
eventMask = XFixesSetSelectionOwnerNotifyMask;
break;
case SelectionWindowDestroy:
subtype = XFixesSelectionWindowDestroyNotify;
eventMask = XFixesSelectionWindowDestroyNotifyMask;
break;
case SelectionClientClose:
subtype = XFixesSelectionClientCloseNotify;
eventMask = XFixesSelectionClientCloseNotifyMask;
break;
default:
return;
}
for (e = selectionEvents; e; e = e->next)
{
if (e->selection == selection->selection && (e->eventMask & eventMask))
{
xXFixesSelectionNotifyEvent ev;
ev.type = XFixesEventBase + XFixesSelectionNotify;
ev.subtype = subtype;
ev.sequenceNumber = e->pClient->sequence;
ev.window = e->pWindow->drawable.id;
if (subtype == XFixesSetSelectionOwnerNotify)
ev.owner = selection->window;
else
ev.owner = 0;
ev.selection = e->selection;
ev.timestamp = currentTime.milliseconds;
ev.selectionTimestamp = selection->lastTimeChanged.milliseconds;
WriteEventsToClient (e->pClient, 1, (xEvent *) &ev);
}
}
}
static Bool
CheckSelectionCallback (void)
{
if (selectionEvents)
{
if (!SelectionCallbackRegistered)
{
if (!AddCallback (&SelectionCallback, XFixesSelectionCallback, NULL))
return FALSE;
SelectionCallbackRegistered = TRUE;
}
}
else
{
if (SelectionCallbackRegistered)
{
DeleteCallback (&SelectionCallback, XFixesSelectionCallback, NULL);
SelectionCallbackRegistered = FALSE;
}
}
return TRUE;
}
#define SelectionAllEvents (XFixesSetSelectionOwnerNotifyMask |\
XFixesSelectionWindowDestroyNotifyMask |\
XFixesSelectionClientCloseNotifyMask)
static int
XFixesSelectSelectionInput (ClientPtr pClient,
Atom selection,
WindowPtr pWindow,
CARD32 eventMask)
{
SelectionEventPtr *prev, e;
for (prev = &selectionEvents; (e = *prev); prev = &e->next)
{
if (e->selection == selection &&
e->pClient == pClient &&
e->pWindow == pWindow)
{
break;
}
}
if (!eventMask)
{
if (e)
{
FreeResource (e->clientResource, 0);
}
return Success;
}
if (!e)
{
e = (SelectionEventPtr) xalloc (sizeof (SelectionEventRec));
if (!e)
return BadAlloc;
e->next = 0;
e->selection = selection;
e->pClient = pClient;
e->pWindow = pWindow;
e->clientResource = FakeClientID(pClient->index);
/*
* Add a resource hanging from the window to
* catch window destroy
*/
if (!LookupIDByType(pWindow->drawable.id, SelectionWindowType))
if (!AddResource (pWindow->drawable.id, SelectionWindowType,
(pointer) pWindow))
{
xfree (e);
return BadAlloc;
}
if (!AddResource (e->clientResource, SelectionClientType, (pointer) e))
return BadAlloc;
*prev = e;
if (!CheckSelectionCallback ())
{
FreeResource (e->clientResource, 0);
return BadAlloc;
}
}
e->eventMask = eventMask;
return Success;
}
int
ProcXFixesSelectSelectionInput (ClientPtr client)
{
REQUEST (xXFixesSelectSelectionInputReq);
WindowPtr pWin;
REQUEST_SIZE_MATCH (xXFixesSelectSelectionInputReq);
pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
SecurityReadAccess);
if (!pWin)
return(BadWindow);
if (stuff->eventMask & ~SelectionAllEvents)
{
client->errorValue = stuff->eventMask;
return( BadValue );
}
return XFixesSelectSelectionInput (client, stuff->selection,
pWin, stuff->eventMask);
}
int
SProcXFixesSelectSelectionInput (ClientPtr client)
{
register int n;
REQUEST(xXFixesSelectSelectionInputReq);
swaps(&stuff->length, n);
swapl(&stuff->window, n);
swapl(&stuff->selection, n);
swapl(&stuff->eventMask, n);
return ProcXFixesSelectSelectionInput(client);
}
void
SXFixesSelectionNotifyEvent (xXFixesSelectionNotifyEvent *from,
xXFixesSelectionNotifyEvent *to)
{
to->type = from->type;
cpswaps (from->sequenceNumber, to->sequenceNumber);
cpswapl (from->window, to->window);
cpswapl (from->owner, to->owner);
cpswapl (from->selection, to->selection);
cpswapl (from->timestamp, to->timestamp);
cpswapl (from->selectionTimestamp, to->selectionTimestamp);
}
static int
SelectionFreeClient (pointer data, XID id)
{
SelectionEventPtr old = (SelectionEventPtr) data;
SelectionEventPtr *prev, e;
for (prev = &selectionEvents; (e = *prev); prev = &e->next)
{
if (e == old)
{
*prev = e->next;
xfree (e);
CheckSelectionCallback ();
break;
}
}
return 1;
}
static int
SelectionFreeWindow (pointer data, XID id)
{
WindowPtr pWindow = (WindowPtr) data;
SelectionEventPtr e, next;
for (e = selectionEvents; e; e = next)
{
next = e->next;
if (e->pWindow == pWindow)
{
FreeResource (e->clientResource, 0);
}
}
return 1;
}
Bool
XFixesSelectionInit (void)
{
SelectionClientType = CreateNewResourceType(SelectionFreeClient);
SelectionWindowType = CreateNewResourceType(SelectionFreeWindow);
return SelectionClientType && SelectionWindowType;
}

230
xfixes/xfixes.c Executable file
View file

@ -0,0 +1,230 @@
/*
* $Id$
*
* Copyright © 2002 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "xfixesint.h"
unsigned char XFixesReqCode;
int XFixesEventBase;
int XFixesErrorBase;
int XFixesClientPrivateIndex;
static int
ProcXFixesQueryVersion(ClientPtr client)
{
XFixesClientPtr pXFixesClient = GetXFixesClient (client);
xXFixesQueryVersionReply rep;
register int n;
REQUEST(xXFixesQueryVersionReq);
REQUEST_SIZE_MATCH(xXFixesQueryVersionReq);
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
if (stuff->majorVersion < XFIXES_MAJOR) {
rep.majorVersion = stuff->majorVersion;
rep.minorVersion = stuff->minorVersion;
} else {
rep.majorVersion = XFIXES_MAJOR;
if (stuff->majorVersion == XFIXES_MAJOR &&
stuff->minorVersion < XFIXES_MINOR)
rep.minorVersion = stuff->minorVersion;
else
rep.minorVersion = XFIXES_MINOR;
}
pXFixesClient->major_version = rep.majorVersion;
pXFixesClient->minor_version = rep.minorVersion;
if (client->swapped) {
swaps(&rep.sequenceNumber, n);
swapl(&rep.length, n);
swapl(&rep.majorVersion, n);
swapl(&rep.minorVersion, n);
}
WriteToClient(client, sizeof(xXFixesQueryVersionReply), (char *)&rep);
return(client->noClientException);
}
/* Major version controls available requests */
static const int version_requests[] = {
X_XFixesQueryVersion, /* before client sends QueryVersion */
X_XFixesGetCursorImage, /* Version 1 */
X_XFixesChangeCursorByName, /* Version 2 */
X_XFixesExpandRegion, /* Version 3 */
};
#define NUM_VERSION_REQUESTS (sizeof (version_requests) / sizeof (version_requests[0]))
int (*ProcXFixesVector[XFixesNumberRequests])(ClientPtr) = {
/*************** Version 1 ******************/
ProcXFixesQueryVersion,
ProcXFixesChangeSaveSet,
ProcXFixesSelectSelectionInput,
ProcXFixesSelectCursorInput,
ProcXFixesGetCursorImage,
/*************** Version 2 ******************/
ProcXFixesCreateRegion,
ProcXFixesCreateRegionFromBitmap,
ProcXFixesCreateRegionFromWindow,
ProcXFixesCreateRegionFromGC,
ProcXFixesCreateRegionFromPicture,
ProcXFixesDestroyRegion,
ProcXFixesSetRegion,
ProcXFixesCopyRegion,
ProcXFixesCombineRegion,
ProcXFixesCombineRegion,
ProcXFixesCombineRegion,
ProcXFixesInvertRegion,
ProcXFixesTranslateRegion,
ProcXFixesRegionExtents,
ProcXFixesFetchRegion,
ProcXFixesSetGCClipRegion,
ProcXFixesSetWindowShapeRegion,
ProcXFixesSetPictureClipRegion,
ProcXFixesSetCursorName,
ProcXFixesGetCursorName,
ProcXFixesGetCursorImageAndName,
ProcXFixesChangeCursor,
ProcXFixesChangeCursorByName,
/*************** Version 3 ******************/
ProcXFixesExpandRegion,
};
static int
ProcXFixesDispatch (ClientPtr client)
{
REQUEST(xXFixesReq);
XFixesClientPtr pXFixesClient = GetXFixesClient (client);
if (pXFixesClient->major_version > NUM_VERSION_REQUESTS)
return BadRequest;
if (stuff->xfixesReqType > version_requests[pXFixesClient->major_version])
return BadRequest;
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
static int
SProcXFixesQueryVersion(ClientPtr client)
{
register int n;
REQUEST(xXFixesQueryVersionReq);
swaps(&stuff->length, n);
swapl(&stuff->majorVersion, n);
swapl(&stuff->minorVersion, n);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
int (*SProcXFixesVector[XFixesNumberRequests])(ClientPtr) = {
/*************** Version 1 ******************/
SProcXFixesQueryVersion,
SProcXFixesChangeSaveSet,
SProcXFixesSelectSelectionInput,
SProcXFixesSelectCursorInput,
SProcXFixesGetCursorImage,
/*************** Version 2 ******************/
SProcXFixesCreateRegion,
SProcXFixesCreateRegionFromBitmap,
SProcXFixesCreateRegionFromWindow,
SProcXFixesCreateRegionFromGC,
SProcXFixesCreateRegionFromPicture,
SProcXFixesDestroyRegion,
SProcXFixesSetRegion,
SProcXFixesCopyRegion,
SProcXFixesCombineRegion,
SProcXFixesCombineRegion,
SProcXFixesCombineRegion,
SProcXFixesInvertRegion,
SProcXFixesTranslateRegion,
SProcXFixesRegionExtents,
SProcXFixesFetchRegion,
SProcXFixesSetGCClipRegion,
SProcXFixesSetWindowShapeRegion,
SProcXFixesSetPictureClipRegion,
SProcXFixesSetCursorName,
SProcXFixesGetCursorName,
SProcXFixesGetCursorImageAndName,
SProcXFixesChangeCursor,
SProcXFixesChangeCursorByName,
/*************** Version 3 ******************/
SProcXFixesExpandRegion,
};
static int
SProcXFixesDispatch (ClientPtr client)
{
REQUEST(xXFixesReq);
if (stuff->xfixesReqType >= XFixesNumberRequests)
return BadRequest;
return (*SProcXFixesVector[stuff->xfixesReqType]) (client);
}
static void
XFixesClientCallback (CallbackListPtr *list,
pointer closure,
pointer data)
{
NewClientInfoRec *clientinfo = (NewClientInfoRec *) data;
ClientPtr pClient = clientinfo->client;
XFixesClientPtr pXFixesClient = GetXFixesClient (pClient);
pXFixesClient->major_version = 0;
pXFixesClient->minor_version = 0;
}
/*ARGSUSED*/
static void
XFixesResetProc (ExtensionEntry *extEntry)
{
DeleteCallback (&ClientStateCallback, XFixesClientCallback, 0);
}
void
XFixesExtensionInit(void)
{
ExtensionEntry *extEntry;
XFixesClientPrivateIndex = AllocateClientPrivateIndex ();
if (!AllocateClientPrivate (XFixesClientPrivateIndex,
sizeof (XFixesClientRec)))
return;
if (!AddCallback (&ClientStateCallback, XFixesClientCallback, 0))
return;
if (XFixesSelectionInit() && XFixesCursorInit () && XFixesRegionInit () &&
(extEntry = AddExtension(XFIXES_NAME, XFixesNumberEvents,
XFixesNumberErrors,
ProcXFixesDispatch, SProcXFixesDispatch,
XFixesResetProc, StandardMinorOpcode)) != 0)
{
XFixesReqCode = (unsigned char)extEntry->base;
XFixesEventBase = extEntry->eventBase;
XFixesErrorBase = extEntry->errorBase;
EventSwapVector[XFixesEventBase + XFixesSelectionNotify] =
(EventSwapPtr) SXFixesSelectionNotifyEvent;
EventSwapVector[XFixesEventBase + XFixesCursorNotify] =
(EventSwapPtr) SXFixesCursorNotifyEvent;
}
}

50
xfixes/xfixes.h Executable file
View file

@ -0,0 +1,50 @@
/*
* $Id$
*
* Copyright © 2002 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _XFIXES_H_
#define _XFIXES_H_
#include "resource.h"
extern RESTYPE RegionResType;
extern int XFixesErrorBase;
#define VERIFY_REGION(pRegion, rid, client, mode) { \
pRegion = SecurityLookupIDByType (client, rid, RegionResType, mode); \
if (!pRegion) { \
client->errorValue = rid; \
return XFixesErrorBase + BadRegion; \
} \
}
#define VERIFY_REGION_OR_NONE(pRegion, rid, client, mode) { \
pRegion = 0; \
if (rid) VERIFY_REGION(pRegion, rid, client, mode); \
}
RegionPtr
XFixesRegionCopy (RegionPtr pRegion);
#endif /* _XFIXES_H_ */

239
xfixes/xfixesint.h Executable file
View file

@ -0,0 +1,239 @@
/*
* $Id$
*
* Copyright © 2002 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _XFIXESINT_H_
#define _XFIXESINT_H_
#define NEED_EVENTS
#include <X11/X.h>
#include <X11/Xproto.h>
#include "misc.h"
#include "os.h"
#include "dixstruct.h"
#include "extnsionst.h"
#include <X11/extensions/xfixesproto.h>
#include "windowstr.h"
#include "selection.h"
#include "xfixes.h"
extern unsigned char XFixesReqCode;
extern int XFixesEventBase;
extern int XFixesClientPrivateIndex;
typedef struct _XFixesClient {
CARD32 major_version;
CARD32 minor_version;
} XFixesClientRec, *XFixesClientPtr;
#define GetXFixesClient(pClient) ((XFixesClientPtr) (pClient)->devPrivates[XFixesClientPrivateIndex].ptr)
extern int (*ProcXFixesVector[XFixesNumberRequests])(ClientPtr);
extern int (*SProcXFixesVector[XFixesNumberRequests])(ClientPtr);
/* Initialize extension at server startup time */
void
XFixesExtensionInit(void);
/* Save set */
int
ProcXFixesChangeSaveSet(ClientPtr client);
int
SProcXFixesChangeSaveSet(ClientPtr client);
/* Selection events */
int
ProcXFixesSelectSelectionInput (ClientPtr client);
int
SProcXFixesSelectSelectionInput (ClientPtr client);
void
SXFixesSelectionNotifyEvent (xXFixesSelectionNotifyEvent *from,
xXFixesSelectionNotifyEvent *to);
Bool
XFixesSelectionInit (void);
/* Cursor notification */
Bool
XFixesCursorInit (void);
int
ProcXFixesSelectCursorInput (ClientPtr client);
int
SProcXFixesSelectCursorInput (ClientPtr client);
void
SXFixesCursorNotifyEvent (xXFixesCursorNotifyEvent *from,
xXFixesCursorNotifyEvent *to);
int
ProcXFixesGetCursorImage (ClientPtr client);
int
SProcXFixesGetCursorImage (ClientPtr client);
/* Cursor names (Version 2) */
int
ProcXFixesSetCursorName (ClientPtr client);
int
SProcXFixesSetCursorName (ClientPtr client);
int
ProcXFixesGetCursorName (ClientPtr client);
int
SProcXFixesGetCursorName (ClientPtr client);
int
ProcXFixesGetCursorImageAndName (ClientPtr client);
int
SProcXFixesGetCursorImageAndName (ClientPtr client);
/* Cursor replacement (Version 2) */
int
ProcXFixesChangeCursor (ClientPtr client);
int
SProcXFixesChangeCursor (ClientPtr client);
int
ProcXFixesChangeCursorByName (ClientPtr client);
int
SProcXFixesChangeCursorByName (ClientPtr client);
/* Region objects (Version 2* */
Bool
XFixesRegionInit (void);
int
ProcXFixesCreateRegion (ClientPtr client);
int
SProcXFixesCreateRegion (ClientPtr client);
int
ProcXFixesCreateRegionFromBitmap (ClientPtr client);
int
SProcXFixesCreateRegionFromBitmap (ClientPtr client);
int
ProcXFixesCreateRegionFromWindow (ClientPtr client);
int
SProcXFixesCreateRegionFromWindow (ClientPtr client);
int
ProcXFixesCreateRegionFromGC (ClientPtr client);
int
SProcXFixesCreateRegionFromGC (ClientPtr client);
int
ProcXFixesCreateRegionFromPicture (ClientPtr client);
int
SProcXFixesCreateRegionFromPicture (ClientPtr client);
int
ProcXFixesDestroyRegion (ClientPtr client);
int
SProcXFixesDestroyRegion (ClientPtr client);
int
ProcXFixesSetRegion (ClientPtr client);
int
SProcXFixesSetRegion (ClientPtr client);
int
ProcXFixesCopyRegion (ClientPtr client);
int
SProcXFixesCopyRegion (ClientPtr client);
int
ProcXFixesCombineRegion (ClientPtr client);
int
SProcXFixesCombineRegion (ClientPtr client);
int
ProcXFixesInvertRegion (ClientPtr client);
int
SProcXFixesInvertRegion (ClientPtr client);
int
ProcXFixesTranslateRegion (ClientPtr client);
int
SProcXFixesTranslateRegion (ClientPtr client);
int
ProcXFixesRegionExtents (ClientPtr client);
int
SProcXFixesRegionExtents (ClientPtr client);
int
ProcXFixesFetchRegion (ClientPtr client);
int
SProcXFixesFetchRegion (ClientPtr client);
int
ProcXFixesSetGCClipRegion (ClientPtr client);
int
SProcXFixesSetGCClipRegion (ClientPtr client);
int
ProcXFixesSetWindowShapeRegion (ClientPtr client);
int
SProcXFixesSetWindowShapeRegion (ClientPtr client);
int
ProcXFixesSetPictureClipRegion (ClientPtr client);
int
SProcXFixesSetPictureClipRegion (ClientPtr client);
int
ProcXFixesExpandRegion (ClientPtr client);
int
SProcXFixesExpandRegion (ClientPtr client);
#endif /* _XFIXESINT_H_ */