dix: write out X_SetPointerMapping reply directly

No need for using a complex callback machinery, if we just move the
little pieces of byte-swapping directly into the request handler.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2025-04-03 16:04:10 +02:00
parent 6091ce6d57
commit 1ef0e46cbc
2 changed files with 16 additions and 13 deletions

View File

@ -1888,7 +1888,6 @@ ProcSetPointerMapping(ClientPtr client)
int ret; int ret;
int i, j; int i, j;
DeviceIntPtr ptr = PickPointer(client); DeviceIntPtr ptr = PickPointer(client);
xSetPointerMappingReply rep;
REQUEST(xSetPointerMappingReq); REQUEST(xSetPointerMappingReq);
REQUEST_AT_LEAST_SIZE(xSetPointerMappingReq); REQUEST_AT_LEAST_SIZE(xSetPointerMappingReq);
@ -1897,12 +1896,6 @@ ProcSetPointerMapping(ClientPtr client)
bytes_to_int32(sizeof(xSetPointerMappingReq) + stuff->nElts)) bytes_to_int32(sizeof(xSetPointerMappingReq) + stuff->nElts))
return BadLength; return BadLength;
rep = (xSetPointerMappingReply) {
.type = X_Reply,
.success = MappingSuccess,
.sequenceNumber = client->sequence,
.length = 0
};
map = (BYTE *) &stuff[1]; map = (BYTE *) &stuff[1];
/* So we're bounded here by the number of core buttons. This check /* So we're bounded here by the number of core buttons. This check
@ -1928,14 +1921,24 @@ ProcSetPointerMapping(ClientPtr client)
} }
ret = ApplyPointerMapping(ptr, map, stuff->nElts, client); ret = ApplyPointerMapping(ptr, map, stuff->nElts, client);
if (ret == MappingBusy)
rep.success = ret; if (ret == -1)
else if (ret == -1)
return BadValue; return BadValue;
else if (ret != Success) if (ret != Success && ret != MappingBusy)
return ret; return ret;
WriteReplyToClient(client, sizeof(xSetPointerMappingReply), &rep); xSetPointerMappingReply rep = {
.type = X_Reply,
.success = MappingSuccess,
.sequenceNumber = client->sequence,
.success = ret,
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
}
WriteToClient(client, sizeof(rep), &rep);
return Success; return Success;
} }

View File

@ -831,7 +831,7 @@ ReplySwapPtr ReplySwapVector[256] = {
ReplyNotSwappd, ReplyNotSwappd,
ReplyNotSwappd, ReplyNotSwappd,
ReplyNotSwappd, /* 115 */ ReplyNotSwappd, /* 115 */
(ReplySwapPtr) SGenericReply, /* SetPointerMapping */ ReplyNotSwappd,
(ReplySwapPtr) SGetPointerMappingReply, (ReplySwapPtr) SGetPointerMappingReply,
ReplyNotSwappd, ReplyNotSwappd,
ReplyNotSwappd, /* 119 */ ReplyNotSwappd, /* 119 */