From d53a61a14d97be4a6e2f3eaa988eeefb0b396cd4 Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Fri, 3 Apr 2026 14:33:50 +0200 Subject: [PATCH] dix: Add dixSetSelectionOwner() To implement selection bridges, we need to be able to set the SelectionOwner from the Xserver code. Rather than duplicating the dix code for ProcSetSelectionOwner(), move the code to its own dixSetSelectionOwner() function, and hook that from the existing ProcSetSelectionOwner(). With that, a DDX can set the selection owner as intended. This is preparation work for the following commits, no functional change intended. Signed-off-by: Olivier Fourdan Part-of: --- dix/selection.c | 35 +++++++++++++++++++++-------------- include/selection.h | 3 +++ 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/dix/selection.c b/dix/selection.c index 622e0646a..4ba99348f 100644 --- a/dix/selection.c +++ b/dix/selection.c @@ -154,38 +154,33 @@ DeleteClientFromAnySelections(ClientPtr client) } int -ProcSetSelectionOwner(ClientPtr client) +dixSetSelectionOwner(ClientPtr client, Atom selection, + Window window, TimeStamp time) { WindowPtr pWin = NULL; - TimeStamp time; Selection *pSel; int rc; - REQUEST(xSetSelectionOwnerReq); - REQUEST_SIZE_MATCH(xSetSelectionOwnerReq); - - UpdateCurrentTime(); - time = ClientTimeToServerTime(stuff->time); - /* If the client's time stamp is in the future relative to the server's time stamp, do not set the selection, just return success. */ if (CompareTimeStamps(time, currentTime) == LATER) return Success; - if (stuff->window != None) { - rc = dixLookupWindow(&pWin, stuff->window, client, DixSetAttrAccess); + if (window != None) { + rc = dixLookupWindow(&pWin, window, client, DixSetAttrAccess); if (rc != Success) return rc; } - if (!ValidAtom(stuff->selection)) { - client->errorValue = stuff->selection; + + if (!ValidAtom(selection)) { + client->errorValue = selection; return BadAtom; } /* * First, see if the selection is already set... */ - rc = dixLookupSelection(&pSel, stuff->selection, client, DixSetAttrAccess); + rc = dixLookupSelection(&pSel, selection, client, DixSetAttrAccess); if (rc != Success) return rc; @@ -207,7 +202,7 @@ ProcSetSelectionOwner(ClientPtr client) } pSel->lastTimeChanged = time; - pSel->window = stuff->window; + pSel->window = window; pSel->pWin = pWin; pSel->client = (pWin ? client : NullClient); @@ -215,6 +210,18 @@ ProcSetSelectionOwner(ClientPtr client) return Success; } +int +ProcSetSelectionOwner(ClientPtr client) +{ + REQUEST(xSetSelectionOwnerReq); + REQUEST_SIZE_MATCH(xSetSelectionOwnerReq); + + UpdateCurrentTime(); + + return dixSetSelectionOwner(client, stuff->selection, stuff->window, + ClientTimeToServerTime(stuff->time)); +} + int ProcGetSelectionOwner(ClientPtr client) { diff --git a/include/selection.h b/include/selection.h index 500439e37..2c9311192 100644 --- a/include/selection.h +++ b/include/selection.h @@ -72,6 +72,9 @@ typedef struct _Selection { extern _X_EXPORT int dixLookupSelection(Selection ** result, Atom name, ClientPtr client, Mask access_mode); +extern _X_EXPORT int dixSetSelectionOwner(ClientPtr client, Atom selection, + Window window, TimeStamp time); + extern _X_EXPORT Selection *CurrentSelections; extern _X_EXPORT CallbackListPtr SelectionCallback;