From 8a87b702871f1cc375b74c9fbf4b6e7ef072c372 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Tue, 4 Nov 2025 16:30:42 +0100 Subject: [PATCH] dix: add dixAnyOtherGrabbed() and unexport GrabInProgress * the `GrabInProgress` field isn't used by any known drivers, thus no need to export it * the only in-tree consumer outside of it's source file is Xext/saver.c, which actually just wants to know whether any *other* client already grabbed the server - asking the OS layer isn't the right source (should ask dix/dispatch.c instead) Therefore adding a simple function for that check into dispatch.c (where grab/ungrab is actually controlled), so we can easily make this internal field static again. Signed-off-by: Enrico Weigelt, metux IT consult --- Xext/saver.c | 2 +- dix/dispatch.c | 6 ++++++ dix/dix_priv.h | 16 ++++++++++++++++ dix/dixgrabs_priv.h | 6 ------ os/connection.c | 2 +- 5 files changed, 24 insertions(+), 8 deletions(-) diff --git a/Xext/saver.c b/Xext/saver.c index 828d4fc6e2..d1f2689855 100644 --- a/Xext/saver.c +++ b/Xext/saver.c @@ -469,7 +469,7 @@ CreateSaverWindow(ScreenPtr pScreen) pPriv->installedMap = None; - if (GrabInProgress && GrabInProgress != pAttr->client->index) + if (dixAnyOtherGrabbed(pAttr->client)) return FALSE; pWin = dixCreateWindow(pSaver->wid, pScreen->root, diff --git a/dix/dispatch.c b/dix/dispatch.c index a51f18be6a..05bc75be72 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -4298,3 +4298,9 @@ DetachOffloadGPU(ScreenPtr secondary) secondary->is_offload_secondary = FALSE; } +bool dixAnyOtherGrabbed(ClientPtr client) +{ + return ((grabState == GrabActive) && + (grabClient != NULL) && + (grabClient != client)); +} diff --git a/dix/dix_priv.h b/dix/dix_priv.h index c8abe051fc..6bee33b7ee 100644 --- a/dix/dix_priv.h +++ b/dix/dix_priv.h @@ -10,6 +10,7 @@ * drivers or extension modules. Thus the definitions here are not part of the * Xserver's module API/ABI. */ +#include #include #include @@ -807,4 +808,19 @@ static inline void SwapLongs(CARD32 *list, unsigned long count) { #define SwapRestL(stuff) \ SwapLongs((CARD32 *)(stuff + 1), (client->req_len - (sizeof(*stuff) >> 2))) +/* + * retrieve current grab client or NULL (if no grab) + * + */ +ClientPtr dixGetGrabClient(void); + +/* + * Check whether any client has grabbed the server and it's not + * the given client. + * + * @param client the client to check against + * @return TRUE if any client, except the given one, has grabbed + */ +bool dixAnyOtherGrabbed(ClientPtr client); + #endif /* _XSERVER_DIX_PRIV_H */ diff --git a/dix/dixgrabs_priv.h b/dix/dixgrabs_priv.h index e483079da5..cbdc289ed2 100644 --- a/dix/dixgrabs_priv.h +++ b/dix/dixgrabs_priv.h @@ -12,12 +12,6 @@ #include "input.h" #include "cursor.h" -/* @brief tells which client ID currently has a grab - * - * used by OS layer and screensaver - */ -extern int GrabInProgress; - struct _GrabParameters; /** diff --git a/os/connection.c b/os/connection.c index 5d5fcb0990..35ddb7b0a4 100644 --- a/os/connection.c +++ b/os/connection.c @@ -139,7 +139,7 @@ static pid_t ParentProcess; static Bool RunFromSmartParent; /* send SIGUSR1 to parent process */ #endif -int GrabInProgress = 0; +static int GrabInProgress = 0; static void EstablishNewConnections(int curconn, int ready, void *data);