2006-11-26 11:13:41 -07:00
|
|
|
/*
|
|
|
|
* 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_DIX_CONFIG_H
|
|
|
|
#include <dix-config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "damageextint.h"
|
2010-07-27 13:02:24 -06:00
|
|
|
#include "protocol-versions.h"
|
2013-06-07 11:28:45 -06:00
|
|
|
#include "extinit.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static unsigned char DamageReqCode;
|
|
|
|
static int DamageEventBase;
|
|
|
|
static RESTYPE DamageExtType;
|
|
|
|
static RESTYPE DamageExtWinType;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
static DevPrivateKeyRec DamageClientPrivateKeyRec;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
#define DamageClientPrivateKey (&DamageClientPrivateKeyRec)
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
DamageExtNotify(DamageExtPtr pDamageExt, BoxPtr pBoxes, int nBoxes)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ClientPtr pClient = pDamageExt->pClient;
|
|
|
|
DamageClientPtr pDamageClient = GetDamageClient(pClient);
|
|
|
|
DrawablePtr pDrawable = pDamageExt->pDrawable;
|
|
|
|
xDamageNotifyEvent ev;
|
|
|
|
int i;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
UpdateCurrentTimeIf();
|
2013-06-07 11:28:45 -06:00
|
|
|
ev = (xDamageNotifyEvent) {
|
|
|
|
.type = DamageEventBase + XDamageNotify,
|
|
|
|
.level = pDamageExt->level,
|
|
|
|
.drawable = pDamageExt->drawable,
|
|
|
|
.damage = pDamageExt->id,
|
|
|
|
.timestamp = currentTime.milliseconds,
|
|
|
|
.geometry.x = pDrawable->x,
|
|
|
|
.geometry.y = pDrawable->y,
|
|
|
|
.geometry.width = pDrawable->width,
|
|
|
|
.geometry.height = pDrawable->height
|
|
|
|
};
|
2012-06-10 07:21:05 -06:00
|
|
|
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;
|
|
|
|
WriteEventsToClient(pClient, 1, (xEvent *) &ev);
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
|
|
|
ev.area.x = 0;
|
|
|
|
ev.area.y = 0;
|
|
|
|
ev.area.width = pDrawable->width;
|
|
|
|
ev.area.height = pDrawable->height;
|
|
|
|
WriteEventsToClient(pClient, 1, (xEvent *) &ev);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
/* Composite extension marks clients with manual Subwindows as critical */
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pDamageClient->critical > 0) {
|
|
|
|
SetCriticalOutputPending();
|
|
|
|
pClient->smart_priority = SMART_MAX_PRIORITY;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
DamageExtReport(DamagePtr pDamage, RegionPtr pRegion, void *closure)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
DamageExtPtr pDamageExt = closure;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
switch (pDamageExt->level) {
|
|
|
|
case DamageReportRawRegion:
|
|
|
|
case DamageReportDeltaRegion:
|
2012-06-10 07:21:05 -06:00
|
|
|
DamageExtNotify(pDamageExt, RegionRects(pRegion),
|
|
|
|
RegionNumRects(pRegion));
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
case DamageReportBoundingBox:
|
2012-06-10 07:21:05 -06:00
|
|
|
DamageExtNotify(pDamageExt, RegionExtents(pRegion), 1);
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
case DamageReportNonEmpty:
|
2012-06-10 07:21:05 -06:00
|
|
|
DamageExtNotify(pDamageExt, NullBox, 0);
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
case DamageReportNone:
|
2012-06-10 07:21:05 -06:00
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
DamageExtDestroy(DamagePtr pDamage, void *closure)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
DamageExtPtr pDamageExt = closure;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
pDamageExt->pDamage = 0;
|
|
|
|
if (pDamageExt->id)
|
2012-06-10 07:21:05 -06:00
|
|
|
FreeResource(pDamageExt->id, RT_NONE);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
DamageExtSetCritical(ClientPtr pClient, Bool critical)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
DamageClientPtr pDamageClient = GetDamageClient(pClient);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (pDamageClient)
|
2012-06-10 07:21:05 -06:00
|
|
|
pDamageClient->critical += critical ? 1 : -1;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ProcDamageQueryVersion(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
DamageClientPtr pDamageClient = GetDamageClient(client);
|
2013-06-07 11:28:45 -06:00
|
|
|
xDamageQueryVersionReply rep = {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0
|
|
|
|
};
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xDamageQueryVersionReq);
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xDamageQueryVersionReq);
|
2013-06-07 11:28:45 -06:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
if (stuff->majorVersion < SERVER_DAMAGE_MAJOR_VERSION) {
|
2012-06-10 07:21:05 -06:00
|
|
|
rep.majorVersion = stuff->majorVersion;
|
|
|
|
rep.minorVersion = stuff->minorVersion;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rep.majorVersion = SERVER_DAMAGE_MAJOR_VERSION;
|
|
|
|
if (stuff->majorVersion == SERVER_DAMAGE_MAJOR_VERSION &&
|
|
|
|
stuff->minorVersion < SERVER_DAMAGE_MINOR_VERSION)
|
|
|
|
rep.minorVersion = stuff->minorVersion;
|
|
|
|
else
|
|
|
|
rep.minorVersion = SERVER_DAMAGE_MINOR_VERSION;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
pDamageClient->major_version = rep.majorVersion;
|
|
|
|
pDamageClient->minor_version = rep.minorVersion;
|
|
|
|
if (client->swapped) {
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&rep.sequenceNumber);
|
|
|
|
swapl(&rep.length);
|
|
|
|
swapl(&rep.majorVersion);
|
|
|
|
swapl(&rep.minorVersion);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, sizeof(xDamageQueryVersionReply), &rep);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcDamageCreate(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
DrawablePtr pDrawable;
|
|
|
|
DamageExtPtr pDamageExt;
|
|
|
|
DamageReportLevel level;
|
|
|
|
RegionPtr pRegion;
|
|
|
|
int rc;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xDamageCreateReq);
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xDamageCreateReq);
|
|
|
|
LEGAL_NEW_RESOURCE(stuff->damage, client);
|
2007-11-24 10:55:21 -07:00
|
|
|
rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
|
2012-06-10 07:21:05 -06:00
|
|
|
DixGetAttrAccess | DixReadAccess);
|
2007-11-24 10:55:21 -07:00
|
|
|
if (rc != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return rc;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
switch (stuff->level) {
|
|
|
|
case XDamageReportRawRectangles:
|
2012-06-10 07:21:05 -06:00
|
|
|
level = DamageReportRawRegion;
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
case XDamageReportDeltaRectangles:
|
2012-06-10 07:21:05 -06:00
|
|
|
level = DamageReportDeltaRegion;
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
case XDamageReportBoundingBox:
|
2012-06-10 07:21:05 -06:00
|
|
|
level = DamageReportBoundingBox;
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
case XDamageReportNonEmpty:
|
2012-06-10 07:21:05 -06:00
|
|
|
level = DamageReportNonEmpty;
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
default:
|
2012-06-10 07:21:05 -06:00
|
|
|
client->errorValue = stuff->level;
|
|
|
|
return BadValue;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
pDamageExt = malloc(sizeof(DamageExtRec));
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!pDamageExt)
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadAlloc;
|
2006-11-26 11:13:41 -07:00
|
|
|
pDamageExt->id = stuff->damage;
|
2010-12-05 08:36:02 -07:00
|
|
|
pDamageExt->drawable = stuff->drawable;
|
2006-11-26 11:13:41 -07:00
|
|
|
pDamageExt->pDrawable = pDrawable;
|
|
|
|
pDamageExt->level = level;
|
|
|
|
pDamageExt->pClient = client;
|
2012-06-10 07:21:05 -06:00
|
|
|
pDamageExt->pDamage = DamageCreate(DamageExtReport,
|
|
|
|
DamageExtDestroy,
|
|
|
|
level,
|
|
|
|
FALSE, pDrawable->pScreen, pDamageExt);
|
|
|
|
if (!pDamageExt->pDamage) {
|
|
|
|
free(pDamageExt);
|
|
|
|
return BadAlloc;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!AddResource(stuff->damage, DamageExtType, (pointer) pDamageExt))
|
|
|
|
return BadAlloc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
DamageSetReportAfterOp(pDamageExt->pDamage, TRUE);
|
|
|
|
DamageRegister(pDamageExt->pDrawable, pDamageExt->pDamage);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pDrawable->type == DRAWABLE_WINDOW) {
|
|
|
|
pRegion = &((WindowPtr) pDrawable)->borderClip;
|
|
|
|
DamageReportDamage(pDamageExt->pDamage, pRegion);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcDamageDestroy(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xDamageDestroyReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
DamageExtPtr pDamageExt;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xDamageDestroyReq);
|
2007-11-24 10:55:21 -07:00
|
|
|
VERIFY_DAMAGEEXT(pDamageExt, stuff->damage, client, DixWriteAccess);
|
2012-06-10 07:21:05 -06:00
|
|
|
FreeResource(stuff->damage, RT_NONE);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcDamageSubtract(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xDamageSubtractReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
DamageExtPtr pDamageExt;
|
|
|
|
RegionPtr pRepair;
|
|
|
|
RegionPtr pParts;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xDamageSubtractReq);
|
2007-11-24 10:55:21 -07:00
|
|
|
VERIFY_DAMAGEEXT(pDamageExt, stuff->damage, client, DixWriteAccess);
|
|
|
|
VERIFY_REGION_OR_NONE(pRepair, stuff->repair, client, DixWriteAccess);
|
|
|
|
VERIFY_REGION_OR_NONE(pParts, stuff->parts, client, DixWriteAccess);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pDamageExt->level != DamageReportRawRegion) {
|
|
|
|
DamagePtr pDamage = pDamageExt->pDamage;
|
|
|
|
|
|
|
|
if (pRepair) {
|
|
|
|
if (pParts)
|
|
|
|
RegionIntersect(pParts, DamageRegion(pDamage), pRepair);
|
|
|
|
if (DamageSubtract(pDamage, pRepair))
|
|
|
|
DamageExtReport(pDamage, DamageRegion(pDamage),
|
|
|
|
(void *) pDamageExt);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (pParts)
|
|
|
|
RegionCopy(pParts, DamageRegion(pDamage));
|
|
|
|
DamageEmpty(pDamage);
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcDamageAdd(ClientPtr client)
|
2007-11-24 10:55:21 -07:00
|
|
|
{
|
|
|
|
REQUEST(xDamageAddReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
DrawablePtr pDrawable;
|
|
|
|
RegionPtr pRegion;
|
|
|
|
int rc;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xDamageAddReq);
|
|
|
|
VERIFY_REGION(pRegion, stuff->region, client, DixWriteAccess);
|
|
|
|
rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
|
2012-06-10 07:21:05 -06:00
|
|
|
DixWriteAccess);
|
2007-11-24 10:55:21 -07:00
|
|
|
if (rc != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return rc;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
|
|
|
/* The region is relative to the drawable origin, so translate it out to
|
|
|
|
* screen coordinates like damage expects.
|
|
|
|
*/
|
2010-12-05 08:36:02 -07:00
|
|
|
RegionTranslate(pRegion, pDrawable->x, pDrawable->y);
|
2010-12-21 13:10:44 -07:00
|
|
|
DamageDamageRegion(pDrawable, pRegion);
|
2010-12-05 08:36:02 -07:00
|
|
|
RegionTranslate(pRegion, -pDrawable->x, -pDrawable->y);
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
/* Major version controls available requests */
|
|
|
|
static const int version_requests[] = {
|
2012-06-10 07:21:05 -06:00
|
|
|
X_DamageQueryVersion, /* before client sends QueryVersion */
|
|
|
|
X_DamageAdd, /* Version 1 */
|
2006-11-26 11:13:41 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#define NUM_VERSION_REQUESTS (sizeof (version_requests) / sizeof (version_requests[0]))
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
static int (*ProcDamageVector[XDamageNumberRequests]) (ClientPtr) = {
|
2006-11-26 11:13:41 -07:00
|
|
|
/*************** Version 1 ******************/
|
|
|
|
ProcDamageQueryVersion,
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcDamageCreate, ProcDamageDestroy, ProcDamageSubtract,
|
2007-11-24 10:55:21 -07:00
|
|
|
/*************** Version 1.1 ****************/
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcDamageAdd,};
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcDamageDispatch(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xDamageReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
DamageClientPtr pDamageClient = GetDamageClient(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (pDamageClient->major_version >= NUM_VERSION_REQUESTS)
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadRequest;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (stuff->damageReqType > version_requests[pDamageClient->major_version])
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadRequest;
|
2006-11-26 11:13:41 -07:00
|
|
|
return (*ProcDamageVector[stuff->damageReqType]) (client);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
SProcDamageQueryVersion(ClientPtr client)
|
|
|
|
{
|
|
|
|
REQUEST(xDamageQueryVersionReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_SIZE_MATCH(xDamageQueryVersionReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swapl(&stuff->majorVersion);
|
|
|
|
swapl(&stuff->minorVersion);
|
2006-11-26 11:13:41 -07:00
|
|
|
return (*ProcDamageVector[stuff->damageReqType]) (client);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
SProcDamageCreate(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xDamageCreateReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
swaps(&stuff->length);
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_SIZE_MATCH(xDamageCreateReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swapl(&stuff->damage);
|
|
|
|
swapl(&stuff->drawable);
|
2006-11-26 11:13:41 -07:00
|
|
|
return (*ProcDamageVector[stuff->damageReqType]) (client);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
SProcDamageDestroy(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xDamageDestroyReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
swaps(&stuff->length);
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_SIZE_MATCH(xDamageDestroyReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swapl(&stuff->damage);
|
2006-11-26 11:13:41 -07:00
|
|
|
return (*ProcDamageVector[stuff->damageReqType]) (client);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
SProcDamageSubtract(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xDamageSubtractReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
swaps(&stuff->length);
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_SIZE_MATCH(xDamageSubtractReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swapl(&stuff->damage);
|
|
|
|
swapl(&stuff->repair);
|
|
|
|
swapl(&stuff->parts);
|
2006-11-26 11:13:41 -07:00
|
|
|
return (*ProcDamageVector[stuff->damageReqType]) (client);
|
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
SProcDamageAdd(ClientPtr client)
|
2007-11-24 10:55:21 -07:00
|
|
|
{
|
|
|
|
REQUEST(xDamageAddReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
2007-11-24 10:55:21 -07:00
|
|
|
REQUEST_SIZE_MATCH(xDamageSubtractReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swapl(&stuff->drawable);
|
|
|
|
swapl(&stuff->region);
|
2007-11-24 10:55:21 -07:00
|
|
|
return (*ProcDamageVector[stuff->damageReqType]) (client);
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static int (*SProcDamageVector[XDamageNumberRequests]) (ClientPtr) = {
|
2006-11-26 11:13:41 -07:00
|
|
|
/*************** Version 1 ******************/
|
|
|
|
SProcDamageQueryVersion,
|
2012-06-10 07:21:05 -06:00
|
|
|
SProcDamageCreate, SProcDamageDestroy, SProcDamageSubtract,
|
2007-11-24 10:55:21 -07:00
|
|
|
/*************** Version 1.1 ****************/
|
2012-06-10 07:21:05 -06:00
|
|
|
SProcDamageAdd,};
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
SProcDamageDispatch(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xDamageReq);
|
|
|
|
if (stuff->damageReqType >= XDamageNumberRequests)
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadRequest;
|
2006-11-26 11:13:41 -07:00
|
|
|
return (*SProcDamageVector[stuff->damageReqType]) (client);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
DamageClientCallback(CallbackListPtr *list, pointer closure, pointer data)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
NewClientInfoRec *clientinfo = (NewClientInfoRec *) data;
|
|
|
|
ClientPtr pClient = clientinfo->client;
|
|
|
|
DamageClientPtr pDamageClient = GetDamageClient(pClient);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pDamageClient->critical = 0;
|
|
|
|
pDamageClient->major_version = 0;
|
|
|
|
pDamageClient->minor_version = 0;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/*ARGSUSED*/ static void
|
|
|
|
DamageResetProc(ExtensionEntry * extEntry)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
DeleteCallback(&ClientStateCallback, DamageClientCallback, 0);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
FreeDamageExt(pointer value, XID did)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
DamageExtPtr pDamageExt = (DamageExtPtr) value;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Get rid of the resource table entry hanging from the window id
|
|
|
|
*/
|
|
|
|
pDamageExt->id = 0;
|
|
|
|
if (WindowDrawable(pDamageExt->pDrawable->type))
|
2012-06-10 07:21:05 -06:00
|
|
|
FreeResourceByType(pDamageExt->pDrawable->id, DamageExtWinType, TRUE);
|
|
|
|
if (pDamageExt->pDamage) {
|
|
|
|
DamageUnregister(pDamageExt->pDrawable, pDamageExt->pDamage);
|
|
|
|
DamageDestroy(pDamageExt->pDamage);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
free(pDamageExt);
|
2006-11-26 11:13:41 -07:00
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
FreeDamageExtWin(pointer value, XID wid)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
DamageExtPtr pDamageExt = (DamageExtPtr) value;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (pDamageExt->id)
|
2012-06-10 07:21:05 -06:00
|
|
|
FreeResource(pDamageExt->id, RT_NONE);
|
2006-11-26 11:13:41 -07:00
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
SDamageNotifyEvent(xDamageNotifyEvent * from, xDamageNotifyEvent * to)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
to->type = from->type;
|
2012-06-10 07:21:05 -06:00
|
|
|
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);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DamageExtensionInit(void)
|
|
|
|
{
|
|
|
|
ExtensionEntry *extEntry;
|
2012-06-10 07:21:05 -06:00
|
|
|
int s;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
for (s = 0; s < screenInfo.numScreens; s++)
|
2012-06-10 07:21:05 -06:00
|
|
|
DamageSetup(screenInfo.screens[s]);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
DamageExtType = CreateNewResourceType(FreeDamageExt, "DamageExt");
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!DamageExtType)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
DamageExtWinType = CreateNewResourceType(FreeDamageExtWin, "DamageExtWin");
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!DamageExtWinType)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (!dixRegisterPrivateKey
|
|
|
|
(&DamageClientPrivateKeyRec, PRIVATE_CLIENT, 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;
|
|
|
|
EventSwapVector[DamageEventBase + XDamageNotify] =
|
|
|
|
(EventSwapPtr) SDamageNotifyEvent;
|
|
|
|
SetResourceTypeErrorValue(DamageExtType,
|
|
|
|
extEntry->errorBase + BadDamage);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|