dix: write out X_GetSelectionOwner 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 14:01:47 +02:00
parent 0812c4953a
commit 361a8ef46f
4 changed files with 10 additions and 20 deletions

View File

@ -219,7 +219,6 @@ ProcGetSelectionOwner(ClientPtr client)
{ {
int rc; int rc;
Selection *pSel; Selection *pSel;
xGetSelectionOwnerReply reply;
REQUEST(xResourceReq); REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq);
@ -229,7 +228,7 @@ ProcGetSelectionOwner(ClientPtr client)
return BadAtom; return BadAtom;
} }
reply = (xGetSelectionOwnerReply) { xGetSelectionOwnerReply rep = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0, .length = 0,
@ -237,13 +236,18 @@ ProcGetSelectionOwner(ClientPtr client)
rc = dixLookupSelection(&pSel, stuff->id, client, DixGetAttrAccess); rc = dixLookupSelection(&pSel, stuff->id, client, DixGetAttrAccess);
if (rc == Success) if (rc == Success)
reply.owner = pSel->window; rep.owner = pSel->window;
else if (rc == BadMatch) else if (rc == BadMatch)
reply.owner = None; rep.owner = None;
else else
return rc; return rc;
WriteReplyToClient(client, sizeof(xGetSelectionOwnerReply), &reply); if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.owner);
}
WriteToClient(client, sizeof(rep), &rep);
return Success; return Success;
} }

View File

@ -249,15 +249,6 @@ SListPropertiesReply(ClientPtr pClient, int size, xListPropertiesReply * pRep)
WriteToClient(pClient, size, pRep); WriteToClient(pClient, size, pRep);
} }
void _X_COLD
SGetSelectionOwnerReply(ClientPtr pClient, int size,
xGetSelectionOwnerReply * pRep)
{
swaps(&pRep->sequenceNumber);
swapl(&pRep->owner);
WriteToClient(pClient, size, pRep);
}
void _X_COLD void _X_COLD
SQueryPointerReply(ClientPtr pClient, int size, xQueryPointerReply * pRep) SQueryPointerReply(ClientPtr pClient, int size, xQueryPointerReply * pRep)
{ {

View File

@ -738,7 +738,7 @@ ReplySwapPtr ReplySwapVector[256] = {
(ReplySwapPtr) SGetPropertyReply, /* 20 */ (ReplySwapPtr) SGetPropertyReply, /* 20 */
(ReplySwapPtr) SListPropertiesReply, (ReplySwapPtr) SListPropertiesReply,
ReplyNotSwappd, ReplyNotSwappd,
(ReplySwapPtr) SGetSelectionOwnerReply, ReplyNotSwappd,
ReplyNotSwappd, ReplyNotSwappd,
ReplyNotSwappd, /* 25 */ ReplyNotSwappd, /* 25 */
(ReplySwapPtr) SGenericReply, /* SGrabPointerReply, */ (ReplySwapPtr) SGenericReply, /* SGrabPointerReply, */

View File

@ -67,11 +67,6 @@ extern void SListPropertiesReply(ClientPtr /* pClient */ ,
int /* size */ , int /* size */ ,
xListPropertiesReply * /* pRep */ ); xListPropertiesReply * /* pRep */ );
extern void SGetSelectionOwnerReply(ClientPtr /* pClient */ ,
int /* size */ ,
xGetSelectionOwnerReply *
/* pRep */ );
extern void SQueryPointerReply(ClientPtr /* pClient */ , extern void SQueryPointerReply(ClientPtr /* pClient */ ,
int /* size */ , int /* size */ ,
xQueryPointerReply * /* pRep */ ); xQueryPointerReply * /* pRep */ );