From 361a8ef46f4b8042ebb689aaf8f649ae7ac9e9a4 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Thu, 3 Apr 2025 14:01:47 +0200 Subject: [PATCH] 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 --- dix/selection.c | 14 +++++++++----- dix/swaprep.c | 9 --------- dix/tables.c | 2 +- include/swaprep.h | 5 ----- 4 files changed, 10 insertions(+), 20 deletions(-) diff --git a/dix/selection.c b/dix/selection.c index ec9b4e85b..ada2ba68b 100644 --- a/dix/selection.c +++ b/dix/selection.c @@ -219,7 +219,6 @@ ProcGetSelectionOwner(ClientPtr client) { int rc; Selection *pSel; - xGetSelectionOwnerReply reply; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); @@ -229,7 +228,7 @@ ProcGetSelectionOwner(ClientPtr client) return BadAtom; } - reply = (xGetSelectionOwnerReply) { + xGetSelectionOwnerReply rep = { .type = X_Reply, .sequenceNumber = client->sequence, .length = 0, @@ -237,13 +236,18 @@ ProcGetSelectionOwner(ClientPtr client) rc = dixLookupSelection(&pSel, stuff->id, client, DixGetAttrAccess); if (rc == Success) - reply.owner = pSel->window; + rep.owner = pSel->window; else if (rc == BadMatch) - reply.owner = None; + rep.owner = None; else return rc; - WriteReplyToClient(client, sizeof(xGetSelectionOwnerReply), &reply); + if (client->swapped) { + swaps(&rep.sequenceNumber); + swapl(&rep.owner); + } + + WriteToClient(client, sizeof(rep), &rep); return Success; } diff --git a/dix/swaprep.c b/dix/swaprep.c index 76234a308..cacbf7896 100644 --- a/dix/swaprep.c +++ b/dix/swaprep.c @@ -249,15 +249,6 @@ SListPropertiesReply(ClientPtr pClient, int size, xListPropertiesReply * 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 SQueryPointerReply(ClientPtr pClient, int size, xQueryPointerReply * pRep) { diff --git a/dix/tables.c b/dix/tables.c index 1d5ec3ef1..7b20c1236 100644 --- a/dix/tables.c +++ b/dix/tables.c @@ -738,7 +738,7 @@ ReplySwapPtr ReplySwapVector[256] = { (ReplySwapPtr) SGetPropertyReply, /* 20 */ (ReplySwapPtr) SListPropertiesReply, ReplyNotSwappd, - (ReplySwapPtr) SGetSelectionOwnerReply, + ReplyNotSwappd, ReplyNotSwappd, ReplyNotSwappd, /* 25 */ (ReplySwapPtr) SGenericReply, /* SGrabPointerReply, */ diff --git a/include/swaprep.h b/include/swaprep.h index 133b022c7..4bb248cc3 100644 --- a/include/swaprep.h +++ b/include/swaprep.h @@ -67,11 +67,6 @@ extern void SListPropertiesReply(ClientPtr /* pClient */ , int /* size */ , xListPropertiesReply * /* pRep */ ); -extern void SGetSelectionOwnerReply(ClientPtr /* pClient */ , - int /* size */ , - xGetSelectionOwnerReply * - /* pRep */ ); - extern void SQueryPointerReply(ClientPtr /* pClient */ , int /* size */ , xQueryPointerReply * /* pRep */ );