Compare commits

...

21 Commits

Author SHA1 Message Date
Stuart Kreitman ca9818d109 Memory overrun due to incomplete implementation of saveSetElt data
structure
Modified Files: Tag: DAMAGE-XFIXES window.c dixutils.c
2004-04-02 06:31:37 +00:00
Stuart Kreitman d7684c666f Needs selection callback code for xfixes (from modular tree) Modified
Files: Tag: DAMAGE-XFIXES dispatch.c
2004-03-30 21:10:39 +00:00
Stuart Kreitman aa93524667 more forward declarations needed Modified Files: Tag: DAMAGE-XFIXES
miinitext.c
2004-03-30 20:40:06 +00:00
Stuart Kreitman 0fe93ec3e9 These files are best left in Xserver/include Removed Files: Tag:
DAMAGE-XFIXES glyphstr.h mipict.h picture.h picturestr.h
2004-03-30 20:04:50 +00:00
Stuart Kreitman 320278947b typo error around XFIXES macros. Modified Files: Tag: DAMAGE-XFIXES
miinitext.c
2004-03-30 19:32:53 +00:00
Stuart Kreitman 3bdf51935c integration from modular tree. Modified Files: Tag: DAMAGE-XFIXES
miinitext.c
2004-03-30 18:44:05 +00:00
Stuart Kreitman 5d175341e0 Integration from modular tree Added Files: Tag: DAMAGE-XFIXES Imakefile
cursor.c region.c saveset.c select.c xfixes.c xfixes.h xfixesint.h
2004-03-30 18:31:54 +00:00
Stuart Kreitman e681e1fc4a integration from modular tree. Added Files: Tag: DAMAGE-XFIXES Imakefile
damage.c damage.h damagestr.h
2004-03-30 17:41:24 +00:00
Stuart Kreitman 97162b0a4f integration from modular tree in support of damage ext. Modified Files:
Tag: DAMAGE-XFIXES filter.c
2004-03-30 17:34:45 +00:00
Stuart Kreitman 0b4b3cae27 integration of _some_ of render from modular tree in support of damage ext.
Modified Files: Tag: DAMAGE-XFIXES picture.c
2004-03-30 17:31:26 +00:00
Stuart Kreitman ee8cb1f24d integration from modular tree Modified Files: Tag: DAMAGE-XFIXES shape.c 2004-03-30 17:20:57 +00:00
Stuart Kreitman 9ea8f62e05 integration from modular tree. Modified Files: Tag: DAMAGE-XFIXES
dixstruct.h
2004-03-30 17:01:52 +00:00
Stuart Kreitman 804cea79f7 integration from modular tree. Modified Files: Tag: DAMAGE-XFIXES dix.h 2004-03-30 17:00:59 +00:00
Stuart Kreitman c0fcd05467 integration from modular tree Modified Files: Tag: DAMAGE-XFIXES
cursorstr.h
2004-03-30 16:59:17 +00:00
Stuart Kreitman 8770e07e22 integration from modular tree, some additional functions exported for the
benefit of damage ext. Modified Files: Tag: DAMAGE-XFIXES window.h
2004-03-30 16:51:08 +00:00
Stuart Kreitman f984253b40 integration of damage/xfixes from modular tree requires migration of
streamlined changes to region macros. Modified Files: Tag:
    DAMAGE-XFIXES regionstr.h
2004-03-30 16:46:23 +00:00
Stuart Kreitman 58747c996e integration from modular tree. Modified Files: Tag: DAMAGE-XFIXES
dispatch.c
2004-03-30 16:44:09 +00:00
Stuart Kreitman 66820785be Integration from modular tree. Modified Files: Tag: DAMAGE-XFIXES window.c 2004-03-30 16:38:13 +00:00
Stuart Kreitman a2a26e69c2 First integration from modular tree. Modified Files: Tag: DAMAGE-XFIXES
events.c
2004-03-30 16:36:09 +00:00
Stuart Kreitman 478b62a407 First integration from modular tree Modified Files: Tag: DAMAGE-XFIXES
dixutils.c
2004-03-30 16:35:06 +00:00
Stuart Kreitman c8cf81cfe9 Integration of DAMAGE backported from modular tree Added Files: Tag:
DAMAGE-XFIXES Imakefile damageext.c damageext.h damageextint.h
2004-03-30 02:16:15 +00:00
30 changed files with 5336 additions and 1167 deletions

View File

