damage: use REQUEST_HEAD_STRUCT and REQUEST_FIELD_* macros
Use the new macros to make request struct parsing / field swapping much easier. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
c729bfd1f9
commit
52bf89e19f
|
|
@ -24,6 +24,7 @@
|
||||||
#include <dix-config.h>
|
#include <dix-config.h>
|
||||||
|
|
||||||
#include "dix/dix_priv.h"
|
#include "dix/dix_priv.h"
|
||||||
|
#include "dix/request_priv.h"
|
||||||
#include "os/client_priv.h"
|
#include "os/client_priv.h"
|
||||||
#include "Xext/panoramiX.h"
|
#include "Xext/panoramiX.h"
|
||||||
#include "Xext/panoramiXsrv.h"
|
#include "Xext/panoramiXsrv.h"
|
||||||
|
|
@ -181,16 +182,16 @@ DamageExtSetCritical(ClientPtr pClient, Bool critical)
|
||||||
static int
|
static int
|
||||||
ProcDamageQueryVersion(ClientPtr client)
|
ProcDamageQueryVersion(ClientPtr client)
|
||||||
{
|
{
|
||||||
|
REQUEST_HEAD_STRUCT(xDamageQueryVersionReq);
|
||||||
|
REQUEST_FIELD_CARD32(majorVersion);
|
||||||
|
REQUEST_FIELD_CARD32(minorVersion);
|
||||||
|
|
||||||
DamageClientPtr pDamageClient = GetDamageClient(client);
|
DamageClientPtr pDamageClient = GetDamageClient(client);
|
||||||
xDamageQueryVersionReply rep = {
|
xDamageQueryVersionReply rep = {
|
||||||
.type = X_Reply,
|
.type = X_Reply,
|
||||||
.sequenceNumber = client->sequence,
|
.sequenceNumber = client->sequence,
|
||||||
};
|
};
|
||||||
|
|
||||||
REQUEST(xDamageQueryVersionReq);
|
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(xDamageQueryVersionReq);
|
|
||||||
|
|
||||||
if (stuff->majorVersion < SERVER_DAMAGE_MAJOR_VERSION) {
|
if (stuff->majorVersion < SERVER_DAMAGE_MAJOR_VERSION) {
|
||||||
rep.majorVersion = stuff->majorVersion;
|
rep.majorVersion = stuff->majorVersion;
|
||||||
rep.minorVersion = stuff->minorVersion;
|
rep.minorVersion = stuff->minorVersion;
|
||||||
|
|
@ -301,8 +302,9 @@ static int
|
||||||
ProcDamageCreate(ClientPtr client)
|
ProcDamageCreate(ClientPtr client)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
REQUEST(xDamageCreateReq);
|
REQUEST_HEAD_STRUCT(xDamageCreateReq);
|
||||||
REQUEST_SIZE_MATCH(xDamageCreateReq);
|
REQUEST_FIELD_CARD32(damage);
|
||||||
|
REQUEST_FIELD_CARD32(drawable);
|
||||||
|
|
||||||
#ifdef PANORAMIX
|
#ifdef PANORAMIX
|
||||||
if (damageUseXinerama)
|
if (damageUseXinerama)
|
||||||
|
|
@ -317,7 +319,9 @@ ProcDamageCreate(ClientPtr client)
|
||||||
static int
|
static int
|
||||||
ProcDamageDestroy(ClientPtr client)
|
ProcDamageDestroy(ClientPtr client)
|
||||||
{
|
{
|
||||||
REQUEST(xDamageDestroyReq);
|
REQUEST_HEAD_STRUCT(xDamageDestroyReq);
|
||||||
|
REQUEST_FIELD_CARD32(damage);
|
||||||
|
|
||||||
DamageExtPtr pDamageExt;
|
DamageExtPtr pDamageExt;
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(xDamageDestroyReq);
|
REQUEST_SIZE_MATCH(xDamageDestroyReq);
|
||||||
|
|
@ -411,12 +415,15 @@ DamageExtSubtract(DamageExtPtr pDamageExt, const RegionPtr pRegion)
|
||||||
static int
|
static int
|
||||||
ProcDamageSubtract(ClientPtr client)
|
ProcDamageSubtract(ClientPtr client)
|
||||||
{
|
{
|
||||||
REQUEST(xDamageSubtractReq);
|
REQUEST_HEAD_STRUCT(xDamageSubtractReq);
|
||||||
|
REQUEST_FIELD_CARD32(damage);
|
||||||
|
REQUEST_FIELD_CARD32(repair);
|
||||||
|
REQUEST_FIELD_CARD32(parts);
|
||||||
|
|
||||||
DamageExtPtr pDamageExt;
|
DamageExtPtr pDamageExt;
|
||||||
RegionPtr pRepair;
|
RegionPtr pRepair;
|
||||||
RegionPtr pParts;
|
RegionPtr pParts;
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(xDamageSubtractReq);
|
|
||||||
VERIFY_DAMAGEEXT(pDamageExt, stuff->damage, client, DixWriteAccess);
|
VERIFY_DAMAGEEXT(pDamageExt, stuff->damage, client, DixWriteAccess);
|
||||||
VERIFY_REGION_OR_NONE(pRepair, stuff->repair, client, DixWriteAccess);
|
VERIFY_REGION_OR_NONE(pRepair, stuff->repair, client, DixWriteAccess);
|
||||||
VERIFY_REGION_OR_NONE(pParts, stuff->parts, client, DixWriteAccess);
|
VERIFY_REGION_OR_NONE(pParts, stuff->parts, client, DixWriteAccess);
|
||||||
|
|
@ -444,12 +451,14 @@ ProcDamageSubtract(ClientPtr client)
|
||||||
static int
|
static int
|
||||||
ProcDamageAdd(ClientPtr client)
|
ProcDamageAdd(ClientPtr client)
|
||||||
{
|
{
|
||||||
REQUEST(xDamageAddReq);
|
REQUEST_HEAD_STRUCT(xDamageAddReq);
|
||||||
|
REQUEST_FIELD_CARD32(drawable);
|
||||||
|
REQUEST_FIELD_CARD32(region);
|
||||||
|
|
||||||
DrawablePtr pDrawable;
|
DrawablePtr pDrawable;
|
||||||
RegionPtr pRegion;
|
RegionPtr pRegion;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(xDamageAddReq);
|
|
||||||
VERIFY_REGION(pRegion, stuff->region, client, DixWriteAccess);
|
VERIFY_REGION(pRegion, stuff->region, client, DixWriteAccess);
|
||||||
rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
|
rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
|
||||||
DixWriteAccess);
|
DixWriteAccess);
|
||||||
|
|
@ -488,78 +497,6 @@ ProcDamageDispatch(ClientPtr client)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _X_COLD
|
|
||||||
SProcDamageQueryVersion(ClientPtr client)
|
|
||||||
{
|
|
||||||
REQUEST(xDamageQueryVersionReq);
|
|
||||||
REQUEST_SIZE_MATCH(xDamageQueryVersionReq);
|
|
||||||
swapl(&stuff->majorVersion);
|
|
||||||
swapl(&stuff->minorVersion);
|
|
||||||
return ProcDamageQueryVersion(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int _X_COLD
|
|
||||||
SProcDamageCreate(ClientPtr client)
|
|
||||||
{
|
|
||||||
REQUEST(xDamageCreateReq);
|
|
||||||
REQUEST_SIZE_MATCH(xDamageCreateReq);
|
|
||||||
swapl(&stuff->damage);
|
|
||||||
swapl(&stuff->drawable);
|
|
||||||
return ProcDamageCreate(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int _X_COLD
|
|
||||||
SProcDamageDestroy(ClientPtr client)
|
|
||||||
{
|
|
||||||
REQUEST(xDamageDestroyReq);
|
|
||||||
REQUEST_SIZE_MATCH(xDamageDestroyReq);
|
|
||||||
swapl(&stuff->damage);
|
|
||||||
return ProcDamageDestroy(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int _X_COLD
|
|
||||||
SProcDamageSubtract(ClientPtr client)
|
|
||||||
{
|
|
||||||
REQUEST(xDamageSubtractReq);
|
|
||||||
REQUEST_SIZE_MATCH(xDamageSubtractReq);
|
|
||||||
swapl(&stuff->damage);
|
|
||||||
swapl(&stuff->repair);
|
|
||||||
swapl(&stuff->parts);
|
|
||||||
return ProcDamageSubtract(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int _X_COLD
|
|
||||||
SProcDamageAdd(ClientPtr client)
|
|
||||||
{
|
|
||||||
REQUEST(xDamageAddReq);
|
|
||||||
REQUEST_SIZE_MATCH(xDamageSubtractReq);
|
|
||||||
swapl(&stuff->drawable);
|
|
||||||
swapl(&stuff->region);
|
|
||||||
return ProcDamageAdd(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int _X_COLD
|
|
||||||
SProcDamageDispatch(ClientPtr client)
|
|
||||||
{
|
|
||||||
REQUEST(xReq);
|
|
||||||
switch (stuff->data) {
|
|
||||||
/* version 1 */
|
|
||||||
case X_DamageQueryVersion:
|
|
||||||
return SProcDamageQueryVersion(client);
|
|
||||||
case X_DamageCreate:
|
|
||||||
return SProcDamageCreate(client);
|
|
||||||
case X_DamageDestroy:
|
|
||||||
return SProcDamageDestroy(client);
|
|
||||||
case X_DamageSubtract:
|
|
||||||
return SProcDamageSubtract(client);
|
|
||||||
/* version 1.1 */
|
|
||||||
case X_DamageAdd:
|
|
||||||
return SProcDamageAdd(client);
|
|
||||||
default:
|
|
||||||
return BadRequest;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
FreeDamageExt(void *value, XID did)
|
FreeDamageExt(void *value, XID did)
|
||||||
{
|
{
|
||||||
|
|
@ -729,7 +666,7 @@ DamageExtensionInit(void)
|
||||||
|
|
||||||
if ((extEntry = AddExtension(DAMAGE_NAME, XDamageNumberEvents,
|
if ((extEntry = AddExtension(DAMAGE_NAME, XDamageNumberEvents,
|
||||||
XDamageNumberErrors,
|
XDamageNumberErrors,
|
||||||
ProcDamageDispatch, SProcDamageDispatch,
|
ProcDamageDispatch, ProcDamageDispatch,
|
||||||
NULL, StandardMinorOpcode)) != 0) {
|
NULL, StandardMinorOpcode)) != 0) {
|
||||||
DamageReqCode = (unsigned char) extEntry->base;
|
DamageReqCode = (unsigned char) extEntry->base;
|
||||||
DamageEventBase = extEntry->eventBase;
|
DamageEventBase = extEntry->eventBase;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue