dix: add dixResouceIsServerOwned()

Little helper function for checking whether a resource XID
belongs to the server itself.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2025-03-05 16:18:31 +01:00
parent 1cbfe67a5a
commit 4ae7dca761
4 changed files with 13 additions and 5 deletions

View File

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

View File

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

View File

@ -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 */

View File

@ -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 */