@ -61,7 +61,7 @@ static int ShapeFreeEvents(
pointer /* data */,
XID /* id */
);
static void SendShapeNotify(
void SendShapeNotify(
WindowPtr /* pWin */,
int /* which */
);
@ -87,8 +87,8 @@ RegionOperate (
#define CREATE_PROC(func) RegionPtr func(WindowPtr /* pWin */)
static CREATE_PROC(CreateBoundingShape);
static CREATE_PROC(CreateClipShape);
CREATE_PROC(CreateBoundingShape);
CREATE_PROC(CreateClipShape);
#undef CREATE_PROC
@ -261,7 +261,7 @@ RegionOperate (client, pWin, kind, destRgnp, srcRgn, op, xoff, yoff, create)
return Success;
}
static RegionPtr
RegionPtr
CreateBoundingShape (pWin)
WindowPtr pWin;
{
@ -274,7 +274,7 @@ CreateBoundingShape (pWin)
return REGION_CREATE(pWin->drawable.pScreen, &extents, 1);
}
static RegionPtr
RegionPtr
CreateClipShape (pWin)
WindowPtr pWin;
{
@ -880,7 +880,7 @@ ProcShapeSelectInput (client)
* deliver the event
*/
static void
void
SendShapeNotify (pWin, which)
WindowPtr pWin;
int which;

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_ */

View File

@ -131,6 +131,7 @@ extern char *ConnectionInfo;
Selection *CurrentSelections;
int NumCurrentSelections;
CallbackListPtr SelectionCallback = NULL;
static ClientPtr grabClient;
#define GrabNone 0
@ -462,6 +463,9 @@ Dispatch(void)
client->errorValue, result);
break;
}
#ifdef DAMAGEEXT
FlushIfCriticalOutputPending ();
#endif
}
FlushAllOutput();
#ifdef SMART_SCHEDULE
@ -627,7 +631,7 @@ ProcChangeSaveSet(client)
return BadMatch;
if ((stuff->mode == SetModeInsert) || (stuff->mode == SetModeDelete))
{
result = AlterSaveSetForClient(client, pWin, stuff->mode);
result = AlterSaveSetForClient(client, pWin, stuff->mode,FALSE,TRUE);
if (client->noClientException != Success)
return(client->noClientException);
else
@ -1040,6 +1044,14 @@ ProcSetSelectionOwner(client)
CurrentSelections[i].window = stuff->window;
CurrentSelections[i].pWin = pWin;
CurrentSelections[i].client = (pWin ? client : NullClient);
if (SelectionCallback)
{
SelectionInfoRec info;
info.selection = &CurrentSelections[i];
info.kind= SelectionSetOwner;
CallCallbacks(&SelectionCallback, &info);
}
return (client->noClientException);
}
else
@ -3720,7 +3732,7 @@ void InitClient(client, i, ospriv)
client->lastGC = (GCPtr) NULL;
client->lastGCID = INVALID;
client->numSaved = 0;
client->saveSet = (pointer *)NULL;
client->saveSet = (SaveSetElt *)NULL;
client->noClientException = Success;
#ifdef DEBUG
client->requestLogIndex = 0;
@ -4053,6 +4065,14 @@ DeleteWindowFromAnySelections(pWin)
for (i = 0; i< NumCurrentSelections; i++)
if (CurrentSelections[i].pWin == pWin)
{
if (SelectionCallback)
{
SelectionInfoRec info;
info.selection = &CurrentSelections[i];
info.kind = SelectionWindowDestroy;
CallCallbacks(&SelectionCallback, &info);
}
CurrentSelections[i].pWin = (WindowPtr)NULL;
CurrentSelections[i].window = None;
CurrentSelections[i].client = NullClient;
@ -4068,6 +4088,14 @@ DeleteClientFromAnySelections(client)
for (i = 0; i< NumCurrentSelections; i++)
if (CurrentSelections[i].client == client)
{
if (SelectionCallback)
{
SelectionInfoRec info;
info.selection = &CurrentSelections[i];
info.kind = SelectionClientClose;
CallCallbacks(&SelectionCallback, &info);
}
CurrentSelections[i].pWin = (WindowPtr)NULL;
CurrentSelections[i].window = None;
CurrentSelections[i].client = NullClient;

View File

@ -152,6 +152,21 @@ ClientTimeToServerTime(c)
* beware of too-small buffers
*/
static unsigned char
ISOLatin1ToLower (unsigned char source)
{
unsigned char dest;
if ((source >= XK_A) && (source <= XK_Z))
dest = source + (XK_a - XK_A);
else if ((source >= XK_Agrave) && (source <= XK_Odiaeresis))
dest = source + (XK_agrave - XK_Agrave);
else if ((source >= XK_Ooblique) && (source <= XK_Thorn))
dest = source + (XK_oslash - XK_Ooblique);
else
dest = source;
return dest;
}
void
CopyISOLatin1Lowered(dest, source, length)
register unsigned char *dest, *source;
@ -160,19 +175,29 @@ CopyISOLatin1Lowered(dest, source, length)
register int i;
for (i = 0; i < length; i++, source++, dest++)
{
if ((*source >= XK_A) && (*source <= XK_Z))
*dest = *source + (XK_a - XK_A);
else if ((*source >= XK_Agrave) && (*source <= XK_Odiaeresis))
*dest = *source + (XK_agrave - XK_Agrave);
else if ((*source >= XK_Ooblique) && (*source <= XK_Thorn))
*dest = *source + (XK_oslash - XK_Ooblique);
else
*dest = *source;
}
*dest = ISOLatin1ToLower (*source);
*dest = '\0';
}
int
CompareISOLatin1Lowered(unsigned char *s1, int s1len,
unsigned char *s2, int s2len)
{
unsigned char c1, c2;
for (;;)
{
/* note -- compare against zero so that -1 ignores len */
c1 = s1len-- ? *s1++ : '\0';
c2 = s2len-- ? *s2++ : '\0';
if (!c1 ||
(c1 != c2 &&
(c1 = ISOLatin1ToLower (c1)) != (c2 = ISOLatin1ToLower (c2))))
break;
}
return (int) c1 - (int) c2;
}
#ifdef XCSECURITY
/* SecurityLookupWindow and SecurityLookupDrawable:
@ -321,13 +346,18 @@ LookupClient(rid, client)
int
AlterSaveSetForClient(client, pWin, mode)
ClientPtr client;
WindowPtr pWin;
unsigned mode;
AlterSaveSetForClient(ClientPtr client,
WindowPtr pWin,
unsigned mode,
Bool toRoot,
Bool remap)
{
int numnow;
#ifdef XFIXES
SaveSetElt *pTmp = NULL;
#else
pointer *pTmp = NULL;
#endif
int j;
numnow = client->numSaved;
@ -335,7 +365,7 @@ AlterSaveSetForClient(client, pWin, mode)
if (numnow)
{
pTmp = client->saveSet;
while ((j < numnow) && (pTmp[j] != (pointer)pWin))
while ((j < numnow) && (SaveSetWindow(pTmp[j]) != (pointer)pWin))
j++;
}
if (mode == SetModeInsert)
@ -343,12 +373,18 @@ AlterSaveSetForClient(client, pWin, mode)
if (j < numnow) /* duplicate */
return(Success);
numnow++;
#ifdef XFIXES
pTmp = (SaveSetElt *)xrealloc(client->saveSet, sizeof(SaveSetElt) * numnow);
#else
pTmp = (pointer *)xrealloc(client->saveSet, sizeof(pointer) * numnow);
#endif
if (!pTmp)
return(BadAlloc);
client->saveSet = pTmp;
client->numSaved = numnow;
client->saveSet[numnow - 1] = (pointer)pWin;
SaveSetAssignWindow(client->saveSet[numnow - 1], pWin);
SaveSetAssignToRoot(client->saveSet[numnow - 1], toRoot);
SaveSetAssignRemap(client->saveSet[numnow - 1], remap);
return(Success);
}
else if ((mode == SetModeDelete) && (j < numnow))
@ -361,15 +397,22 @@ AlterSaveSetForClient(client, pWin, mode)
numnow--;
if (numnow)
{
pTmp = (pointer *)xrealloc(client->saveSet,
sizeof(pointer) * numnow);
#ifdef XFIXES
pTmp = (SaveSetElt *)xrealloc(client->saveSet, sizeof(SaveSetElt) * numnow);
#else
pTmp = (pointer *)xrealloc(client->saveSet, sizeof(pointer) * numnow);
#endif
if (pTmp)
client->saveSet = pTmp;
}
else
{
xfree(client->saveSet);
#ifdef XFIXES
client->saveSet = (SaveSetElt *)NULL;
#else
client->saveSet = (pointer *)NULL;
#endif
}
client->numSaved = numnow;
return(Success);
@ -388,7 +431,7 @@ DeleteWindowFromAnySaveSet(pWin)
{
client = clients[i];
if (client && client->numSaved)
(void)AlterSaveSetForClient(client, pWin, SetModeDelete);
(void)AlterSaveSetForClient(client, pWin, SetModeDelete, FALSE, TRUE);
}
}

View File

