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);