Xext: xtest: 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:
Enrico Weigelt, metux IT consult
2024-07-08 17:57:03 +02:00
parent 6021d051ae
commit 3354adaded

View File

@@ -39,6 +39,7 @@
#include "dix/dix_priv.h"
#include "dix/exevents_priv.h"
#include "dix/request_priv.h"
#include "os/osdep.h"
#include "misc.h"
@@ -90,6 +91,9 @@ static int XTestSwapFakeInput(ClientPtr /* client */ ,
static int
ProcXTestGetVersion(ClientPtr client)
{
REQUEST_HEAD_STRUCT(xXTestGetVersionReq);
REQUEST_FIELD_CARD16(minorVersion);
xXTestGetVersionReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
@@ -111,14 +115,16 @@ ProcXTestGetVersion(ClientPtr client)
static int
ProcXTestCompareCursor(ClientPtr client)
{
REQUEST(xXTestCompareCursorReq);
REQUEST_HEAD_STRUCT(xXTestCompareCursorReq);
REQUEST_FIELD_CARD32(window);
REQUEST_FIELD_CARD32(cursor);
xXTestCompareCursorReply rep;
WindowPtr pWin;
CursorPtr pCursor;
int rc;
DeviceIntPtr ptr = PickPointer(client);
REQUEST_SIZE_MATCH(xXTestCompareCursorReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc;
@@ -183,7 +189,14 @@ XTestDeviceSendEvents(DeviceIntPtr dev,
static int
ProcXTestFakeInput(ClientPtr client)
{
REQUEST(xXTestFakeInputReq);
REQUEST_HEAD_NO_CHECK(xXTestFakeInputReq);
if (client->swapped) {
int n = XTestSwapFakeInput(client, (xReq *)stuff);
if (n != Success)
return n;
}
int nev, n, type, rc;
xEvent *ev;
DeviceIntPtr dev = NULL;
@@ -373,7 +386,7 @@ ProcXTestFakeInput(ClientPtr client)
/* swap the request back so we can simply re-execute it */
if (client->swapped) {
(void) XTestSwapFakeInput(client, (xReq *) stuff);
swaps(&stuff->length);
REQUEST_FIELD_CARD16(length);
}
ResetCurrentRequest(client);
client->sequence--;
@@ -451,9 +464,8 @@ ProcXTestFakeInput(ClientPtr client)
static int
ProcXTestGrabControl(ClientPtr client)
{
REQUEST(xXTestGrabControlReq);
REQUEST_HEAD_STRUCT(xXTestGrabControlReq);
REQUEST_SIZE_MATCH(xXTestGrabControlReq);
if ((stuff->impervious != xTrue) && (stuff->impervious != xFalse)) {
client->errorValue = stuff->impervious;
return BadValue;
@@ -483,29 +495,6 @@ ProcXTestDispatch(ClientPtr client)
}
}
static int _X_COLD
SProcXTestGetVersion(ClientPtr client)
{
REQUEST(xXTestGetVersionReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXTestGetVersionReq);
swaps(&stuff->minorVersion);
return ProcXTestGetVersion(client);
}
static int _X_COLD
SProcXTestCompareCursor(ClientPtr client)
{
REQUEST(xXTestCompareCursorReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXTestCompareCursorReq);
swapl(&stuff->window);
swapl(&stuff->cursor);
return ProcXTestCompareCursor(client);
}
static int _X_COLD
XTestSwapFakeInput(ClientPtr client, xReq * req)
{
@@ -530,48 +519,6 @@ XTestSwapFakeInput(ClientPtr client, xReq * req)
return Success;
}
static int _X_COLD
SProcXTestFakeInput(ClientPtr client)
{
int n;
REQUEST(xReq);
swaps(&stuff->length);
n = XTestSwapFakeInput(client, stuff);
if (n != Success)
return n;
return ProcXTestFakeInput(client);
}
static int _X_COLD
SProcXTestGrabControl(ClientPtr client)
{
REQUEST(xXTestGrabControlReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXTestGrabControlReq);
return ProcXTestGrabControl(client);
}
static int _X_COLD
SProcXTestDispatch(ClientPtr client)
{
REQUEST(xReq);
switch (stuff->data) {
case X_XTestGetVersion:
return SProcXTestGetVersion(client);
case X_XTestCompareCursor:
return SProcXTestCompareCursor(client);
case X_XTestFakeInput:
return SProcXTestFakeInput(client);
case X_XTestGrabControl:
return SProcXTestGrabControl(client);
default:
return BadRequest;
}
}
/**
* Allocate an virtual slave device for xtest events, this
* is a slave device to inputInfo master devices
@@ -703,7 +650,7 @@ void
XTestExtensionInit(void)
{
AddExtension(XTestExtensionName, 0, 0,
ProcXTestDispatch, SProcXTestDispatch,
ProcXTestDispatch, ProcXTestDispatch,
XTestExtensionTearDown, StandardMinorOpcode);
xtest_evlist = InitEventList(GetMaximumEventsNum());