@ -181,11 +181,6 @@ static WindowPtr *spriteTrace = (WindowPtr *)NULL;
static int spriteTraceSize = 0;
static int spriteTraceGood;
typedef struct {
int x, y;
ScreenPtr pScreen;
} HotSpot;
static struct {
CursorPtr current;
BoxRec hotLimits; /* logical constraints of hot spot */

View File

@ -3152,10 +3152,17 @@ HandleSaveSet(client)
for (j=0; j<client->numSaved; j++)
{
pWin = (WindowPtr)client->saveSet[j];
pParent = pWin->parent;
while (pParent && (wClient (pParent) == client))
pParent = pParent->parent;
pWin = SaveSetWindow(client->saveSet[j]);
#ifdef XFIXES
if (SaveSetToRoot(client->saveSet[j]))
pParent = WindowTable[pWin->drawable.pScreen->myNum];
else
#endif
{
pParent = pWin->parent;
while (pParent && (wClient (pParent) == client))
pParent = pParent->parent;
}
if (pParent)
{
if (pParent != pWin->parent)
@ -3172,7 +3179,11 @@ HandleSaveSet(client)
}
xfree(client->saveSet);
client->numSaved = 0;
#ifdef XFIXES
client->saveSet = (SaveSetElt *)NULL;
#else
client->saveSet = (pointer *)NULL;
#endif
}
Bool

View File

@ -77,10 +77,18 @@ typedef struct _Cursor {
unsigned short backRed, backGreen, backBlue; /* device-independent color */
int refcnt;
pointer devPriv[MAXSCREENS]; /* set by pScr->RealizeCursor*/
#ifdef XFIXES
CARD32 serialNumber;
Atom name;
#endif
} CursorRec;
typedef struct _CursorMetric {
unsigned short width, height, xhot, yhot;
} CursorMetricRec;
typedef struct {
int x, y;
ScreenPtr pScreen;
} HotSpot;
#endif /* CURSORSTRUCT_H */

View File

@ -379,6 +379,12 @@ extern void CopyISOLatin1Lowered(
unsigned char * /*source*/,
int /*length*/);
extern int CompareISOLatin1Lowered(
unsigned char * /*a*/,
int alen,
unsigned char * /*b*/,
int blen);
#ifdef XCSECURITY
extern WindowPtr SecurityLookupWindow(
@ -423,12 +429,14 @@ extern ClientPtr LookupClient(
extern void NoopDDA(void);
extern int AlterSaveSetForClient(
int AlterSaveSetForClient(
ClientPtr /*client*/,
WindowPtr /*pWin*/,
unsigned /*mode*/);
extern void DeleteWindowFromAnySaveSet(
unsigned /*mode*/,
Bool /*toRoot*/,
Bool /*remap*/);
void DeleteWindowFromAnySaveSet(
WindowPtr /*pWin*/);
extern void BlockHandler(
@ -785,4 +793,21 @@ typedef struct {
int count;
} DeviceEventInfoRec;
/*
* SelectionCallback stuff
*/
extern CallbackListPtr SelectionCallback;
typedef enum {
SelectionSetOwner,
SelectionWindowDestroy,
SelectionClientClose
} SelectionCallbackKind;
typedef struct {
struct _Selection *selection;
SelectionCallbackKind kind;
} SelectionInfoRec;
#endif /* DIX_H */

View File

@ -68,6 +68,28 @@ typedef enum {ClientStateInitial,
ClientStateCheckingSecurity,
ClientStateCheckedSecurity} ClientState;
#ifdef XFIXES
typedef struct _saveSet {
struct _Window *windowPtr;
Bool toRoot;
Bool remap;
} SaveSetElt;
#define SaveSetWindow(ss) ((ss).windowPtr)
#define SaveSetToRoot(ss) ((ss).toRoot)
#define SaveSetRemap(ss) ((ss).remap)
#define SaveSetAssignWindow(ss,w) ((ss).windowPtr = (w))
#define SaveSetAssignToRoot(ss,tr) ((ss).toRoot = (tr))
#define SaveSetAssignRemap(ss,rm) ((ss).remap = (rm))
#else
typedef struct _Window *SaveSetElt;
#define SaveSetWindow(ss) (ss)
#define SaveSetToRoot(ss) FALSE
#define SaveSetRemap(ss) TRUE
#define SaveSetAssignWindow(ss,w) ((ss) = (w))
#define SaveSetAssignToRoot(ss,tr)
#define SaveSetAssignRemap(ss,rm)
#endif
typedef struct _Client {
int index;
Mask clientAsMask;
@ -85,7 +107,7 @@ typedef struct _Client {
Drawable lastDrawableID;
GCPtr lastGC;
GContext lastGCID;
pointer *saveSet;
SaveSetElt *saveSet;
int numSaved;
pointer screenPrivate[MAXSCREENS];
int (**requestVector) (
@ -148,8 +170,8 @@ extern Bool SmartScheduleDisable;
extern Bool SmartScheduleIdle;
extern Bool SmartScheduleTimerStopped;
extern Bool SmartScheduleStartTimer(void);
#define SMART_MAX_PRIORITY (20)
#define SMART_MIN_PRIORITY (-20)
#define SMART_MAX_PRIORITY 20
#define SMART_MIN_PRIORITY -20
extern Bool SmartScheduleInit(void);

View File

@ -95,81 +95,84 @@ extern RegDataRec miBrokenData;
#define REGION_END(reg) REGION_BOX(reg, (reg)->data->numRects - 1)
#define REGION_SZOF(n) (sizeof(RegDataRec) + ((n) * sizeof(BoxRec)))
/* Keith recommends weaning the region code of pScreen argument */
#define REG_pScreen screenInfo.screens[0]
#ifdef NEED_SCREEN_REGIONS
#define REGION_CREATE(_pScreen, _rect, _size) \
(*(_pScreen)->RegionCreate)(_rect, _size)
(*(REG_pScreen)->RegionCreate)(_rect, _size)
#define REGION_INIT(_pScreen, _pReg, _rect, _size) \
(*(_pScreen)->RegionInit)(_pReg, _rect, _size)
(*(REG_pScreen)->RegionInit)(_pReg, _rect, _size)
#define REGION_COPY(_pScreen, dst, src) \
(*(_pScreen)->RegionCopy)(dst, src)
(*(REG_pScreen)->RegionCopy)(dst, src)
#define REGION_DESTROY(_pScreen, _pReg) \
(*(_pScreen)->RegionDestroy)(_pReg)
(*(REG_pScreen)->RegionDestroy)(_pReg)
#define REGION_UNINIT(_pScreen, _pReg) \
(*(_pScreen)->RegionUninit)(_pReg)
(*(REG_pScreen)->RegionUninit)(_pReg)
#define REGION_INTERSECT(_pScreen, newReg, reg1, reg2) \
(*(_pScreen)->Intersect)(newReg, reg1, reg2)
(*(REG_pScreen)->Intersect)(newReg, reg1, reg2)
#define REGION_UNION(_pScreen, newReg, reg1, reg2) \
(*(_pScreen)->Union)(newReg, reg1, reg2)
(*(REG_pScreen)->Union)(newReg, reg1, reg2)
#define REGION_SUBTRACT(_pScreen, newReg, reg1, reg2) \
(*(_pScreen)->Subtract)(newReg, reg1, reg2)
(*(REG_pScreen)->Subtract)(newReg, reg1, reg2)
#define REGION_INVERSE(_pScreen, newReg, reg1, invRect) \
(*(_pScreen)->Inverse)(newReg, reg1, invRect)
(*(REG_pScreen)->Inverse)(newReg, reg1, invRect)
#define REGION_RESET(_pScreen, _pReg, _pBox) \
(*(_pScreen)->RegionReset)(_pReg, _pBox)
(*(REG_pScreen)->RegionReset)(_pReg, _pBox)
#define REGION_TRANSLATE(_pScreen, _pReg, _x, _y) \
(*(_pScreen)->TranslateRegion)(_pReg, _x, _y)
(*(REG_pScreen)->TranslateRegion)(_pReg, _x, _y)
#define RECT_IN_REGION(_pScreen, _pReg, prect) \
(*(_pScreen)->RectIn)(_pReg, prect)
(*(REG_pScreen)->RectIn)(_pReg, prect)
#define POINT_IN_REGION(_pScreen, _pReg, _x, _y, prect) \
(*(_pScreen)->PointInRegion)(_pReg, _x, _y, prect)
(*(REG_pScreen)->PointInRegion)(_pReg, _x, _y, prect)
#define REGION_NOTEMPTY(_pScreen, _pReg) \
(*(_pScreen)->RegionNotEmpty)(_pReg)
(*(REG_pScreen)->RegionNotEmpty)(_pReg)
#define REGION_EQUAL(_pScreen, _pReg1, _pReg2) \
(*(_pScreen)->RegionEqual)(_pReg1, _pReg2)
(*(REG_pScreen)->RegionEqual)(_pReg1, _pReg2)
#define REGION_BROKEN(_pScreen, _pReg) \
(*(_pScreen)->RegionBroken)(_pReg)
(*(REG_pScreen)->RegionBroken)(_pReg)
#define REGION_BREAK(_pScreen, _pReg) \
(*(_pScreen)->RegionBreak)(_pReg)
(*(REG_pScreen)->RegionBreak)(_pReg)
#define REGION_EMPTY(_pScreen, _pReg) \
(*(_pScreen)->RegionEmpty)(_pReg)
(*(REG_pScreen)->RegionEmpty)(_pReg)
#define REGION_EXTENTS(_pScreen, _pReg) \
(*(_pScreen)->RegionExtents)(_pReg)
(*(REG_pScreen)->RegionExtents)(_pReg)
#define REGION_APPEND(_pScreen, dstrgn, rgn) \
(*(_pScreen)->RegionAppend)(dstrgn, rgn)
(*(REG_pScreen)->RegionAppend)(dstrgn, rgn)
#define REGION_VALIDATE(_pScreen, badreg, pOverlap) \
(*(_pScreen)->RegionValidate)(badreg, pOverlap)
(*(REG_pScreen)->RegionValidate)(badreg, pOverlap)
#define BITMAP_TO_REGION(_pScreen, pPix) \
(*(_pScreen)->BitmapToRegion)(pPix)
(*(REG_pScreen)->BitmapToRegion)(pPix)
#define RECTS_TO_REGION(_pScreen, nrects, prect, ctype) \
(*(_pScreen)->RectsToRegion)(nrects, prect, ctype)
(*(REG_pScreen)->RectsToRegion)(nrects, prect, ctype)
#else /* !NEED_SCREEN_REGIONS */
/* Reference _pScreen macro argument and check its type */
#define REGION_SCREEN(_pScreen_) (void)((_pScreen_)->myNum)
#define REGION_SCREEN(_pScreen) (void)((REG_pScreen)->myNum)
#define REGION_CREATE(_pScreen, _rect, _size) \
(REGION_SCREEN(_pScreen), miRegionCreate(_rect, _size))

View File

@ -252,4 +252,10 @@ void ResizeChildrenWinSize(
int /*dw*/,
int /*dh*/);
RegionPtr
CreateBoundingShape (WindowPtr pWin);
RegionPtr
CreateClipShape (WindowPtr pWin);
#endif /* WINDOW_H */

View File

@ -238,6 +238,12 @@ extern void RRExtensionInit(INITARGS);
#ifdef RES
extern void ResExtensionInit(INITARGS);
#endif
#ifdef XFIXES
extern void XFixesExtensionInit(INITARGS);
#endif
#ifdef DAMAGE
extern void DamageExtensionInit(INITARGS);
#endif
#ifndef XFree86LOADER
@ -377,6 +383,12 @@ InitExtensions(argc, argv)
#ifdef RES
ResExtensionInit();
#endif
#ifdef XFIXES
XFixesExtensionInit();
#endif
#ifdef DAMAGE
DamageExtensionInit();
#endif
}
void
@ -500,6 +512,12 @@ static ExtensionModule staticExtensions[] = {
#ifdef RANDR
{ RRExtensionInit, "RANDR", NULL, NULL, NULL },
#endif
#ifdef DAMAGE
{ DamageExtensionInit, "DAMAGE", NULL, NULL },
#endif
#ifdef XFIXES
{ XFixesExtensionInit, "XFIXES", NULL, NULL },
#endif
{ NULL, NULL, NULL, NULL, NULL }
};

1812
miext/damage/damage.c Executable file

File diff suppressed because it is too large Load Diff

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_ */

101
miext/damage/damagestr.h Executable file
View File

@ -0,0 +1,101 @@
/*
* $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 _DAMAGESTR_H_
#define _DAMAGESTR_H_
#include "damage.h"
#include "picturestr.h"
typedef struct _damage {
DamagePtr pNext;
DamagePtr pNextWin;
RegionRec damage;
DamageReportLevel damageLevel;
Bool isInternal;
void *closure;
Bool isWindow;
DrawablePtr pDrawable;
DamageReportFunc damageReport;
DamageDestroyFunc damageDestroy;
} DamageRec;
typedef struct _damageScrPriv {
int internalLevel;
PaintWindowBackgroundProcPtr PaintWindowBackground;
PaintWindowBorderProcPtr PaintWindowBorder;
CopyWindowProcPtr CopyWindow;
CloseScreenProcPtr CloseScreen;
CreateGCProcPtr CreateGC;
DestroyPixmapProcPtr DestroyPixmap;
SetWindowPixmapProcPtr SetWindowPixmap;
DestroyWindowProcPtr DestroyWindow;
#ifdef RENDER
CompositeProcPtr Composite;
GlyphsProcPtr Glyphs;
#endif
BSFuncRec BackingStoreFuncs;
} DamageScrPrivRec, *DamageScrPrivPtr;
typedef struct _damageGCPriv {
GCOps *ops;
GCFuncs *funcs;
} DamageGCPrivRec, *DamageGCPrivPtr;
extern int damageScrPrivateIndex;
extern int damagePixPrivateIndex;
extern int damageGCPrivateIndex;
extern int damageWinPrivateIndex;
#define damageGetScrPriv(pScr) \
((DamageScrPrivPtr) (pScr)->devPrivates[damageScrPrivateIndex].ptr)
#define damageScrPriv(pScr) \
DamageScrPrivPtr pScrPriv = damageGetScrPriv(pScr)
#define damageGetPixPriv(pPix) \
((DamagePtr) (pPix)->devPrivates[damagePixPrivateIndex].ptr)
#define damgeSetPixPriv(pPix,v) \
((pPix)->devPrivates[damagePixPrivateIndex].ptr = (pointer ) (v))
#define damagePixPriv(pPix) \
DamagePtr pDamage = damageGetPixPriv(pPix)
#define damageGetGCPriv(pGC) \
((DamageGCPrivPtr) (pGC)->devPrivates[damageGCPrivateIndex].ptr)
#define damageGCPriv(pGC) \
DamageGCPrivPtr pGCPriv = damageGetGCPriv(pGC)
#define damageGetWinPriv(pWin) \
((DamagePtr) (pWin)->devPrivates[damageWinPrivateIndex].ptr)
#define damageSetWinPriv(pWin,d) \
((pWin)->devPrivates[damageWinPrivateIndex].ptr = (d))
#endif /* _DAMAGESTR_H_ */

View File

@ -1,7 +1,7 @@
/*
* $XFree86$
* $Id$
*
* Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
* 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
@ -22,6 +22,9 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "misc.h"
#include "scrnintstr.h"
#include "os.h"
@ -40,6 +43,12 @@
static char **filterNames;
static int nfilterNames;
/*
* standard but not required filters don't have constant indices
*/
int pictFilterConvolution;
int
PictureGetFilterId (char *filter, int len, Bool makeit)
{
@ -50,15 +59,14 @@ PictureGetFilterId (char *filter, int len, Bool makeit)
if (len < 0)
len = strlen (filter);
for (i = 0; i < nfilterNames; i++)
if (len == strlen (filterNames[i]) &&
!strncmp (filterNames[i], filter, len))
if (!CompareISOLatin1Lowered (filterNames[i], -1, filter, len))
return i;
if (!makeit)
return -1;
name = xalloc (strlen (filter) + 1);
name = xalloc (len + 1);
if (!name)
return -1;
strncpy (name, filter, len);
memcpy (name, filter, len);
name[len] = '\0';
if (filterNames)
names = xrealloc (filterNames, (nfilterNames + 1) * sizeof (char *));
@ -116,7 +124,9 @@ PictureFreeFilterIds (void)
}
int
PictureAddFilter (ScreenPtr pScreen, char *filter, xFixed *params, int nparams)
PictureAddFilter (ScreenPtr pScreen,
char *filter,
PictFilterValidateParamsProcPtr ValidateParams)
{
PictureScreenPtr ps = GetPictureScreen(pScreen);
int id = PictureGetFilterId (filter, -1, TRUE);
@ -140,9 +150,8 @@ PictureAddFilter (ScreenPtr pScreen, char *filter, xFixed *params, int nparams)
ps->filters = filters;
i = ps->nfilters++;
ps->filters[i].name = PictureGetFilterName (id);
ps->filters[i].params = params;
ps->filters[i].nparams = nparams;
ps->filters[i].id = id;
ps->filters[i].ValidateParams = ValidateParams;
return id;
}
@ -209,11 +218,12 @@ PictureSetDefaultFilters (ScreenPtr pScreen)
if (!filterNames)
if (!PictureSetDefaultIds ())
return FALSE;
if (PictureAddFilter (pScreen, FilterNearest, 0, 0) < 0)
return FALSE;
if (PictureAddFilter (pScreen, FilterBilinear, 0, 0) < 0)
return FALSE;
if (PictureAddFilter (pScreen, FilterNearest, 0) < 0)
return FALSE;
if (PictureAddFilter (pScreen, FilterBilinear, 0) < 0)
return FALSE;
if (!PictureSetFilterAlias (pScreen, FilterNearest, FilterFast))
return FALSE;
if (!PictureSetFilterAlias (pScreen, FilterBilinear, FilterGood))
@ -243,21 +253,25 @@ SetPictureFilter (PicturePtr pPicture, char *name, int len, xFixed *params, int
if (!pFilter)
return BadName;
if (nparams > pFilter->nparams)
return BadMatch;
if (pFilter->nparams != pPicture->filter_nparams)
if (pFilter->ValidateParams)
{
new_params = xalloc (pFilter->nparams * sizeof (xFixed));
if (!(*pFilter->ValidateParams) (pPicture, pFilter->id, params, nparams))
return BadMatch;
}
else if (nparams)
return BadMatch;
if (nparams != pPicture->filter_nparams)
{
new_params = xalloc (nparams * sizeof (xFixed));
if (!new_params)
return BadAlloc;
xfree (pPicture->filter_params);
pPicture->filter_params = new_params;
pPicture->filter_nparams = pFilter->nparams;
pPicture->filter_nparams = nparams;
}
for (i = 0; i < nparams; i++)
pPicture->filter_params[i] = params[i];
for (; i < pFilter->nparams; i++)
pPicture->filter_params[i] = pFilter->params[i];
pPicture->filter = pFilter->id;
return Success;
}

View File

@ -1,127 +0,0 @@
/*
* $XFree86: xc/programs/Xserver/render/glyphstr.h,v 1.3 2000/11/20 07:13:13 keithp Exp $
*
* Copyright © 2000 SuSE, 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 SuSE not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. SuSE makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
* 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: Keith Packard, SuSE, Inc.
*/
#ifndef _GLYPHSTR_H_
#define _GLYPHSTR_H_
#include "renderproto.h"
#include "picture.h"
#include "screenint.h"
#define GlyphFormat1 0
#define GlyphFormat4 1
#define GlyphFormat8 2
#define GlyphFormat16 3
#define GlyphFormat32 4
#define GlyphFormatNum 5
typedef struct _Glyph {
CARD32 refcnt;
CARD32 size; /* info + bitmap */
xGlyphInfo info;
/* bits follow */
} GlyphRec, *GlyphPtr;
typedef struct _GlyphRef {
CARD32 signature;
GlyphPtr glyph;
} GlyphRefRec, *GlyphRefPtr;
#define DeletedGlyph ((GlyphPtr) 1)
typedef struct _GlyphHashSet {
CARD32 entries;
CARD32 size;
CARD32 rehash;
} GlyphHashSetRec, *GlyphHashSetPtr;
typedef struct _GlyphHash {
GlyphRefPtr table;
GlyphHashSetPtr hashSet;
CARD32 tableEntries;
} GlyphHashRec, *GlyphHashPtr;
typedef struct _GlyphSet {
CARD32 refcnt;
PictFormatPtr format;
int fdepth;
GlyphHashRec hash;
} GlyphSetRec, *GlyphSetPtr;
typedef struct _GlyphList {
INT16 xOff;
INT16 yOff;
CARD8 len;
PictFormatPtr format;
} GlyphListRec, *GlyphListPtr;
extern GlyphHashRec globalGlyphs[GlyphFormatNum];
GlyphHashSetPtr
FindGlyphHashSet (CARD32 filled);
Bool
GlyphInit (ScreenPtr pScreen);
GlyphRefPtr
FindGlyphRef (GlyphHashPtr hash, CARD32 signature, Bool match, GlyphPtr compare);
CARD32
HashGlyph (GlyphPtr glyph);
void
FreeGlyph (GlyphPtr glyph, int format);
void
AddGlyph (GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id);
Bool
DeleteGlyph (GlyphSetPtr glyphSet, Glyph id);
GlyphPtr
FindGlyph (GlyphSetPtr glyphSet, Glyph id);
GlyphPtr
AllocateGlyph (xGlyphInfo *gi, int format);
Bool
AllocateGlyphHash (GlyphHashPtr hash, GlyphHashSetPtr hashSet);
Bool
ResizeGlyphHash (GlyphHashPtr hash, CARD32 change, Bool global);
Bool
ResizeGlyphSet (GlyphSetPtr glyphSet, CARD32 change);
GlyphSetPtr
AllocateGlyphSet (int fdepth, PictFormatPtr format);
int
FreeGlyphSet (pointer value,
XID gid);
#endif /* _GLYPHSTR_H_ */

View File

@ -1,210 +0,0 @@
/*
* $XFree86: xc/programs/Xserver/render/mipict.h,v 1.12 2002/11/05 05:34:40 keithp Exp $
*
* Copyright © 2000 SuSE, 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 SuSE not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. SuSE makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
* 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: Keith Packard, SuSE, Inc.
*/
#ifndef _MIPICT_H_
#define _MIPICT_H_
#include "picturestr.h"
#define MI_MAX_INDEXED 256 /* XXX depth must be <= 8 */
#if MI_MAX_INDEXED <= 256
typedef CARD8 miIndexType;
#endif
typedef struct _miIndexed {
Bool color;
CARD32 rgba[MI_MAX_INDEXED];
miIndexType ent[32768];
} miIndexedRec, *miIndexedPtr;
#define miCvtR8G8B8to15(s) ((((s) >> 3) & 0x001f) | \
(((s) >> 6) & 0x03e0) | \
(((s) >> 9) & 0x7c00))
#define miIndexToEnt15(mif,rgb15) ((mif)->ent[rgb15])
#define miIndexToEnt24(mif,rgb24) miIndexToEnt15(mif,miCvtR8G8B8to15(rgb24))
#define miIndexToEntY24(mif,rgb24) ((mif)->ent[CvtR8G8B8toY15(rgb24)])
int
miCreatePicture (PicturePtr pPicture);
void
miDestroyPicture (PicturePtr pPicture);
void
miDestroyPictureClip (PicturePtr pPicture);
int
miChangePictureClip (PicturePtr pPicture,
int type,
pointer value,
int n);
void
miChangePicture (PicturePtr pPicture,
Mask mask);
void
miValidatePicture (PicturePtr pPicture,
Mask mask);
Bool
miClipPicture (RegionPtr pRegion,
PicturePtr pPicture,
INT16 xReg,
INT16 yReg,
INT16 xPict,
INT16 yPict);
Bool
miComputeCompositeRegion (RegionPtr pRegion,
PicturePtr pSrc,
PicturePtr pMask,
PicturePtr pDst,
INT16 xSrc,
INT16 ySrc,
INT16 xMask,
INT16 yMask,
INT16 xDst,
INT16 yDst,
CARD16 width,
CARD16 height);
Bool
miPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats);
void
miGlyphExtents (int nlist,
GlyphListPtr list,
GlyphPtr *glyphs,
BoxPtr extents);
void
miGlyphs (CARD8 op,
PicturePtr pSrc,
PicturePtr pDst,
PictFormatPtr maskFormat,
INT16 xSrc,
INT16 ySrc,
int nlist,
GlyphListPtr list,
GlyphPtr *glyphs);
void
miRenderColorToPixel (PictFormatPtr pPict,
xRenderColor *color,
CARD32 *pixel);
void
miRenderPixelToColor (PictFormatPtr pPict,
CARD32 pixel,
xRenderColor *color);
void
miCompositeRects (CARD8 op,
PicturePtr pDst,
xRenderColor *color,
int nRect,
xRectangle *rects);
void
miTrapezoidBounds (int ntrap, xTrapezoid *traps, BoxPtr box);
void
miTrapezoids (CARD8 op,
PicturePtr pSrc,
PicturePtr pDst,
PictFormatPtr maskFormat,
INT16 xSrc,
INT16 ySrc,
int ntrap,
xTrapezoid *traps);
void
miPointFixedBounds (int npoint, xPointFixed *points, BoxPtr bounds);
void
miTriangleBounds (int ntri, xTriangle *tris, BoxPtr bounds);
void
miRasterizeTriangle (PicturePtr pMask,
xTriangle *tri,
int x_off,
int y_off);
void
miTriangles (CARD8 op,
PicturePtr pSrc,
PicturePtr pDst,
PictFormatPtr maskFormat,
INT16 xSrc,
INT16 ySrc,
int ntri,
xTriangle *tris);
void
miTriStrip (CARD8 op,
PicturePtr pSrc,
PicturePtr pDst,
PictFormatPtr maskFormat,
INT16 xSrc,
INT16 ySrc,
int npoint,
xPointFixed *points);
void
miTriFan (CARD8 op,
PicturePtr pSrc,
PicturePtr pDst,
PictFormatPtr maskFormat,
INT16 xSrc,
INT16 ySrc,
int npoint,
xPointFixed *points);
PicturePtr
miCreateAlphaPicture (ScreenPtr pScreen,
PicturePtr pDst,
PictFormatPtr pPictFormat,
CARD16 width,
CARD16 height);
Bool
miInitIndexed (ScreenPtr pScreen,
PictFormatPtr pFormat);
void
miCloseIndexed (ScreenPtr pScreen,
PictFormatPtr pFormat);
void
miUpdateIndexed (ScreenPtr pScreen,
PictFormatPtr pFormat,
int ndef,
xColorItem *pdef);
#endif /* _MIPICT_H_ */

View File

@ -1,5 +1,5 @@
/*
* $XFree86: xc/programs/Xserver/render/picture.c,v 1.29 2002/11/23 02:38:15 keithp Exp $
* $Id$
*
* Copyright © 2000 SuSE, Inc.
*
@ -23,6 +23,9 @@
* Author: Keith Packard, SuSE, Inc.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "misc.h"
#include "scrnintstr.h"
#include "os.h"
@ -367,7 +370,7 @@ PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp)
case PICT_TYPE_COLOR:
case PICT_TYPE_GRAY:
pFormats[f].type = PictTypeIndexed;
pFormats[f].index.pVisual = &pScreen->visuals[PICT_FORMAT_VIS(format)];
pFormats[f].index.vid = pScreen->visuals[PICT_FORMAT_VIS(format)].vid;
break;
}
}
@ -375,6 +378,21 @@ PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp)
return pFormats;
}
static VisualPtr
PictureFindVisual (ScreenPtr pScreen, VisualID visual)
{
int i;
VisualPtr pVisual;
for (i = 0, pVisual = pScreen->visuals;
i < pScreen->numVisuals;
i++, pVisual++)
{
if (pVisual->vid == visual)
return pVisual;
}
return 0;
}
Bool
PictureInitIndexedFormats (ScreenPtr pScreen)
{
@ -390,13 +408,16 @@ PictureInitIndexedFormats (ScreenPtr pScreen)
{
if (format->type == PictTypeIndexed && !format->index.pColormap)
{
if (format->index.pVisual->vid == pScreen->rootVisual)
if (format->index.vid == pScreen->rootVisual)
format->index.pColormap = (ColormapPtr) LookupIDByType(pScreen->defColormap,
RT_COLORMAP);
else
{
VisualPtr pVisual;
pVisual = PictureFindVisual (pScreen, format->index.vid);
if (CreateColormap (FakeClientID (0), pScreen,
format->index.pVisual,
pVisual,
&format->index.pColormap, AllocNone,
0) != Success)
{
@ -480,16 +501,16 @@ PictureMatchVisual (ScreenPtr pScreen, int depth, VisualPtr pVisual)
{
if (type == PictTypeIndexed)
{
if (format->index.pVisual == pVisual)
if (format->index.vid == pVisual->vid)
return format;
}
else
{
if (format->direct.redMask << format->direct.red ==
if ((unsigned long) format->direct.redMask << format->direct.red ==
pVisual->redMask &&
format->direct.greenMask << format->direct.green ==
(unsigned long) format->direct.greenMask << format->direct.green ==
pVisual->greenMask &&
format->direct.blueMask << format->direct.blue ==
(unsigned long) format->direct.blueMask << format->direct.blue ==
pVisual->blueMask)
{
return format;
@ -561,7 +582,7 @@ PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
return FALSE;
PictureWindowPrivateIndex = AllocateWindowPrivateIndex();
PictureGeneration = serverGeneration;
#ifdef XResExtension
#ifdef RES
RegisterResourceName (PictureType, "PICTURE");
RegisterResourceName (PictFormatType, "PICTFORMAT");
RegisterResourceName (GlyphSetType, "GLYPHSET");
@ -585,7 +606,8 @@ PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
}
if (formats[n].type == PictTypeIndexed)
{
if ((formats[n].index.pVisual->class | DynamicClass) == PseudoColor)
VisualPtr pVisual = PictureFindVisual (pScreen, formats[n].index.vid);
if ((pVisual->class | DynamicClass) == PseudoColor)
type = PICT_TYPE_COLOR;
else
type = PICT_TYPE_GRAY;
@ -1009,7 +1031,6 @@ SetPictureClipRects (PicturePtr pPicture,
PictureScreenPtr ps = GetPictureScreen(pScreen);
RegionPtr clientClip;
int result;
clientClip = RECTS_TO_REGION(pScreen,
nRect, rects, CT_UNSORTED);
if (!clientClip)
@ -1026,6 +1047,50 @@ SetPictureClipRects (PicturePtr pPicture,
return result;
}
int
SetPictureClipRegion (PicturePtr pPicture,
int xOrigin,
int yOrigin,
RegionPtr pRegion)
{
ScreenPtr pScreen = pPicture->pDrawable->pScreen;
PictureScreenPtr ps = GetPictureScreen(pScreen);
RegionPtr clientClip;
int result;
int type;
if (pRegion)
{
type = CT_REGION;
clientClip = REGION_CREATE (pScreen,
REGION_EXTENTS(pScreen, pRegion),
REGION_NUM_RECTS(pRegion));
if (!clientClip)
return BadAlloc;
if (!REGION_COPY (pSCreen, clientClip, pRegion))
{
REGION_DESTROY (pScreen, clientClip);
return BadAlloc;
}
}
else
{
type = CT_NONE;
clientClip = 0;
}
result =(*ps->ChangePictureClip) (pPicture, type,
(pointer) clientClip, 0);
if (result == Success)
{
pPicture->clipOrigin.x = xOrigin;
pPicture->clipOrigin.y = yOrigin;
pPicture->stateChanges |= CPClipXOrigin|CPClipYOrigin|CPClipMask;
pPicture->serialNumber |= GC_CHANGE_SERIAL_BIT;
}
return result;
}
int
SetPictureTransform (PicturePtr pPicture,
PictTransform *transform)

View File

@ -1,230 +0,0 @@
/*
* $XFree86: xc/programs/Xserver/render/picture.h,v 1.20tsi Exp $
*
* Copyright © 2000 SuSE, 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 SuSE not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. SuSE makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
* 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: Keith Packard, SuSE, Inc.
*/
#ifndef _PICTURE_H_
#define _PICTURE_H_
typedef struct _DirectFormat *DirectFormatPtr;
typedef struct _PictFormat *PictFormatPtr;
typedef struct _Picture *PicturePtr;
/*
* While the protocol is generous in format support, the
* sample implementation allows only packed RGB and GBR
* representations for data to simplify software rendering,
*/
#define PICT_FORMAT(bpp,type,a,r,g,b) (((bpp) << 24) | \
((type) << 16) | \
((a) << 12) | \
((r) << 8) | \
((g) << 4) | \
((b)))
/*
* gray/color formats use a visual index instead of argb
*/
#define PICT_VISFORMAT(bpp,type,vi) (((bpp) << 24) | \
((type) << 16) | \
((vi)))
#define PICT_FORMAT_BPP(f) (((f) >> 24) )
#define PICT_FORMAT_TYPE(f) (((f) >> 16) & 0xff)
#define PICT_FORMAT_A(f) (((f) >> 12) & 0x0f)
#define PICT_FORMAT_R(f) (((f) >> 8) & 0x0f)
#define PICT_FORMAT_G(f) (((f) >> 4) & 0x0f)
#define PICT_FORMAT_B(f) (((f) ) & 0x0f)
#define PICT_FORMAT_RGB(f) (((f) ) & 0xfff)
#define PICT_FORMAT_VIS(f) (((f) ) & 0xffff)
#define PICT_TYPE_OTHER 0
#define PICT_TYPE_A 1
#define PICT_TYPE_ARGB 2
#define PICT_TYPE_ABGR 3
#define PICT_TYPE_COLOR 4
#define PICT_TYPE_GRAY 5
#define PICT_FORMAT_COLOR(f) (PICT_FORMAT_TYPE(f) & 2)
/* 32bpp formats */
#define PICT_a8r8g8b8 PICT_FORMAT(32,PICT_TYPE_ARGB,8,8,8,8)
#define PICT_x8r8g8b8 PICT_FORMAT(32,PICT_TYPE_ARGB,0,8,8,8)
#define PICT_a8b8g8r8 PICT_FORMAT(32,PICT_TYPE_ABGR,8,8,8,8)
#define PICT_x8b8g8r8 PICT_FORMAT(32,PICT_TYPE_ABGR,0,8,8,8)
/* 24bpp formats */
#define PICT_r8g8b8 PICT_FORMAT(24,PICT_TYPE_ARGB,0,8,8,8)
#define PICT_b8g8r8 PICT_FORMAT(24,PICT_TYPE_ABGR,0,8,8,8)
/* 16bpp formats */
#define PICT_r5g6b5 PICT_FORMAT(16,PICT_TYPE_ARGB,0,5,6,5)
#define PICT_b5g6r5 PICT_FORMAT(16,PICT_TYPE_ABGR,0,5,6,5)
#define PICT_a1r5g5b5 PICT_FORMAT(16,PICT_TYPE_ARGB,1,5,5,5)
#define PICT_x1r5g5b5 PICT_FORMAT(16,PICT_TYPE_ARGB,0,5,5,5)
#define PICT_a1b5g5r5 PICT_FORMAT(16,PICT_TYPE_ABGR,1,5,5,5)
#define PICT_x1b5g5r5 PICT_FORMAT(16,PICT_TYPE_ABGR,0,5,5,5)
#define PICT_a4r4g4b4 PICT_FORMAT(16,PICT_TYPE_ARGB,4,4,4,4)
#define PICT_x4r4g4b4 PICT_FORMAT(16,PICT_TYPE_ARGB,4,4,4,4)
#define PICT_a4b4g4r4 PICT_FORMAT(16,PICT_TYPE_ARGB,4,4,4,4)
#define PICT_x4b4g4r4 PICT_FORMAT(16,PICT_TYPE_ARGB,4,4,4,4)
/* 8bpp formats */
#define PICT_a8 PICT_FORMAT(8,PICT_TYPE_A,8,0,0,0)
#define PICT_r3g3b2 PICT_FORMAT(8,PICT_TYPE_ARGB,0,3,3,2)
#define PICT_b2g3r3 PICT_FORMAT(8,PICT_TYPE_ABGR,0,3,3,2)
#define PICT_a2r2g2b2 PICT_FORMAT(8,PICT_TYPE_ARGB,2,2,2,2)
#define PICT_a2b2g2r2 PICT_FORMAT(8,PICT_TYPE_ABGR,2,2,2,2)
#define PICT_c8 PICT_FORMAT(8,PICT_TYPE_COLOR,0,0,0,0)
#define PICT_g8 PICT_FORMAT(8,PICT_TYPE_GRAY,0,0,0,0)
/* 4bpp formats */
#define PICT_a4 PICT_FORMAT(4,PICT_TYPE_A,4,0,0,0)
#define PICT_r1g2b1 PICT_FORMAT(4,PICT_TYPE_ARGB,0,1,2,1)
#define PICT_b1g2r1 PICT_FORMAT(4,PICT_TYPE_ABGR,0,1,2,1)
#define PICT_a1r1g1b1 PICT_FORMAT(4,PICT_TYPE_ARGB,1,1,1,1)
#define PICT_a1b1g1r1 PICT_FORMAT(4,PICT_TYPE_ABGR,1,1,1,1)
#define PICT_c4 PICT_FORMAT(4,PICT_TYPE_COLOR,0,0,0,0)
#define PICT_g4 PICT_FORMAT(4,PICT_TYPE_GRAY,0,0,0,0)
/* 1bpp formats */
#define PICT_a1 PICT_FORMAT(1,PICT_TYPE_A,1,0,0,0)
#define PICT_g1 PICT_FORMAT(1,PICT_TYPE_GRAY,0,0,0,0)
/*
* For dynamic indexed visuals (GrayScale and PseudoColor), these control the
* selection of colors allocated for drawing to Pictures. The default
* policy depends on the size of the colormap:
*
* Size Default Policy
* ----------------------------
* < 64 PolicyMono
* < 256 PolicyGray
* 256 PolicyColor (only on PseudoColor)
*
* The actual allocation code lives in miindex.c, and so is
* austensibly server dependent, but that code does:
*
* PolicyMono Allocate no additional colors, use black and white
* PolicyGray Allocate 13 gray levels (11 cells used)
* PolicyColor Allocate a 4x4x4 cube and 13 gray levels (71 cells used)
* PolicyAll Allocate as big a cube as possible, fill with gray (all)
*
* Here's a picture to help understand how many colors are
* actually allocated (this is just the gray ramp):
*
* gray level
* all 0000 1555 2aaa 4000 5555 6aaa 8000 9555 aaaa bfff d555 eaaa ffff
* b/w 0000 ffff
* 4x4x4 5555 aaaa
* extra 1555 2aaa 4000 6aaa 8000 9555 bfff d555 eaaa
*
* The default colormap supplies two gray levels (black/white), the
* 4x4x4 cube allocates another two and nine more are allocated to fill
* in the 13 levels. When the 4x4x4 cube is not allocated, a total of
* 11 cells are allocated.
*/
#define PictureCmapPolicyInvalid -1
#define PictureCmapPolicyDefault 0
#define PictureCmapPolicyMono 1
#define PictureCmapPolicyGray 2
#define PictureCmapPolicyColor 3
#define PictureCmapPolicyAll 4
extern int PictureCmapPolicy;
int PictureParseCmapPolicy (const char *name);
/* Fixed point updates from Carl Worth, USC, Information Sciences Institute */
#ifdef WIN32
typedef __int64 xFixed_32_32;
#else
# if defined (_LP64) || \
defined(__alpha__) || defined(__alpha) || \
defined(ia64) || defined(__ia64__) || \
defined(__sparc64__) || \
defined(__s390x__) || \
defined(AMD64) || defined (__AMD64__) || \
(defined(sgi) && (_MIPS_SZLONG == 64))
typedef long xFixed_32_32;
# else
# if defined(__GNUC__) && \
((__GNUC__ > 2) || \
((__GNUC__ == 2) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ > 7)))
__extension__
# endif
typedef long long int xFixed_32_32;
# endif
#endif
typedef CARD32 xFixed_1_31;
typedef CARD32 xFixed_1_16;
typedef INT32 xFixed_16_16;
/*
* An unadorned "xFixed" is the same as xFixed_16_16,
* (since it's quite common in the code)
*/
typedef xFixed_16_16 xFixed;
#define XFIXED_BITS 16
#define xFixedToInt(f) (int) ((f) >> XFIXED_BITS)
#define IntToxFixed(i) ((xFixed) (i) << XFIXED_BITS)
#define xFixedE ((xFixed) 1)
#define xFixed1 (IntToxFixed(1))
#define xFixed1MinusE (xFixed1 - xFixedE)
#define xFixedFrac(f) ((f) & xFixed1MinusE)
#define xFixedFloor(f) ((f) & ~xFixed1MinusE)
#define xFixedCeil(f) xFixedFloor((f) + xFixed1MinusE)
#define xFixedFraction(f) ((f) & xFixed1MinusE)
#define xFixedMod2(f) ((f) & (xFixed1 | xFixed1MinusE))
/* whether 't' is a well defined not obviously empty trapezoid */
#define xTrapezoidValid(t) ((t)->left.p1.y != (t)->left.p2.y && \
(t)->right.p1.y != (t)->right.p2.y && \
(int) ((t)->bottom - (t)->top) > 0)
/*
* Standard NTSC luminance conversions:
*
* y = r * 0.299 + g * 0.587 + b * 0.114
*
* Approximate this for a bit more speed:
*
* y = (r * 153 + g * 301 + b * 58) / 512
*
* This gives 17 bits of luminance; to get 15 bits, lop the low two
*/
#define CvtR8G8B8toY15(s) (((((s) >> 16) & 0xff) * 153 + \
(((s) >> 8) & 0xff) * 301 + \
(((s) ) & 0xff) * 58) >> 2)
#endif /* _PICTURE_H_ */

