diff --git a/Xext/security.c b/Xext/security.c index 1052bc931..2e697dd6b 100644 --- a/Xext/security.c +++ b/Xext/security.c @@ -762,7 +762,7 @@ SecurityResource(CallbackListPtr *pcbl, void *unused, void *calldata) goto denied; /* special checks for server-owned resources */ - if (owner == serverClient) { + if (dixResouceIsServerOwned(rec->id)) { if (rec->rtype & RC_DRAWABLE) /* additional operations allowed on root windows */ allowed |= SecurityRootWindowExtraMask; diff --git a/dix/colormap.c b/dix/colormap.c index 1dfaebd45..d1428a113 100644 --- a/dix/colormap.c +++ b/dix/colormap.c @@ -220,8 +220,6 @@ static void FindColorInRootCmap(ColormapPtr /* pmap */ , (bits) += (base); \ while((bits) & ~(mask)) \ (bits) += ((bits) & ~(mask)); -/* ID of server as client */ -#define SERVER_ID 0 typedef struct _colorResource { Colormap mid; @@ -418,7 +416,7 @@ FreeColormap(void *value, XID mid) EntryPtr pent; ColormapPtr pmap = (ColormapPtr) value; - if (dixClientIdForXID(mid) != SERVER_ID) { + if (!dixResouceIsServerOwned(mid)) { (*pmap->pScreen->UninstallColormap) (pmap); WalkTree(pmap->pScreen, (VisitWindowProcPtr) TellNoMap, (void *) &mid); } diff --git a/dix/resource_priv.h b/dix/resource_priv.h index f7d4e4e36..cdbb377c4 100644 --- a/dix/resource_priv.h +++ b/dix/resource_priv.h @@ -82,4 +82,14 @@ static inline ClientPtr dixClientForXID(XID xid) { return NullClient; } +/* + * @brief check whether resource is owned by server + * + * @param XID the ID of the resource to check + * @return TRUE if resource is server owned + */ +static inline Bool dixResouceIsServerOwned(XID xid) { + return (dixClientForXID(xid) == serverClient); +} + #endif /* _XSERVER_DIX_RESOURCE_PRIV_H */ diff --git a/hw/xwayland/xwayland-pixmap.h b/hw/xwayland/xwayland-pixmap.h index 840e8e5ea..8d9388766 100644 --- a/hw/xwayland/xwayland-pixmap.h +++ b/hw/xwayland/xwayland-pixmap.h @@ -50,7 +50,7 @@ Bool xwl_pixmap_init(void); static inline Bool xwl_is_client_pixmap(PixmapPtr pixmap) { - return dixClientForXID(pixmap->drawable.id) != serverClient; + return (!dixResouceIsServerOwned(pixmap->drawable.id)); } #endif /* XWAYLAND_PIXMAP_H */