View File

@ -1,502 +0,0 @@
/* $XdotOrg: xc/programs/Xserver/render/picturestr.h,v 1.1.4.1 2003/12/18 19:29:15 kaleb Exp $ */
/*
* $XFree86: xc/programs/Xserver/render/picturestr.h,v 1.21 2002/11/06 22:45:36 keithp Exp $
*
* Copyright © 2000 SuSE, 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 SuSE not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. SuSE makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
* 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: Keith Packard, SuSE, Inc.
*/
#ifndef _PICTURESTR_H_
#define _PICTURESTR_H_
#include "glyphstr.h"
#include "scrnintstr.h"
#include "resource.h"
typedef struct _DirectFormat {
CARD16 red, redMask;
CARD16 green, greenMask;
CARD16 blue, blueMask;
CARD16 alpha, alphaMask;
} DirectFormatRec;
typedef struct _IndexFormat {
VisualPtr pVisual;
ColormapPtr pColormap;
int nvalues;
xIndexValue *pValues;
void *devPrivate;
} IndexFormatRec;
typedef struct _PictFormat {
CARD32 id;
CARD32 format; /* except bpp */
unsigned char type;
unsigned char depth;
DirectFormatRec direct;
IndexFormatRec index;
} PictFormatRec;
typedef struct _PictVector {
xFixed vector[3];
} PictVector, *PictVectorPtr;
typedef struct _PictTransform {
xFixed matrix[3][3];
} PictTransform, *PictTransformPtr;
typedef struct _Picture {
DrawablePtr pDrawable;
PictFormatPtr pFormat;
CARD32 format; /* PICT_FORMAT */
int refcnt;
CARD32 id;
PicturePtr pNext; /* chain on same drawable */
unsigned int repeat : 1;
unsigned int graphicsExposures : 1;
unsigned int subWindowMode : 1;
unsigned int polyEdge : 1;
unsigned int polyMode : 1;
unsigned int freeCompClip : 1;
unsigned int clientClipType : 2;
unsigned int componentAlpha : 1;
unsigned int unused : 23;
PicturePtr alphaMap;
DDXPointRec alphaOrigin;
DDXPointRec clipOrigin;
pointer clientClip;
Atom dither;
unsigned long stateChanges;
unsigned long serialNumber;
RegionPtr pCompositeClip;
DevUnion *devPrivates;
PictTransform *transform;
int filter;
xFixed *filter_params;
int filter_nparams;
} PictureRec;
typedef struct {
char *name;
xFixed *params;
int nparams;
int id;
} PictFilterRec, *PictFilterPtr;
#define PictFilterNearest 0
#define PictFilterBilinear 1
#define PictFilterFast 2
#define PictFilterGood 3
#define PictFilterBest 4
typedef struct {
char *alias;
int alias_id;
int filter_id;
} PictFilterAliasRec, *PictFilterAliasPtr;
typedef int (*CreatePictureProcPtr) (PicturePtr pPicture);
typedef void (*DestroyPictureProcPtr) (PicturePtr pPicture);
typedef int (*ChangePictureClipProcPtr) (PicturePtr pPicture,
int clipType,
pointer value,
int n);
typedef void (*DestroyPictureClipProcPtr)(PicturePtr pPicture);
typedef int (*ChangePictureTransformProcPtr) (PicturePtr pPicture,
PictTransform *transform);
typedef int (*ChangePictureFilterProcPtr) (PicturePtr pPicture,
int filter,
xFixed *params,
int nparams);
typedef void (*DestroyPictureFilterProcPtr) (PicturePtr pPicture);
typedef void (*ChangePictureProcPtr) (PicturePtr pPicture,
Mask mask);
typedef void (*ValidatePictureProcPtr) (PicturePtr pPicture,
Mask mask);
typedef void (*CompositeProcPtr) (CARD8 op,
PicturePtr pSrc,
PicturePtr pMask,
PicturePtr pDst,
INT16 xSrc,
INT16 ySrc,
INT16 xMask,
INT16 yMask,
INT16 xDst,
INT16 yDst,
CARD16 width,
CARD16 height);
typedef void (*GlyphsProcPtr) (CARD8 op,
PicturePtr pSrc,
PicturePtr pDst,
PictFormatPtr maskFormat,
INT16 xSrc,
INT16 ySrc,
int nlists,
GlyphListPtr lists,
GlyphPtr *glyphs);
typedef void (*CompositeRectsProcPtr) (CARD8 op,
PicturePtr pDst,
xRenderColor *color,
int nRect,
xRectangle *rects);
typedef void (*RasterizeTrapezoidProcPtr)(PicturePtr pMask,
xTrapezoid *trap,
int x_off,
int y_off);
typedef void (*TrapezoidsProcPtr) (CARD8 op,
PicturePtr pSrc,
PicturePtr pDst,
PictFormatPtr maskFormat,
INT16 xSrc,
INT16 ySrc,
int ntrap,
xTrapezoid *traps);
typedef void (*TrianglesProcPtr) (CARD8 op,
PicturePtr pSrc,
PicturePtr pDst,
PictFormatPtr maskFormat,
INT16 xSrc,
INT16 ySrc,
int ntri,
xTriangle *tris);
typedef void (*TriStripProcPtr) (CARD8 op,
PicturePtr pSrc,
PicturePtr pDst,
PictFormatPtr maskFormat,
INT16 xSrc,
INT16 ySrc,
int npoint,
xPointFixed *points);
typedef void (*TriFanProcPtr) (CARD8 op,
PicturePtr pSrc,
PicturePtr pDst,
PictFormatPtr maskFormat,
INT16 xSrc,
INT16 ySrc,
int npoint,
xPointFixed *points);
typedef Bool (*InitIndexedProcPtr) (ScreenPtr pScreen,
PictFormatPtr pFormat);
typedef void (*CloseIndexedProcPtr) (ScreenPtr pScreen,
PictFormatPtr pFormat);
typedef void (*UpdateIndexedProcPtr) (ScreenPtr pScreen,
PictFormatPtr pFormat,
int ndef,
xColorItem *pdef);
typedef struct _PictureScreen {
int totalPictureSize;
unsigned int *PicturePrivateSizes;
int PicturePrivateLen;
PictFormatPtr formats;
PictFormatPtr fallback;
int nformats;
CreatePictureProcPtr CreatePicture;
DestroyPictureProcPtr DestroyPicture;
ChangePictureClipProcPtr ChangePictureClip;
DestroyPictureClipProcPtr DestroyPictureClip;
ChangePictureProcPtr ChangePicture;
ValidatePictureProcPtr ValidatePicture;
CompositeProcPtr Composite;
GlyphsProcPtr Glyphs;
CompositeRectsProcPtr CompositeRects;
DestroyWindowProcPtr DestroyWindow;
CloseScreenProcPtr CloseScreen;
StoreColorsProcPtr StoreColors;
InitIndexedProcPtr InitIndexed;
CloseIndexedProcPtr CloseIndexed;
UpdateIndexedProcPtr UpdateIndexed;
int subpixel;
PictFilterPtr filters;
int nfilters;
PictFilterAliasPtr filterAliases;
int nfilterAliases;
ChangePictureTransformProcPtr ChangePictureTransform;
ChangePictureFilterProcPtr ChangePictureFilter;
DestroyPictureFilterProcPtr DestroyPictureFilter;
TrapezoidsProcPtr Trapezoids;
TrianglesProcPtr Triangles;
TriStripProcPtr TriStrip;
TriFanProcPtr TriFan;
RasterizeTrapezoidProcPtr RasterizeTrapezoid;
} PictureScreenRec, *PictureScreenPtr;
extern int PictureScreenPrivateIndex;
extern int PictureWindowPrivateIndex;
extern RESTYPE PictureType;
extern RESTYPE PictFormatType;
extern RESTYPE GlyphSetType;
#define GetPictureScreen(s) ((PictureScreenPtr) ((s)->devPrivates[PictureScreenPrivateIndex].ptr))
#define GetPictureScreenIfSet(s) ((PictureScreenPrivateIndex != -1) ? GetPictureScreen(s) : NULL)
#define SetPictureScreen(s,p) ((s)->devPrivates[PictureScreenPrivateIndex].ptr = (pointer) (p))
#define GetPictureWindow(w) ((PicturePtr) ((w)->devPrivates[PictureWindowPrivateIndex].ptr))
#define SetPictureWindow(w,p) ((w)->devPrivates[PictureWindowPrivateIndex].ptr = (pointer) (p))
#define VERIFY_PICTURE(pPicture, pid, client, mode, err) {\
pPicture = SecurityLookupIDByType(client, pid, PictureType, mode);\
if (!pPicture) { \
client->errorValue = pid; \
return err; \
} \
}
#define VERIFY_ALPHA(pPicture, pid, client, mode, err) {\
if (pid == None) \
pPicture = 0; \
else { \
VERIFY_PICTURE(pPicture, pid, client, mode, err); \
} \
} \
Bool
PictureDestroyWindow (WindowPtr pWindow);
Bool
PictureCloseScreen (int Index, ScreenPtr pScreen);
void
PictureStoreColors (ColormapPtr pColormap, int ndef, xColorItem *pdef);
Bool
PictureInitIndexedFormats (ScreenPtr pScreen);
Bool
PictureSetSubpixelOrder (ScreenPtr pScreen, int subpixel);
int
PictureGetSubpixelOrder (ScreenPtr pScreen);
PictFormatPtr
PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp);
PictFormatPtr
PictureMatchVisual (ScreenPtr pScreen, int depth, VisualPtr pVisual);
PictFormatPtr
PictureMatchFormat (ScreenPtr pScreen, int depth, CARD32 format);
Bool
PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats);
int
PictureGetFilterId (char *filter, int len, Bool makeit);
char *
PictureGetFilterName (int id);
int
PictureAddFilter (ScreenPtr pScreen, char *filter, xFixed *params, int nparams);
Bool
PictureSetFilterAlias (ScreenPtr pScreen, char *filter, char *alias);
Bool
PictureSetDefaultFilters (ScreenPtr pScreen);
void
PictureResetFilters (ScreenPtr pScreen);
PictFilterPtr
PictureFindFilter (ScreenPtr pScreen, char *name, int len);
int
SetPictureFilter (PicturePtr pPicture, char *name, int len, xFixed *params, int nparams);
Bool
PictureFinishInit (void);
void
SetPictureToDefaults (PicturePtr pPicture);
PicturePtr
AllocatePicture (ScreenPtr pScreen);
#if 0
Bool
miPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats);
#endif
PicturePtr
CreatePicture (Picture pid,
DrawablePtr pDrawable,
PictFormatPtr pFormat,
Mask mask,
XID *list,
ClientPtr client,
int *error);
int
ChangePicture (PicturePtr pPicture,
Mask vmask,
XID *vlist,
DevUnion *ulist,
ClientPtr client);
int
SetPictureClipRects (PicturePtr pPicture,
int xOrigin,
int yOrigin,
int nRect,
xRectangle *rects);
int
SetPictureTransform (PicturePtr pPicture,
PictTransform *transform);
void
ValidatePicture(PicturePtr pPicture);
int
FreePicture (pointer pPicture,
XID pid);
int
FreePictFormat (pointer pPictFormat,
XID pid);
void
CompositePicture (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
CompositeGlyphs (CARD8 op,
PicturePtr pSrc,
PicturePtr pDst,
PictFormatPtr maskFormat,
INT16 xSrc,
INT16 ySrc,
int nlist,
GlyphListPtr lists,
GlyphPtr *glyphs);
void
CompositeRects (CARD8 op,
PicturePtr pDst,
xRenderColor *color,
int nRect,
xRectangle *rects);
void
CompositeTrapezoids (CARD8 op,
PicturePtr pSrc,
PicturePtr pDst,
PictFormatPtr maskFormat,
INT16 xSrc,
INT16 ySrc,
int ntrap,
xTrapezoid *traps);
void
CompositeTriangles (CARD8 op,
PicturePtr pSrc,
PicturePtr pDst,
PictFormatPtr maskFormat,
INT16 xSrc,
INT16 ySrc,
int ntriangles,
xTriangle *triangles);
void
CompositeTriStrip (CARD8 op,
PicturePtr pSrc,
PicturePtr pDst,
PictFormatPtr maskFormat,
INT16 xSrc,
INT16 ySrc,
int npoints,
xPointFixed *points);
void
CompositeTriFan (CARD8 op,
PicturePtr pSrc,
PicturePtr pDst,
PictFormatPtr maskFormat,
INT16 xSrc,
INT16 ySrc,
int npoints,
xPointFixed *points);
Bool
PictureTransformPoint (PictTransformPtr transform,
PictVectorPtr vector);
void RenderExtensionInit (void);
Bool
AnimCurInit (ScreenPtr pScreen);
int
AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *ppCursor);
#ifdef XINERAMA
void PanoramiXRenderInit (void);
void PanoramiXRenderReset (void);
#endif
#endif /* _PICTURESTR_H_ */

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;
}

796
xfixes/region.c Executable file
View File

@ -0,0 +1,796 @@
/*
* $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>
#ifdef SKK
#ifdef SHAPE
#include <shapeint.h>
#endif
#endif
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);
}

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;
}

225
xfixes/xfixes.c Executable file
View File

@ -0,0 +1,225 @@
/*
* $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 */
};
#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,
};
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,
};
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_ */

233
xfixes/xfixesint.h Executable file
View File

@ -0,0 +1,233 @@
/*
* $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);
#endif /* _XFIXESINT_H_ */