Compare commits

...

19 Commits

Author SHA1 Message Date
Enrico Weigelt, metux IT consult db667ff43c dix: unexport and document GetXIDRange()
Not used by any drivers (just the xcmisc extension), so no need
to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-05-15 19:06:47 +02:00
Enrico Weigelt, metux IT consult 452b9b0fb5 dix: unexport and document GetXIDList()
Not used by any drivers (just the xcmisc extension), so no need
to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-05-15 19:06:47 +02:00
Enrico Weigelt, metux IT consult ecf9f59650 dix: unexport and document HashResourceID()
Not used by any drivers/modules, so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-05-15 19:06:47 +02:00
Enrico Weigelt, metux IT consult b5dd5ebe85 dix: make CLIENTOFFSET macro private
Not used by any external drivers, so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-05-15 19:06:47 +02:00
Enrico Weigelt, metux IT consult 0cae563190 dix: make RESOURCE_ID_MASK private
Not used by any external drivers, so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-05-15 19:06:47 +02:00
Enrico Weigelt, metux IT consult 3942e5a419 dix: make RESOURCE_CLIENT_MASK macro private
Not used in any external modules, so no need to keep it public.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-05-15 19:06:47 +02:00
Enrico Weigelt, metux IT consult 98fd466992 dix: make CLIENT_BITS() macro private
Not used by any external drivers, so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-05-15 19:06:47 +02:00
Enrico Weigelt, metux IT consult 24cfc882cd dix: make SERVER_BIT define private
Not used by any external drivers, so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-05-15 19:06:47 +02:00
Enrico Weigelt, metux IT consult 4ac617e268 dix: make SameClient() macro private
Not used in any external modules, so need to keep it public.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-05-15 19:06:47 +02:00
Enrico Weigelt, metux IT consult 57551db4b0 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>
2025-05-15 19:06:47 +02:00
Enrico Weigelt, metux IT consult 0ef98ebf79 dix: let CreateGrab operate on ClientPtr instead of array index
Almost all callers have ClientPtr anyways, so we're just doing duplicate
array lookups. Just using ClientPtr directly is easier anyways.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-05-15 19:06:47 +02:00
Enrico Weigelt, metux IT consult 317053a20d dix: CreateColormap() pass in ClientPtr instead of client index
The function actually operates on ClientRec, so we can pass it in
directly, so it doesn't need to fetch it from clients[] array itself.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-05-15 19:06:47 +02:00
Enrico Weigelt, metux IT consult 2ef147e9e3 dix: add dixClientForXID()
Retrieves the ClientPtr for the owner of given resource.
This way reducing the sites directly accessing clients[] array.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-05-15 19:06:47 +02:00
Enrico Weigelt, metux IT consult 5c3404c619 include/resource.h: replace RESOURCE_CLIENT_BITS by ResourceClientBits()
We can write down the function name directly. Nobody else than a few
define's in here using that macro.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-05-15 19:06:47 +02:00
Enrico Weigelt, metux IT consult 37d6229ac5 dix: replace CLIENT_ID() macro by dixClientIdForXID() inline function
Make it type-safe and a bit more obvious what it really does,
also adding some inline documentation. Since it's just some
bit shifting magic, it's qualified for inlining.

The CLIENT_ID() macro isn't used by any external modules, so the
new function doesn't need to be in a public header.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-05-15 19:06:47 +02:00
Enrico Weigelt, metux IT consult 055ad81d06 dix: add dixClientForOtherClients()
Helper function for retrieving the owning client of an OtherClients.

It's an actual function, so callers don't need access to internal
knowledge (definition of struct _OtherClients, clients[] array, ...)

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-05-15 19:06:47 +02:00
Enrico Weigelt, metux IT consult 3789797ea3 dix: add dixClientForInputClients()
Helper function for retrieving the owning client of an InputClients.

It's an actual function, so callers don't need access to internal
knowledge (definition of struct _InputClients, clients[] array, ...)

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-05-15 19:06:47 +02:00
Enrico Weigelt, metux IT consult 51b4c8b767 dix: add dixClientForGrab()
Helper function for retrieving the owning client of a grab.

It's an actual function, so callers don't need access to internal
knowledge (definition of GrabRec, clients[] array, ...)

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-05-15 19:06:47 +02:00
Enrico Weigelt, metux IT consult 8acb734370 dix: replace wClient() macro by dixClientForWindow() inline function
Hide internals (drop the need to include windowstr.h), make it typesafe
as well as the naming easier to understand.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-05-15 19:06:47 +02:00
51 changed files with 438 additions and 241 deletions

View File

@ -1,6 +1,9 @@
#include <dix-config.h>
#include <stdlib.h>
#include "dix/resource_priv.h"
#include "misc.h"
#include "hashtable.h"

View File

@ -32,6 +32,7 @@ Equipment Corporation.
#include <X11/extensions/panoramiXproto.h>
#include "dix/dix_priv.h"
#include "dix/resource_priv.h"
#include "misc.h"
#include "cursor.h"
@ -352,7 +353,7 @@ PanoramiXFindIDByScrnum(RESTYPE type, XID id, int screen)
data.screen = screen;
data.id = id;
return LookupClientResourceComplex(clients[CLIENT_ID(id)], type,
return LookupClientResourceComplex(dixClientForXID(id), type,
XineramaFindIDByScrnum, &data);
}

View File

@ -32,6 +32,7 @@ in this Software without prior written authorization from The Open Group.
#include "dix/dix_priv.h"
#include "dix/registry_priv.h"
#include "dix/resource_priv.h"
#include "include/extinit_priv.h"
#include "os/audit.h"
#include "os/auth.h"
@ -207,7 +208,7 @@ SecurityDeleteAuthorization(void *value, XID id)
.type = SecurityEventBase + XSecurityAuthorizationRevoked,
.authId = pAuth->id
};
WriteEventsToClient(rClient(pEventClient), 1, (xEvent *) &are);
WriteEventsToClient(dixClientForOtherClients(pEventClient), 1, (xEvent *) &are);
FreeResource(pEventClient->resource, X11_RESTYPE_NONE);
}
@ -744,7 +745,6 @@ SecurityResource(CallbackListPtr *pcbl, void *unused, void *calldata)
{
XaceResourceAccessRec *rec = calldata;
SecurityStateRec *subj, *obj;
int cid = CLIENT_ID(rec->id);
Mask requested = rec->access_mode;
Mask allowed = SecurityResourceMask;
@ -759,8 +759,12 @@ SecurityResource(CallbackListPtr *pcbl, void *unused, void *calldata)
if (rec->rtype == X11_RESTYPE_WINDOW)
allowed |= SecurityWindowExtraMask;
ClientPtr owner = dixClientForXID(rec->id);
if (!owner)
goto denied;
/* special checks for server-owned resources */
if (cid == 0) {
if (dixResouceIsServerOwned(rec->id)) {
if (rec->rtype & RC_DRAWABLE)
/* additional operations allowed on root windows */
allowed |= SecurityRootWindowExtraMask;
@ -774,15 +778,15 @@ SecurityResource(CallbackListPtr *pcbl, void *unused, void *calldata)
allowed |= DixReadAccess;
}
if (clients[cid] != NULL) {
obj = dixLookupPrivate(&clients[cid]->devPrivates, stateKey);
if (SecurityDoCheck(subj, obj, requested, allowed) == Success)
return;
}
obj = dixLookupPrivate(&owner->devPrivates, stateKey);
if (SecurityDoCheck(subj, obj, requested, allowed) == Success)
return;
denied:
SecurityAudit("Security: denied client %d access %lx to resource 0x%lx "
"of client %d on request %s\n", rec->client->index,
(unsigned long)requested, (unsigned long)rec->id, cid,
(unsigned long)requested, (unsigned long)rec->id,
dixClientIdForXID(rec->id),
SecurityLookupRequestName(rec->client));
rec->status = BadAccess; /* deny access */
}
@ -858,13 +862,13 @@ SecurityProperty(CallbackListPtr *pcbl, void *unused, void *calldata)
Mask allowed = SecurityResourceMask | DixReadAccess;
subj = dixLookupPrivate(&rec->client->devPrivates, stateKey);
obj = dixLookupPrivate(&wClient(rec->pWin)->devPrivates, stateKey);
obj = dixLookupPrivate(&dixClientForWindow(rec->pWin)->devPrivates, stateKey);
if (SecurityDoCheck(subj, obj, requested, allowed) != Success) {
SecurityAudit("Security: denied client %d access to property %s "
"(atom 0x%x) window 0x%lx of client %d on request %s\n",
rec->client->index, NameForAtom(name), name,
(unsigned long)rec->pWin->drawable.id, wClient(rec->pWin)->index,
(unsigned long)rec->pWin->drawable.id, dixClientForWindow(rec->pWin)->index,
SecurityLookupRequestName(rec->client));
rec->status = BadAccess;
}
@ -880,7 +884,7 @@ SecuritySend(CallbackListPtr *pcbl, void *unused, void *calldata)
int i;
subj = dixLookupPrivate(&rec->client->devPrivates, stateKey);
obj = dixLookupPrivate(&wClient(rec->pWin)->devPrivates, stateKey);
obj = dixLookupPrivate(&dixClientForWindow(rec->pWin)->devPrivates, stateKey);
if (SecurityDoCheck(subj, obj, DixSendAccess, 0) == Success)
return;
@ -895,7 +899,7 @@ SecuritySend(CallbackListPtr *pcbl, void *unused, void *calldata)
rec->client->index,
LookupEventName(rec->events[i].u.u.type),
(unsigned long)rec->pWin->drawable.id,
wClient(rec->pWin)->index);
dixClientForWindow(rec->pWin)->index);
rec->status = BadAccess;
return;
}
@ -909,7 +913,7 @@ SecurityReceive(CallbackListPtr *pcbl, void *unused, void *calldata)
SecurityStateRec *subj, *obj;
subj = dixLookupPrivate(&rec->client->devPrivates, stateKey);
obj = dixLookupPrivate(&wClient(rec->pWin)->devPrivates, stateKey);
obj = dixLookupPrivate(&dixClientForWindow(rec->pWin)->devPrivates, stateKey);
if (SecurityDoCheck(subj, obj, DixReceiveAccess, 0) == Success)
return;
@ -917,7 +921,7 @@ SecurityReceive(CallbackListPtr *pcbl, void *unused, void *calldata)
SecurityAudit("Security: denied client %d from receiving an event "
"sent to window 0x%lx of client %d\n",
rec->client->index, (unsigned long)rec->pWin->drawable.id,
wClient(rec->pWin)->index);
dixClientForWindow(rec->pWin)->index);
rec->status = BadAccess;
}

View File

@ -28,18 +28,20 @@ from The Open Group.
#include <dix-config.h>
#include <stdint.h>
#include <X11/X.h>
#include <X11/Xproto.h>
#include <X11/extensions/xcmiscproto.h>
#include "dix/resource_priv.h"
#include "misc.h"
#include "os.h"
#include "dixstruct.h"
#include "extnsionst.h"
#include "swaprep.h"
#include <X11/extensions/xcmiscproto.h>
#include "extinit_priv.h"
#include <stdint.h>
static int
ProcXCMiscGetVersion(ClientPtr client)
{

View File

@ -12,6 +12,7 @@
#include <X11/extensions/XResproto.h>
#include "dix/registry_priv.h"
#include "dix/resource_priv.h"
#include "os/client_priv.h"
#include "misc.h"
@ -299,21 +300,21 @@ ProcXResQueryClientResources(ClientPtr client)
{
REQUEST(xXResQueryClientResourcesReq);
xXResQueryClientResourcesReply rep;
int i, clientID, num_types;
int i, num_types;
int *counts;
REQUEST_SIZE_MATCH(xXResQueryClientResourcesReq);
clientID = CLIENT_ID(stuff->xid);
ClientPtr resClient = dixClientForXID(stuff->xid);
if ((clientID >= currentMaxClients) || !clients[clientID]) {
if (!resClient) {
client->errorValue = stuff->xid;
return BadValue;
}
counts = calloc(lastResourceType + 1, sizeof(int));
FindAllClientResources(clients[clientID], ResFindAllRes, counts);
FindAllClientResources(resClient, ResFindAllRes, counts);
num_types = 0;
@ -375,21 +376,17 @@ ProcXResQueryClientPixmapBytes(ClientPtr client)
{
REQUEST(xXResQueryClientPixmapBytesReq);
xXResQueryClientPixmapBytesReply rep;
int clientID;
unsigned long bytes;
REQUEST_SIZE_MATCH(xXResQueryClientPixmapBytesReq);
clientID = CLIENT_ID(stuff->xid);
if ((clientID >= currentMaxClients) || !clients[clientID]) {
ClientPtr owner = dixClientForXID(stuff->xid);
if (!owner) {
client->errorValue = stuff->xid;
return BadValue;
}
bytes = 0;
FindAllClientResources(clients[clientID], ResFindResourcePixmaps,
unsigned long bytes = 0;
FindAllClientResources(owner, ResFindResourcePixmaps,
(void *) (&bytes));
rep = (xXResQueryClientPixmapBytesReply) {
@ -547,10 +544,9 @@ ConstructClientIds(ClientPtr client,
}
}
} else {
int clientID = CLIENT_ID(specs[specIdx].client);
if ((clientID < currentMaxClients) && clients[clientID]) {
if (!ConstructClientIdValue(client, clients[clientID],
ClientPtr owner = dixClientForXID(specs[specIdx].client);
if (owner) {
if (!ConstructClientIdValue(client, owner,
specs[specIdx].mask, ctx)) {
return BadAlloc;
}
@ -887,16 +883,12 @@ ConstructResourceBytesByResource(XID aboutClient, ConstructResourceBytesCtx *ctx
for (specIdx = 0; specIdx < ctx->numSpecs; ++specIdx) {
xXResResourceIdSpec *spec = ctx->specs + specIdx;
if (spec->resource) {
int cid = CLIENT_ID(spec->resource);
if (cid < currentMaxClients &&
(aboutClient == None || cid == aboutClient)) {
ClientPtr client = clients[cid];
if (client) {
ctx->curSpec = spec;
FindAllClientResources(client,
AddResourceSizeValueByResource,
ctx);
}
ClientPtr client = dixClientForXID(spec->resource);
if (client && (aboutClient == None || aboutClient == client->index)) {
ctx->curSpec = spec;
FindAllClientResources(client,
AddResourceSizeValueByResource,
ctx);
}
}
}
@ -915,16 +907,12 @@ ConstructResourceBytes(XID aboutClient,
ConstructResourceBytesCtx *ctx)
{
if (aboutClient) {
int clientIdx = CLIENT_ID(aboutClient);
ClientPtr client = NullClient;
if ((clientIdx >= currentMaxClients) || !clients[clientIdx]) {
ClientPtr client = dixClientForXID(aboutClient);
if (!client) {
ctx->sendClient->errorValue = aboutClient;
return BadValue;
}
client = clients[clientIdx];
ConstructClientResourceBytes(client, ctx);
ConstructResourceBytesByResource(aboutClient, ctx);
} else {

View File

@ -33,6 +33,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <X11/Xfuncproto.h>
#include "dix/registry_priv.h"
#include "dix/resource_priv.h"
#include "os/client_priv.h"
#include "selection.h"
@ -630,7 +631,10 @@ SELinuxResource(CallbackListPtr *pcbl, void *unused, void *calldata)
if (offset < 0) {
/* No: use the SID of the owning client */
class = SECCLASS_X_RESOURCE;
privatePtr = &clients[CLIENT_ID(rec->id)]->devPrivates;
ClientPtr owner = dixClientForXID(rec->id);
if (!owner)
return;
privatePtr = &owner->devPrivates;
obj = dixLookupPrivate(privatePtr, objectKey);
}
else {
@ -771,7 +775,7 @@ SELinuxResourceState(CallbackListPtr *pcbl, void *unused, void *calldata)
return;
pWin = (WindowPtr) rec->value;
subj = dixLookupPrivate(&wClient(pWin)->devPrivates, subjectKey);
subj = dixLookupPrivate(&dixClientForWindow(pWin)->devPrivates, subjectKey);
if (subj->sid) {
char *ctx;

View File

@ -57,6 +57,7 @@ SOFTWARE.
#include "dix/exevents_priv.h"
#include "dix/input_priv.h"
#include "dix/resource_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "XIstubs.h"

View File

@ -52,11 +52,14 @@ SOFTWARE.
#include <dix-config.h>
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "dix/resource_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h" /* window structure */
#include "scrnintstr.h" /* screen structure */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "XIstubs.h"
#include "exglobals.h"

View File

@ -96,6 +96,7 @@ SOFTWARE.
#include "dix/eventconvert.h"
#include "dix/exevents_priv.h"
#include "dix/input_priv.h"
#include "dix/resource_priv.h"
#include "mi/mi_priv.h"
#include "inputstr.h"
@ -1045,7 +1046,7 @@ TouchClientWantsOwnershipEvents(ClientPtr client, DeviceIntPtr dev,
InputClients *iclient;
nt_list_for_each_entry(iclient, wOtherInputMasks(win)->inputClients, next) {
if (rClient(iclient) != client)
if (dixClientForInputClients(iclient) != client)
continue;
return xi2mask_isset(iclient->xi2mask, dev, XI_TouchOwnership);
@ -1117,7 +1118,7 @@ ActivateEarlyAccept(DeviceIntPtr dev, TouchPointInfoPtr ti)
ti->listeners[0].type != TOUCH_LISTENER_POINTER_GRAB);
BUG_RETURN(!grab);
client = rClient(grab);
client = dixClientForGrab(grab);
if (TouchAcceptReject(client, dev, XIAcceptTouch, ti->client_id,
ti->listeners[0].window->drawable.id, &error) != Success)
@ -1369,7 +1370,7 @@ RetrieveTouchDeliveryData(DeviceIntPtr dev, TouchPointInfoPtr ti,
BUG_RETURN_VAL(!*grab, FALSE);
*client = rClient(*grab);
*client = dixClientForGrab(*grab);
*win = (*grab)->window;
*mask = (*grab)->xi2mask;
}
@ -1397,7 +1398,7 @@ RetrieveTouchDeliveryData(DeviceIntPtr dev, TouchPointInfoPtr ti,
BUG_RETURN_VAL(!iclients, FALSE);
*mask = iclients->xi2mask;
*client = rClient(iclients);
*client = dixClientForInputClients(iclients);
}
else if (listener->level == XI) {
int xi_type = GetXIType(TouchGetPointerEventType(ev));
@ -1409,7 +1410,7 @@ RetrieveTouchDeliveryData(DeviceIntPtr dev, TouchPointInfoPtr ti,
break;
BUG_RETURN_VAL(!iclients, FALSE);
*client = rClient(iclients);
*client = dixClientForInputClients(iclients);
}
else {
int coretype = GetCoreType(TouchGetPointerEventType(ev));
@ -1423,7 +1424,7 @@ RetrieveTouchDeliveryData(DeviceIntPtr dev, TouchPointInfoPtr ti,
break;
/* if owner selected, oclients is NULL */
*client = oclients ? rClient(oclients) : wClient(*win);
*client = oclients ? dixClientForOtherClients(oclients) : dixClientForWindow(*win);
}
*grab = NULL;
@ -1449,7 +1450,7 @@ DeliverTouchEmulatedEvent(DeviceIntPtr dev, TouchPointInfoPtr ti,
if (grab) {
win = grab->window;
xi2mask = grab->xi2mask;
client = rClient(grab);
client = dixClientForGrab(grab);
}
}
@ -1738,7 +1739,7 @@ ProcessBarrierEvent(InternalEvent *e, DeviceIntPtr dev)
Otherwise, deliver normally to the client.
*/
if (grab &&
CLIENT_ID(be->barrierid) == CLIENT_ID(grab->resource) &&
dixClientIdForXID(be->barrierid) == dixClientIdForXID(grab->resource) &&
grab->window->drawable.id == be->window) {
DeliverGrabbedEvent(e, dev, FALSE);
} else {
@ -2279,7 +2280,7 @@ RetrieveGestureDeliveryData(DeviceIntPtr dev, InternalEvent *ev, GestureListener
BUG_RETURN_VAL(!*grab, FALSE);
*client = rClient(*grab);
*client = dixClientForGrab(*grab);
*win = (*grab)->window;
}
else {
@ -2298,7 +2299,7 @@ RetrieveGestureDeliveryData(DeviceIntPtr dev, InternalEvent *ev, GestureListener
BUG_RETURN_VAL(!iclients, FALSE);
*client = rClient(iclients);
*client = dixClientForInputClients(iclients);
}
return TRUE;
@ -2528,7 +2529,7 @@ GrabButton(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr modifier_device,
else if (grabtype == XI2)
type = XI_ButtonPress;
grab = CreateGrab(client->index, dev, modifier_device, pWin, grabtype,
grab = CreateGrab(client, dev, modifier_device, pWin, grabtype,
mask, param, type, button, confineTo, cursor);
if (!grab)
return BadAlloc;
@ -2576,7 +2577,7 @@ GrabKey(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr modifier_device,
if (rc != Success)
return rc;
grab = CreateGrab(client->index, dev, modifier_device, pWin, grabtype,
grab = CreateGrab(client, dev, modifier_device, pWin, grabtype,
mask, param, type, key, NULL, NULL);
if (!grab)
return BadAlloc;
@ -2619,7 +2620,7 @@ GrabWindow(ClientPtr client, DeviceIntPtr dev, int type,
if (rc != Success)
return rc;
grab = CreateGrab(client->index, dev, dev, pWin, XI2,
grab = CreateGrab(client, dev, dev, pWin, XI2,
mask, param,
(type == XIGrabtypeEnter) ? XI_Enter : XI_FocusIn, 0,
NULL, cursor);
@ -2650,7 +2651,7 @@ GrabTouchOrGesture(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr mod_dev,
if (rc != Success)
return rc;
grab = CreateGrab(client->index, dev, mod_dev, pWin, XI2,
grab = CreateGrab(client, dev, mod_dev, pWin, XI2,
mask, param, type, 0, NullWindow, NullCursor);
if (!grab)
return BadAlloc;

View File

@ -55,7 +55,7 @@ SOFTWARE.
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "dix/dix_priv.h"
#include "dix/resource_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h" /* window struct */

View File

@ -56,6 +56,7 @@ SOFTWARE.
#include <X11/extensions/XIproto.h>
#include "dix/input_priv.h"
#include "dix/resource_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "XIstubs.h"

View File

@ -56,6 +56,7 @@ SOFTWARE.
#include <X11/extensions/XIproto.h>
#include "dix/input_priv.h"
#include "dix/resource_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "XIstubs.h"

View File

@ -52,11 +52,13 @@ SOFTWARE.
#include <dix-config.h>
#include <X11/extensions/XIproto.h>
#include "dix/resource_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h" /* window structure */
#include <X11/extensions/XIproto.h>
#include "exglobals.h"
#include "ungrdev.h"
/***********************************************************************

View File

@ -46,6 +46,7 @@
#include "dix/cursor_priv.h"
#include "dix/dix_priv.h"
#include "dix/input_priv.h"
#include "dix/resource_priv.h"
#include "mi/mi_priv.h"
#include "os/bug_priv.h"
@ -844,7 +845,7 @@ XIDestroyPointerBarrier(ClientPtr client,
return err;
}
if (CLIENT_ID(stuff->barrier) != client->index)
if (dixClientIdForXID(stuff->barrier) != client->index)
return BadAccess;
FreeResource(stuff->barrier, X11_RESTYPE_NONE);
@ -913,10 +914,9 @@ ProcXIBarrierReleasePointer(ClientPtr client)
return err;
}
if (CLIENT_ID(barrier_id) != client->index)
if (dixClientIdForXID(barrier_id) != client->index)
return BadAccess;
barrier = container_of(b, struct PointerBarrierClient, barrier);
pbd = GetBarrierDevice(barrier, dev->id);

View File

@ -36,6 +36,7 @@
#include "dix/dix_priv.h"
#include "dix/exevents_priv.h"
#include "dix/resource_priv.h"
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h" /* window structure */

View File

@ -29,6 +29,7 @@
#include "dix/dix_priv.h"
#include "dix/exevents_priv.h"
#include "dix/resource_priv.h"
#include "dixstruct.h"
#include "windowstr.h"
@ -56,7 +57,7 @@ check_for_touch_selection_conflicts(ClientPtr B, WindowPtr win, int deviceid,
for (; A; A = A->next) {
DeviceIntPtr tmp;
if (CLIENT_ID(A->resource) == B->index)
if (dixClientIdForXID(A->resource) == B->index)
continue;
if (deviceid == XIAllDevices)

View File

@ -43,6 +43,8 @@
#include <dix-config.h>
#include "dix/resource_priv.h"
#include "compint.h"
static Bool
@ -327,7 +329,7 @@ compUnredirectWindow(ClientPtr pClient, WindowPtr pWin, int update)
return BadValue;
for (ccw = cw->clients; ccw; ccw = ccw->next)
if (ccw->update == update && CLIENT_ID(ccw->id) == pClient->index) {
if (ccw->update == update && dixClientIdForXID(ccw->id) == pClient->index) {
FreeResource(ccw->id, X11_RESTYPE_NONE);
return Success;
}
@ -426,7 +428,7 @@ compFreeClientSubwindows(WindowPtr pWin, XID id)
return;
for (prev = &csw->clients; (ccw = *prev); prev = &ccw->next) {
if (ccw->id == id) {
ClientPtr pClient = clients[CLIENT_ID(id)];
ClientPtr pClient = dixClientForXID(id);
*prev = ccw->next;
if (ccw->update == CompositeRedirectManual) {
@ -475,7 +477,7 @@ compUnredirectSubwindows(ClientPtr pClient, WindowPtr pWin, int update)
if (!csw)
return BadValue;
for (ccw = csw->clients; ccw; ccw = ccw->next)
if (ccw->update == update && CLIENT_ID(ccw->id) == pClient->index) {
if (ccw->update == update && dixClientIdForXID(ccw->id) == pClient->index) {
FreeResource(ccw->id, X11_RESTYPE_NONE);
return Success;
}
@ -495,9 +497,8 @@ compRedirectOneSubwindow(WindowPtr pParent, WindowPtr pWin)
if (!csw)
return Success;
for (ccw = csw->clients; ccw; ccw = ccw->next) {
int ret = compRedirectWindow(clients[CLIENT_ID(ccw->id)],
int ret = compRedirectWindow(dixClientForXID(ccw->id),
pWin, ccw->update);
if (ret != Success)
return ret;
}
@ -517,9 +518,8 @@ compUnredirectOneSubwindow(WindowPtr pParent, WindowPtr pWin)
if (!csw)
return Success;
for (ccw = csw->clients; ccw; ccw = ccw->next) {
int ret = compUnredirectWindow(clients[CLIENT_ID(ccw->id)],
int ret = compUnredirectWindow(dixClientForXID(ccw->id),
pWin, ccw->update);
if (ret != Success)
return ret;
}

View File

@ -44,6 +44,7 @@
#include <dix-config.h>
#include "dix/dix_priv.h"
#include "dix/resource_priv.h"
#include "os/osdep.h"
#include "compint.h"
@ -216,7 +217,7 @@ updateOverlayWindow(ScreenPtr pScreen)
/* Let's resize the overlay window. */
vlist[0] = w;
vlist[1] = h;
return ConfigureWindow(pWin, CWWidth | CWHeight, vlist, wClient(pWin));
return ConfigureWindow(pWin, CWWidth | CWHeight, vlist, dixClientForWindow(pWin));
}
/* Let's be on the safe side and not assume an overlay window is
@ -585,7 +586,7 @@ compCreateWindow(WindowPtr pWin)
(*pScreen->SetWindowPixmap) (pWin, parent_pixmap);
if (csw)
for (ccw = csw->clients; ccw; ccw = ccw->next)
compRedirectWindow(clients[CLIENT_ID(ccw->id)],
compRedirectWindow(dixClientForXID(ccw->id),
pWin, ccw->update);
if (compImplicitRedirect(pWin, pWin->parent))
compRedirectWindow(serverClient, pWin, CompositeRedirectAutomatic);

View File

@ -53,7 +53,9 @@ SOFTWARE.
#include <strings.h>
#include "dix/colormap_priv.h"
#include "dix/resource_priv.h"
#include "os/osdep.h"
#include "os/bug_priv.h"
#include "misc.h"
#include "dix.h"
@ -222,8 +224,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;
@ -244,8 +244,8 @@ typedef struct _colorResource {
* \param alloc 1 iff all entries are allocated writable
*/
int
CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
ColormapPtr *ppcmap, int alloc, int client)
dixCreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
ColormapPtr *ppcmap, int alloc, ClientPtr pClient)
{
int class, size;
unsigned long sizebytes;
@ -254,9 +254,14 @@ CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
int i;
Pixel *ppix, **pptr;
if (!pClient)
return BadMatch;
const int clientIndex = pClient->index;
class = pVisual->class;
if (!(class & DynamicClass) && (alloc != AllocNone) &&
(client != SERVER_ID))
(pClient != serverClient))
return BadMatch;
size = pVisual->ColormapEntries;
@ -313,10 +318,10 @@ CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
free(pmap);
return BadAlloc;
}
pmap->clientPixelsRed[client] = ppix;
pmap->clientPixelsRed[clientIndex] = ppix;
for (i = 0; i < size; i++)
ppix[i] = i;
pmap->numPixelsRed[client] = size;
pmap->numPixelsRed[clientIndex] = size;
}
if ((class | DynamicClass) == DirectColor) {
@ -351,14 +356,14 @@ CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
pmap->freeGreen = 0;
ppix = xallocarray(size, sizeof(Pixel));
if (!ppix) {
free(pmap->clientPixelsRed[client]);
free(pmap->clientPixelsRed[clientIndex]);
free(pmap);
return BadAlloc;
}
pmap->clientPixelsGreen[client] = ppix;
pmap->clientPixelsGreen[clientIndex] = ppix;
for (i = 0; i < size; i++)
ppix[i] = i;
pmap->numPixelsGreen[client] = size;
pmap->numPixelsGreen[clientIndex] = size;
size = pmap->freeBlue;
for (pent = &pmap->blue[size - 1]; pent >= pmap->blue; pent--)
@ -366,15 +371,15 @@ CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
pmap->freeBlue = 0;
ppix = xallocarray(size, sizeof(Pixel));
if (!ppix) {
free(pmap->clientPixelsGreen[client]);
free(pmap->clientPixelsRed[client]);
free(pmap->clientPixelsGreen[clientIndex]);
free(pmap->clientPixelsRed[clientIndex]);
free(pmap);
return BadAlloc;
}
pmap->clientPixelsBlue[client] = ppix;
pmap->clientPixelsBlue[clientIndex] = ppix;
for (i = 0; i < size; i++)
ppix[i] = i;
pmap->numPixelsBlue[client] = size;
pmap->numPixelsBlue[clientIndex] = size;
}
}
pmap->flags |= CM_BeingCreated;
@ -385,7 +390,7 @@ CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
/*
* Security creation/labeling check
*/
i = XaceHookResourceAccess(clients[client], mid, X11_RESTYPE_COLORMAP,
i = XaceHookResourceAccess(pClient, mid, X11_RESTYPE_COLORMAP,
pmap, X11_RESTYPE_NONE, NULL, DixCreateAccess);
if (i != Success) {
FreeResource(mid, X11_RESTYPE_NONE);
@ -415,7 +420,7 @@ FreeColormap(void *value, XID mid)
EntryPtr pent;
ColormapPtr pmap = (ColormapPtr) value;
if (CLIENT_ID(mid) != SERVER_ID) {
if (!dixResouceIsServerOwned(mid)) {
(*pmap->pScreen->UninstallColormap) (pmap);
WalkTree(pmap->pScreen, (VisitWindowProcPtr) TellNoMap, (void *) &mid);
}
@ -546,12 +551,12 @@ CopyColormapAndFree(Colormap mid, ColormapPtr pSrc, int client)
pScreen = pSrc->pScreen;
pVisual = pSrc->pVisual;
midSrc = pSrc->mid;
alloc = ((pSrc->flags & CM_AllAllocated) && CLIENT_ID(midSrc) == client) ?
alloc = ((pSrc->flags & CM_AllAllocated) && dixClientIdForXID(midSrc) == client) ?
AllocAll : AllocNone;
size = pVisual->ColormapEntries;
/* If the create returns non-0, it failed */
result = CreateColormap(mid, pScreen, pVisual, &pmap, alloc, client);
result = dixCreateColormap(mid, pScreen, pVisual, &pmap, alloc, clients[client]);
if (result != Success)
return result;
if (alloc == AllocAll) {
@ -1086,7 +1091,7 @@ AllocColor(ColormapPtr pmap,
* resource manager that the client has pixels in this colormap which
* should be freed when the client dies */
if ((pmap->numPixelsRed[client] == 1) &&
(CLIENT_ID(pmap->mid) != client) && !(pmap->flags & CM_BeingCreated)) {
(dixClientIdForXID(pmap->mid) != client) && !(pmap->flags & CM_BeingCreated)) {
colorResource *pcr;
pcr = malloc(sizeof(colorResource));
@ -1506,7 +1511,7 @@ AllocColorCells(int client, ColormapPtr pmap, int colors, int planes,
oldcount = pmap->numPixelsRed[client];
if (pmap->class == DirectColor)
oldcount += pmap->numPixelsGreen[client] + pmap->numPixelsBlue[client];
if (!oldcount && (CLIENT_ID(pmap->mid) != client)) {
if (!oldcount && (dixClientIdForXID(pmap->mid) != client)) {
pcr = malloc(sizeof(colorResource));
if (!pcr)
return BadAlloc;
@ -1573,7 +1578,7 @@ AllocColorPlanes(int client, ColormapPtr pmap, int colors,
oldcount = pmap->numPixelsRed[client];
if (class == DirectColor)
oldcount += pmap->numPixelsGreen[client] + pmap->numPixelsBlue[client];
if (!oldcount && (CLIENT_ID(pmap->mid) != client)) {
if (!oldcount && (dixClientIdForXID(pmap->mid) != client)) {
pcr = malloc(sizeof(colorResource));
if (!pcr)
return BadAlloc;

View File

@ -21,8 +21,8 @@
typedef struct _CMEntry *EntryPtr;
int CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
ColormapPtr *ppcmap, int alloc, int client);
int dixCreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
ColormapPtr *ppcmap, int alloc, ClientPtr client);
/* should only be called via resource type's destructor */
int FreeColormap(void *pmap, XID mid);

View File

@ -60,6 +60,7 @@ SOFTWARE.
#include "dix/exevents_priv.h"
#include "dix/input_priv.h"
#include "dix/ptrveloc_priv.h"
#include "dix/resource_priv.h"
#include "mi/mi_priv.h"
#include "os/bug_priv.h"
#include "os/osdep.h"

View File

@ -109,6 +109,7 @@ Equipment Corporation.
#include "dix/input_priv.h"
#include "dix/gc_priv.h"
#include "dix/registry_priv.h"
#include "dix/resource_priv.h"
#include "dix/screenint_priv.h"
#include "include/resource.h"
#include "os/auth.h"
@ -2461,8 +2462,8 @@ ProcCreateColormap(ClientPtr client)
i < pScreen->numVisuals; i++, pVisual++) {
if (pVisual->vid != stuff->visual)
continue;
return CreateColormap(mid, pScreen, pVisual, &pmap,
(int) stuff->alloc, client->index);
return dixCreateColormap(mid, pScreen, pVisual, &pmap,
(int) stuff->alloc, client);
}
client->errorValue = stuff->visual;
return BadMatch;

View File

@ -23,6 +23,7 @@
#include "include/events.h"
#include "include/gc.h"
#include "include/input.h"
#include "include/resource.h"
#include "include/window.h"
/* server setting: maximum size for big requests */

View File

@ -64,7 +64,7 @@ void FreeGrab(GrabPtr grab);
* Create a new grab for given client, with given parameters.
* Returns NULL on OOM.
*
* @param client _Index_ of the client who will hold the grab
* @param pClient ClientPtr to the client who will hold the grab
* @param device Device that's being grabbed
* @param modDevice Device whose modifiers are used (NULL = use core keyboard)
* @param window the window getting the events
@ -77,7 +77,7 @@ void FreeGrab(GrabPtr grab);
* @param cursor cursor to be used while grabbed (may be NULL)
* @return newly created grab. Must be freed by ::FreeGrab()
*/
GrabPtr CreateGrab(int client,
GrabPtr CreateGrab(ClientPtr pClient,
DeviceIntPtr device,
DeviceIntPtr modDevice,
WindowPtr window,

View File

@ -87,6 +87,7 @@ Author: Adobe Systems Incorporated
#include "dix/callback_priv.h"
#include "dix/dix_priv.h"
#include "dix/resource_priv.h"
#include "misc.h"
#include "windowstr.h"
@ -221,7 +222,7 @@ int
dixLookupClient(ClientPtr *pClient, XID rid, ClientPtr client, Mask access)
{
void *pRes;
int rc = BadValue, clientIndex = CLIENT_ID(rid);
int rc = BadValue, clientIndex = dixClientIdForXID(rid);
if (!clientIndex || !clients[clientIndex] || (rid & SERVER_BIT))
goto bad;

View File

@ -124,6 +124,7 @@ Equipment Corporation.
#include "dix/input_priv.h"
#include "dix/eventconvert.h"
#include "dix/exevents_priv.h"
#include "dix/resource_priv.h"
#include "os/bug_priv.h"
#include "os/client_priv.h"
#include "os/fmt.h"
@ -1424,8 +1425,8 @@ CheckGrabForSyncs(DeviceIntPtr thisDev, Bool thisMode, Bool otherMode)
else { /* free both if same client owns both */
thisDev->deviceGrab.sync.state = GRAB_STATE_THAWED;
if (thisDev->deviceGrab.sync.other &&
(CLIENT_BITS(thisDev->deviceGrab.sync.other->resource) ==
CLIENT_BITS(grab->resource)))
(dixClientIdForXID(thisDev->deviceGrab.sync.other->resource) ==
dixClientIdForXID(grab->resource)))
thisDev->deviceGrab.sync.other = NullGrab;
}
@ -1435,8 +1436,8 @@ CheckGrabForSyncs(DeviceIntPtr thisDev, Bool thisMode, Bool otherMode)
dev->deviceGrab.sync.other = grab;
else { /* free both if same client owns both */
if (dev->deviceGrab.sync.other &&
(CLIENT_BITS(dev->deviceGrab.sync.other->resource) ==
CLIENT_BITS(grab->resource)))
(dixClientIdForXID(dev->deviceGrab.sync.other->resource) ==
dixClientIdForXID(grab->resource)))
dev->deviceGrab.sync.other = NullGrab;
}
}
@ -2198,11 +2199,11 @@ DeliverToWindowOwner(DeviceIntPtr dev, WindowPtr win,
!((wOtherEventMasks(win) | win->eventMask) & filter))
return EVENT_SKIP;
if (IsInterferingGrab(wClient(win), dev, events))
if (IsInterferingGrab(dixClientForWindow(win), dev, events))
return EVENT_SKIP;
if (!XaceHookReceiveAccess(wClient(win), win, events, count)) {
int attempt = TryClientEvents(wClient(win), dev, events,
if (!XaceHookReceiveAccess(dixClientForWindow(win), win, events, count)) {
int attempt = TryClientEvents(dixClientForWindow(win), dev, events,
count, win->eventMask,
filter, grab);
@ -2269,7 +2270,7 @@ DeliverEventToInputClients(DeviceIntPtr dev, InputClients * inputclients,
for (; inputclients; inputclients = inputclients->next) {
Mask mask;
ClientPtr client = rClient(inputclients);
ClientPtr client = dixClientForInputClients(inputclients);
if (IsInterferingGrab(client, dev, events))
continue;
@ -2376,7 +2377,7 @@ DeliverEventsToWindow(DeviceIntPtr pDev, WindowPtr pWin, xEvent
case EVENT_DELIVERED:
/* We delivered to the owner, with our event mask */
deliveries++;
client = wClient(pWin);
client = dixClientForWindow(pWin);
deliveryMask = pWin->eventMask;
break;
case EVENT_NOT_DELIVERED:
@ -2505,7 +2506,7 @@ DeliverRawEvent(RawDeviceEvent *ev, DeviceIntPtr device)
*/
ic.next = NULL;
if (!FilterRawEvents(rClient(&ic), grab, root))
if (!FilterRawEvents(dixClientForInputClients(&ic), grab, root))
DeliverEventToInputClients(device, &ic, root, xi, 1,
filter, NULL, &c, &m);
}
@ -2551,16 +2552,16 @@ MaybeDeliverEventsToClient(WindowPtr pWin, xEvent *pEvents,
OtherClients *other;
if (pWin->eventMask & filter) {
if (wClient(pWin) == dontClient)
if (dixClientForWindow(pWin) == dontClient)
return 0;
#ifdef XINERAMA
if (!noPanoramiXExtension && pWin->drawable.pScreen->myNum)
return XineramaTryClientEventsResult(wClient(pWin), NullGrab,
return XineramaTryClientEventsResult(dixClientForWindow(pWin), NullGrab,
pWin->eventMask, filter);
#endif /* XINERAMA */
if (XaceHookReceiveAccess(wClient(pWin), pWin, pEvents, count))
if (XaceHookReceiveAccess(dixClientForWindow(pWin), pWin, pEvents, count))
return 1; /* don't send, but pretend we did */
return TryClientEvents(wClient(pWin), NULL, pEvents, count,
return TryClientEvents(dixClientForWindow(pWin), NULL, pEvents, count,
pWin->eventMask, filter, NullGrab);
}
for (other = wOtherClients(pWin); other; other = other->next) {
@ -2569,13 +2570,13 @@ MaybeDeliverEventsToClient(WindowPtr pWin, xEvent *pEvents,
return 0;
#ifdef XINERAMA
if (!noPanoramiXExtension && pWin->drawable.pScreen->myNum)
return XineramaTryClientEventsResult(rClient(other), NullGrab,
return XineramaTryClientEventsResult(dixClientForOtherClients(other), NullGrab,
other->mask, filter);
#endif /* XINERAMA */
if (XaceHookReceiveAccess(rClient(other), pWin, pEvents,
if (XaceHookReceiveAccess(dixClientForOtherClients(other), pWin, pEvents,
count))
return 1; /* don't send, but pretend we did */
return TryClientEvents(rClient(other), NULL, pEvents, count,
return TryClientEvents(dixClientForOtherClients(other), NULL, pEvents, count,
other->mask, filter, NullGrab);
}
}
@ -3826,7 +3827,7 @@ ActivatePassiveGrab(DeviceIntPtr device, GrabPtr grab, InternalEvent *event,
FixUpEventFromWindow(pSprite, xE, grab->window, None, TRUE);
/* XXX: XACE? */
TryClientEvents(rClient(grab), device, xE, count,
TryClientEvents(dixClientForGrab(grab), device, xE, count,
GetEventFilter(device, xE),
GetEventFilter(device, xE), grab);
}
@ -3866,7 +3867,7 @@ CoreGrabInterferes(DeviceIntPtr device, GrabPtr grab)
GrabPtr othergrab = other->deviceGrab.grab;
if (othergrab && othergrab->grabtype == CORE &&
SameClient(grab, rClient(othergrab)) &&
SameClient(grab, dixClientForGrab(othergrab)) &&
((IsPointerDevice(grab->device) &&
IsPointerDevice(othergrab->device)) ||
(IsKeyboardDevice(grab->device) &&
@ -4325,10 +4326,10 @@ DeliverOneGrabbedEvent(InternalEvent *event, DeviceIntPtr dev,
if (rc == Success) {
FixUpEventFromWindow(pSprite, xE, grab->window, None, TRUE);
if (XaceHookSendAccess(0, dev, grab->window, xE, count) ||
XaceHookReceiveAccess(rClient(grab), grab->window, xE, count))
XaceHookReceiveAccess(dixClientForGrab(grab), grab->window, xE, count))
deliveries = 1; /* don't send, but pretend we did */
else if (level != CORE || !IsInterferingGrab(rClient(grab), dev, xE)) {
deliveries = TryClientEvents(rClient(grab), dev,
else if (level != CORE || !IsInterferingGrab(dixClientForGrab(grab), dev, xE)) {
deliveries = TryClientEvents(dixClientForGrab(grab), dev,
xE, count, mask, filter, grab);
}
}
@ -4423,8 +4424,8 @@ FreezeThisEventIfNeededForSyncGrab(DeviceIntPtr thisDev, InternalEvent *event)
if (dev) {
FreezeThaw(dev, TRUE);
if ((dev->deviceGrab.sync.state == GRAB_STATE_FREEZE_BOTH_NEXT_EVENT) &&
(CLIENT_BITS(grab->resource) ==
CLIENT_BITS(dev->deviceGrab.grab->resource)))
(dixClientIdForXID(grab->resource) ==
dixClientIdForXID(dev->deviceGrab.grab->resource)))
dev->deviceGrab.sync.state = GRAB_STATE_FROZEN_NO_EVENT;
else
dev->deviceGrab.sync.other = grab;
@ -4561,14 +4562,14 @@ EventSelectForWindow(WindowPtr pWin, ClientPtr client, Mask mask)
/* It is illegal for two different clients to select on any of the
events for AtMostOneClient. However, it is OK, for some client to
continue selecting on one of those events. */
if ((wClient(pWin) != client) && (check & pWin->eventMask))
if ((dixClientForWindow(pWin) != client) && (check & pWin->eventMask))
return BadAccess;
for (others = wOtherClients(pWin); others; others = others->next) {
if (!SameClient(others, client) && (check & others->mask))
return BadAccess;
}
}
if (wClient(pWin) == client) {
if (dixClientForWindow(pWin) == client) {
check = pWin->eventMask;
pWin->eventMask = mask;
}
@ -4683,7 +4684,7 @@ CoreEnterLeaveEvent(DeviceIntPtr mouse,
if (grab) {
mask = (pWin == grab->window) ? grab->eventMask : 0;
if (grab->ownerEvents)
mask |= EventMaskForClient(pWin, rClient(grab));
mask |= EventMaskForClient(pWin, dixClientForGrab(grab));
}
else {
mask = pWin->eventMask | wOtherEventMasks(pWin);
@ -4711,7 +4712,7 @@ CoreEnterLeaveEvent(DeviceIntPtr mouse,
if ((mask & GetEventFilter(mouse, &event))) {
if (grab)
TryClientEvents(rClient(grab), mouse, &event, 1, mask,
TryClientEvents(dixClientForGrab(grab), mouse, &event, 1, mask,
GetEventFilter(mouse, &event), grab);
else
DeliverEventsToWindow(mouse, pWin, &event, 1,
@ -4722,7 +4723,7 @@ CoreEnterLeaveEvent(DeviceIntPtr mouse,
xKeymapEvent ke = {
.type = KeymapNotify
};
ClientPtr client = grab ? rClient(grab) : wClient(pWin);
ClientPtr client = grab ? dixClientForGrab(grab) : dixClientForWindow(pWin);
int rc;
rc = XaceHookDeviceAccess(client, keybd, DixReadAccess);
@ -4730,7 +4731,7 @@ CoreEnterLeaveEvent(DeviceIntPtr mouse,
memcpy((char *) &ke.map[0], (char *) &keybd->key->down[1], 31);
if (grab)
TryClientEvents(rClient(grab), keybd, (xEvent *) &ke, 1,
TryClientEvents(dixClientForGrab(grab), keybd, (xEvent *) &ke, 1,
mask, KeymapStateMask, grab);
else
DeliverEventsToWindow(mouse, pWin, (xEvent *) &ke, 1,
@ -4802,7 +4803,7 @@ DeviceEnterLeaveEvent(DeviceIntPtr mouse,
Mask mask;
mask = xi2mask_isset(grab->xi2mask, mouse, type);
TryClientEvents(rClient(grab), mouse, (xEvent *) event, 1, mask, 1,
TryClientEvents(dixClientForGrab(grab), mouse, (xEvent *) event, 1, mask, 1,
grab);
}
else {
@ -4833,7 +4834,7 @@ CoreFocusEvent(DeviceIntPtr dev, int type, int mode, int detail, WindowPtr pWin)
xKeymapEvent ke = {
.type = KeymapNotify
};
ClientPtr client = wClient(pWin);
ClientPtr client = dixClientForWindow(pWin);
int rc;
rc = XaceHookDeviceAccess(client, dev, DixReadAccess);
@ -5669,7 +5670,7 @@ ProcGrabKey(ClientPtr client)
mask.core = (KeyPressMask | KeyReleaseMask);
grab = CreateGrab(client->index, keybd, keybd, pWin, CORE, &mask,
grab = CreateGrab(client, keybd, keybd, pWin, CORE, &mask,
&param, KeyPress, stuff->key, NullWindow, NullCursor);
if (!grab)
return BadAlloc;
@ -5763,7 +5764,7 @@ ProcGrabButton(ClientPtr client)
mask.core = stuff->eventMask;
grab = CreateGrab(client->index, ptr, modifierDevice, pWin,
grab = CreateGrab(client, ptr, modifierDevice, pWin,
CORE, &mask, &param, ButtonPress,
stuff->button, confineTo, cursor);
if (!grab)
@ -5894,7 +5895,7 @@ DeleteWindowFromAnyEvents(WindowPtr pWin, Bool freeResources)
of ending up reverting to a dying window and thence
to None */
#ifdef NOTDEF
|| wClient(parent)->clientGone
|| dixClientForWindow(parent)->clientGone
#endif
);
if (!ActivateFocusInGrab(keybd, pWin, parent))
@ -5966,7 +5967,7 @@ EventMaskForClient(WindowPtr pWin, ClientPtr client)
{
OtherClientsPtr other;
if (wClient(pWin) == client)
if (dixClientForWindow(pWin) == client)
return pWin->eventMask;
for (other = wOtherClients(pWin); other; other = other->next) {
if (SameClient(other, client))
@ -6284,5 +6285,5 @@ IsWrongPointerBarrierClient(ClientPtr client, DeviceIntPtr dev, xEvent *event)
if (ev->evtype != XI_BarrierHit && ev->evtype != XI_BarrierLeave)
return FALSE;
return client->index != CLIENT_ID(ev->barrier);
return client->index != dixClientIdForXID(ev->barrier);
}

View File

@ -29,6 +29,7 @@
#include "dix/dixgrabs_priv.h"
#include "dix/eventconvert.h"
#include "dix/input_priv.h"
#include "dix/resource_priv.h"
#include "mi/mi_priv.h"
#include "os/bug_priv.h"

View File

@ -55,6 +55,7 @@ SOFTWARE.
#include "dix/dix_priv.h"
#include "dix/dixgrabs_priv.h"
#include "dix/exevents_priv.h"
#include "dix/resource_priv.h"
#include "os/auth.h"
#include "os/client_priv.h"
@ -76,7 +77,6 @@ SOFTWARE.
void
PrintDeviceGrabInfo(DeviceIntPtr dev)
{
ClientPtr client;
LocalClientCredRec *lcc;
int i, j;
GrabInfoPtr devGrab = &dev->deviceGrab;
@ -88,7 +88,7 @@ PrintDeviceGrabInfo(DeviceIntPtr dev)
(grab->grabtype == XI2) ? "xi2" :
((grab->grabtype == CORE) ? "core" : "xi1"), dev->name, dev->id);
client = clients[CLIENT_ID(grab->resource)];
ClientPtr client = dixClientForXID(grab->resource);
if (client) {
pid_t clientpid = GetClientPid(client);
const char *cmdname = GetClientCmdName(client);
@ -110,7 +110,7 @@ PrintDeviceGrabInfo(DeviceIntPtr dev)
}
if (!clientIdPrinted) {
ErrorF(" (no client information available for client %d)\n",
CLIENT_ID(grab->resource));
dixClientIdForXID(grab->resource));
}
/* XXX is this even correct? */
@ -172,7 +172,6 @@ void
UngrabAllDevices(Bool kill_client)
{
DeviceIntPtr dev;
ClientPtr client;
ErrorF("Ungrabbing all devices%s; grabs listed below:\n",
kill_client ? " and killing their owners" : "");
@ -181,7 +180,7 @@ UngrabAllDevices(Bool kill_client)
if (!dev->deviceGrab.grab)
continue;
PrintDeviceGrabInfo(dev);
client = clients[CLIENT_ID(dev->deviceGrab.grab->resource)];
ClientPtr client = dixClientForXID(dev->deviceGrab.grab->resource);
if (!kill_client || !client || client->clientGone)
dev->deviceGrab.DeactivateGrab(dev);
if (kill_client)
@ -215,7 +214,7 @@ AllocGrab(const GrabPtr src)
}
GrabPtr
CreateGrab(int client, DeviceIntPtr device, DeviceIntPtr modDevice,
CreateGrab(ClientPtr client, DeviceIntPtr device, DeviceIntPtr modDevice,
WindowPtr window, enum InputLevel grabtype, GrabMask *mask,
GrabParameters *param, int eventType,
KeyCode keybut, /* key or button */
@ -226,7 +225,7 @@ CreateGrab(int client, DeviceIntPtr device, DeviceIntPtr modDevice,
grab = AllocGrab(NULL);
if (!grab)
return (GrabPtr) NULL;
grab->resource = FakeClientID(client);
grab->resource = FakeClientID(client->index);
grab->device = device;
grab->window = window;
if (grabtype == CORE || grabtype == XI)
@ -539,7 +538,7 @@ AddPassiveGrabToList(ClientPtr client, GrabPtr pGrab)
for (grab = wPassiveGrabs(pGrab->window); grab; grab = grab->next) {
if (GrabMatchesSecond(pGrab, grab, (pGrab->grabtype == CORE))) {
if (CLIENT_BITS(pGrab->resource) != CLIENT_BITS(grab->resource)) {
if (dixClientIdForXID(pGrab->resource) != dixClientIdForXID(grab->resource)) {
FreeGrab(pGrab);
return BadAccess;
}
@ -619,7 +618,7 @@ DeletePassiveGrabFromList(GrabPtr pMinuendGrab)
ok = TRUE;
for (grab = wPassiveGrabs(pMinuendGrab->window);
grab && ok; grab = grab->next) {
if ((CLIENT_BITS(grab->resource) != CLIENT_BITS(pMinuendGrab->resource))
if ((dixClientIdForXID(grab->resource) != dixClientIdForXID(pMinuendGrab->resource))
|| !GrabMatchesSecond(grab, pMinuendGrab, (grab->grabtype == CORE)))
continue;
if (GrabSupersedesSecond(pMinuendGrab, grab)) {
@ -647,7 +646,7 @@ DeletePassiveGrabFromList(GrabPtr pMinuendGrab)
param.other_devices_mode = grab->pointerMode;
param.modifiers = any_modifier;
pNewGrab = CreateGrab(CLIENT_ID(grab->resource), grab->device,
pNewGrab = CreateGrab(dixClientForXID(grab->resource), grab->device,
grab->modifierDevice, grab->window,
grab->grabtype,
(GrabMask *) &grab->eventMask,

41
dix/lookup.c Normal file
View File

@ -0,0 +1,41 @@
/* SPDX-License-Identifier: MIT OR X11
*
* Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net>
*
* @brief DIX lookup functions
*/
#include <dix-config.h>
#include "dix/dix_priv.h"
#include "dix/resource_priv.h"
#include "include/input.h"
#include "include/inputstr.h"
#include "include/windowstr.h"
ClientPtr dixClientForWindow(WindowPtr pWin) {
if (!pWin)
return NullClient;
return dixClientForXID(pWin->drawable.id);
}
ClientPtr dixClientForGrab(GrabPtr pGrab) {
if (!pGrab)
return NullClient;
return dixClientForXID(pGrab->resource);
}
ClientPtr dixClientForInputClients(InputClientsPtr pInputClients) {
if (!pInputClients)
return NullClient;
return dixClientForXID(pInputClients->resource);
}
ClientPtr dixClientForOtherClients(OtherClientsPtr pOtherClients) {
if (!pOtherClients)
return NullClient;
return dixClientForXID(pOtherClients->resource);
}

View File

@ -20,6 +20,7 @@ srcs_dix = [
'glyphcurs.c',
'grabs.c',
'inpututils.c',
'lookup.c',
'pixmap.c',
'privates.c',
'property.c',

View File

@ -112,7 +112,7 @@ Equipment Corporation.
* like it belongs to a client. This ID, however, must not be one
* the client actually can create, or we have the potential for conflict.
* The 31st bit of the ID is reserved for the server's use for this
* purpose. By setting CLIENT_ID(id) to the client, the SERVER_BIT to
* purpose. By setting dixClientIdForXID(id) to the client, the SERVER_BIT to
* 1, and an otherwise arbitrary ID in the low 22 bits, we can create a
* resource "owned" by the client.
*/
@ -125,6 +125,7 @@ Equipment Corporation.
#include "dix/dixgrabs_priv.h"
#include "dix/gc_priv.h"
#include "dix/registry_priv.h"
#include "dix/resource_priv.h"
#include "os/osdep.h"
#include "misc.h"
@ -813,7 +814,7 @@ AddResource(XID id, RESTYPE type, void *value)
#ifdef XSERVER_DTRACE
XSERVER_RESOURCE_ALLOC(id, type, value, TypeNameString(type));
#endif
client = CLIENT_ID(id);
client = dixClientIdForXID(id);
rrec = &clientTable[client];
if (!rrec->buckets) {
ErrorF("[dix] AddResource(%lx, %x, %lx), client=%d \n",
@ -901,7 +902,7 @@ FreeResource(XID id, RESTYPE skipDeleteFuncType)
int *eltptr;
int elements;
if (((cid = CLIENT_ID(id)) < LimitClients) && clientTable[cid].buckets) {
if (((cid = dixClientIdForXID(id)) < LimitClients) && clientTable[cid].buckets) {
head = &clientTable[cid].resources[HashResourceID(id, clientTable[cid].hashsize)];
eltptr = &clientTable[cid].elements;
@ -935,7 +936,7 @@ FreeResourceByType(XID id, RESTYPE type, Bool skipFree)
ResourcePtr res;
ResourcePtr *prev, *head;
if (((cid = CLIENT_ID(id)) < LimitClients) && clientTable[cid].buckets) {
if (((cid = dixClientIdForXID(id)) < LimitClients) && clientTable[cid].buckets) {
head = &clientTable[cid].resources[HashResourceID(id, clientTable[cid].hashsize)];
prev = head;
@ -970,7 +971,7 @@ ChangeResourceValue(XID id, RESTYPE rtype, void *value)
int cid;
ResourcePtr res;
if (((cid = CLIENT_ID(id)) < LimitClients) && clientTable[cid].buckets) {
if (((cid = dixClientIdForXID(id)) < LimitClients) && clientTable[cid].buckets) {
res = clientTable[cid].resources[HashResourceID(id, clientTable[cid].hashsize)];
for (; res; res = res->next)
@ -1201,7 +1202,7 @@ int
dixLookupResourceByType(void **result, XID id, RESTYPE rtype,
ClientPtr client, Mask mode)
{
int cid = CLIENT_ID(id);
int cid = dixClientIdForXID(id);
ResourcePtr res = NULL;
*result = NULL;
@ -1238,7 +1239,7 @@ int
dixLookupResourceByClass(void **result, XID id, RESTYPE rclass,
ClientPtr client, Mask mode)
{
int cid = CLIENT_ID(id);
int cid = dixClientIdForXID(id);
ResourcePtr res = NULL;
*result = NULL;

155
dix/resource_priv.h Normal file
View File

@ -0,0 +1,155 @@
/* SPDX-License-Identifier: MIT OR X11
*
* Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net>
*/
#ifndef _XSERVER_DIX_RESOURCE_PRIV_H
#define _XSERVER_DIX_RESOURCE_PRIV_H
#include <X11/Xdefs.h>
#include "include/dix.h"
#include "include/resource.h"
#define SameClient(obj,client) \
(CLIENT_BITS((obj)->resource) == (client)->clientAsMask)
#define SERVER_BIT (Mask)0x40000000 /* use illegal bit */
/* client field */
#define RESOURCE_CLIENT_MASK (((1 << ResourceClientBits()) - 1) << CLIENTOFFSET)
/* bits and fields within a resource id */
#define RESOURCE_AND_CLIENT_COUNT 29 /* 29 bits for XIDs */
#define CLIENTOFFSET (RESOURCE_AND_CLIENT_COUNT - ResourceClientBits())
/* extract the client mask from an XID */
#define CLIENT_BITS(id) ((id) & RESOURCE_CLIENT_MASK)
/* resource field */
#define RESOURCE_ID_MASK ((1 << CLIENTOFFSET) - 1)
/*
* @brief retrieve client that owns given window
*
* XIDs carry the ID of the client who created/owns the resource in upper bits.
* (every client so is assigned a range of XIDs it may use for resource creation)
*
* @param WindowPtr to the window whose client shall be retrieved
* @return pointer to ClientRec structure or NullClient (NULL)
*/
ClientPtr dixClientForWindow(WindowPtr pWin);
/*
* @brief retrieve client that owns given grab
*
* XIDs carry the ID of the client who created/owns the resource in upper bits.
* (every client so is assigned a range of XIDs it may use for resource creation)
*
* @param GrabPtr to the grab whose owning client shall be retrieved
* @return pointer to ClientRec structure or NullClient (NULL)
*/
ClientPtr dixClientForGrab(GrabPtr pGrab);
/*
* @brief retrieve client that owns InputClients
*
* XIDs carry the ID of the client who created/owns the resource in upper bits.
* (every client so is assigned a range of XIDs it may use for resource creation)
*
* @param GrabPtr to the InputClients whose owning client shall be retrieved
* @return pointer to ClientRec structure or NullClient (NULL)
*/
ClientPtr dixClientForInputClients(InputClientsPtr pInputClients);
/*
* @brief retrieve client that owns OtherClients
*
* XIDs carry the ID of the client who created/owns the resource in upper bits.
* (every client so is assigned a range of XIDs it may use for resource creation)
*
* @param GrabPtr to the OtherClients whose owning client shall be retrieved
* @return pointer to ClientRec structure or NullClient (NULL)
*/
ClientPtr dixClientForOtherClients(OtherClientsPtr pOtherClients);
/*
* @brief extract client ID from XID
*
* XIDs carry the ID of the client who created/owns the resource in upper bits.
* (every client so is assigned a range of XIDs it may use for resource creation)
*
* This ID is frequently used as table index, eg. for client or resource lookup.
*
* @param XID the ID of the resource whose client is retrieved
* @return index of the client (within client or resource table)
*/
static inline int dixClientIdForXID(XID xid) {
return ((int)(CLIENT_BITS(xid) >> CLIENTOFFSET));
}
/*
* @brief retrieve client pointer from XID
*
* XIDs carry the ID of the client who created/owns the resource in upper bits.
* (every client so is assigned a range of XIDs it may use for resource creation)
*
* @param XID the ID of the resource whose client is retrieved
* @return pointer to ClientRec structure or NullClient (NULL)
*/
static inline ClientPtr dixClientForXID(XID xid) {
const int idx = dixClientIdForXID(xid);
if (idx < MAXCLIENTS)
return clients[idx];
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);
}
/*
* @brief hash a XID for using as hashtable index
*
* @param id the XID to hash
* @param numBits number of bits in the resulting hash (>=0)
* @result the computed hash value
*
* @note This function is really only for handling
* INITHASHSIZE..MAXHASHSIZE bit hashes, but will handle any number
* of bits by either masking numBits lower bits of the ID or by
* providing at most MAXHASHSIZE hashes.
*/
int HashResourceID(XID id, unsigned int numBits);
/*
* @brief scan for free XIDs for client
*
* @param pClient the client to scan
* @param count maximum size of items to return
* @param pids pointer to XID where to return found free XIDs
* @result number of free XIDs
*/
unsigned int GetXIDList(ClientPtr pClient,
unsigned int count,
XID *pids);
/*
* @brief retrieve a range of free XIDs for given client
*
* @param client the client to scan
* @param server TRUE if scanning for free server XIDs
* @param minp pointer to result buffer: minimum XID of found range
* @param maxp pointer to result buffer: maximum XID of found range
*/
void GetXIDRange(int client,
Bool server,
XID *minp,
XID *maxp);
#endif /* _XSERVER_DIX_RESOURCE_PRIV_H */

View File

@ -31,6 +31,7 @@
#include "dix/eventconvert.h"
#include "dix/exevents_priv.h"
#include "dix/input_priv.h"
#include "dix/resource_priv.h"
#include "mi/mi_priv.h"
#include "os/bug_priv.h"
@ -994,7 +995,7 @@ TouchAcceptReject(ClientPtr client, DeviceIntPtr dev, int mode,
}
for (i = 0; i < ti->num_listeners; i++) {
if (CLIENT_ID(ti->listeners[i].listener) == client->index &&
if (dixClientIdForXID(ti->listeners[i].listener) == client->index &&
ti->listeners[i].window->drawable.id == grab_window)
break;
}

View File

@ -104,6 +104,7 @@ Equipment Corporation.
#include "dix/exevents_priv.h"
#include "dix/input_priv.h"
#include "dix/property_priv.h"
#include "dix/resource_priv.h"
#include "mi/mi_priv.h" /* miPaintWindow */
#include "os/auth.h"
#include "os/client_priv.h"
@ -934,7 +935,7 @@ CreateWindow(Window wid, WindowPtr pParent, int x, int y, unsigned w,
RecalculateDeliverableEvents(pWin);
if (vmask)
*error = ChangeWindowAttributes(pWin, vmask, vlist, wClient(pWin));
*error = ChangeWindowAttributes(pWin, vmask, vlist, dixClientForWindow(pWin));
else
*error = Success;
@ -2959,7 +2960,7 @@ HandleSaveSet(ClientPtr client)
else
{
pParent = pWin->parent;
while (pParent && (wClient(pParent) == client))
while (pParent && (dixClientForWindow(pParent) == client))
pParent = pParent->parent;
}
if (pParent) {

View File

@ -36,6 +36,7 @@
#include <X11/extensions/presenttokens.h>
#include "dix/dix_priv.h"
#include "dix/resource_priv.h"
#include "glxserver.h"
#include <unpack.h>
@ -2501,7 +2502,9 @@ void
__glXsendSwapEvent(__GLXdrawable *drawable, int type, CARD64 ust,
CARD64 msc, CARD32 sbc)
{
ClientPtr client = clients[CLIENT_ID(drawable->drawId)];
ClientPtr client = dixClientForXID(drawable->drawId);
if (!client)
return;
xGLXBufferSwapComplete2 wire = {
.type = __glXEventBase + GLX_BufferSwapComplete

View File

@ -50,6 +50,7 @@
#include <sys/types.h>
#include <grp.h>
#include "dix/resource_priv.h"
#include "os/osdep.h"
#include "xf86.h"

View File

@ -710,7 +710,7 @@ DGACreateColormap(int index, ClientPtr client, int id, int mode, int alloc)
LEGAL_NEW_RESOURCE(id, client);
return CreateColormap(id, pScreen, pVisual, &pmap, alloc, client->index);
return dixCreateColormap(id, pScreen, pVisual, &pmap, alloc, client);
}
/* Called by the extension to install a colormap on DGA active screens */

View File

@ -469,9 +469,9 @@ xnestCreateDefaultColormap(ScreenPtr pScreen)
for (pVisual = pScreen->visuals;
pVisual->vid != pScreen->rootVisual; pVisual++);
if (CreateColormap(pScreen->defColormap, pScreen, pVisual, &pCmap,
if (dixCreateColormap(pScreen->defColormap, pScreen, pVisual, &pCmap,
(pVisual->class & DynamicClass) ? AllocNone : AllocAll,
0)
serverClient)
!= Success)
return FALSE;

View File

@ -31,6 +31,7 @@
#include "dix/dix_priv.h"
#include "dix/input_priv.h"
#include "dix/resource_priv.h"
#include "randr/randrstr_priv.h"
#include "xwayland-cvt.h"
@ -574,7 +575,7 @@ xwl_output_set_window_randr_emu_props(struct xwl_screen *xwl_screen,
{
struct xwl_output_randr_emu_prop prop = {};
xwl_output_randr_emu_prop(xwl_screen, wClient(window), &prop);
xwl_output_randr_emu_prop(xwl_screen, dixClientForWindow(window), &prop);
xwl_output_set_randr_emu_prop(window, &prop);
}

View File

@ -29,6 +29,8 @@
#include <xwayland-config.h>
#include <wayland-client.h>
#include "dix/resource_priv.h"
#include "pixmapstr.h"
/* This is an opaque structure implemented in the different backends */
@ -48,7 +50,7 @@ Bool xwl_pixmap_init(void);
static inline Bool
xwl_is_client_pixmap(PixmapPtr pixmap)
{
return clients[CLIENT_ID(pixmap->drawable.id)] != serverClient;
return (!dixResouceIsServerOwned(pixmap->drawable.id));
}
#endif /* XWAYLAND_PIXMAP_H */

View File

@ -34,6 +34,7 @@
#include "dix/dix_priv.h"
#include "dix/property_priv.h"
#include "dix/resource_priv.h"
#include "compositeext.h"
#include "compint.h"
@ -472,7 +473,7 @@ window_is_wm_window(WindowPtr window)
{
struct xwl_screen *xwl_screen = xwl_screen_get(window->drawable.pScreen);
return CLIENT_ID(window->drawable.id) == xwl_screen->wm_client_id;
return dixClientIdForXID(window->drawable.id) == xwl_screen->wm_client_id;
}
static WindowPtr
@ -572,7 +573,7 @@ xwl_window_should_enable_viewport(struct xwl_window *xwl_window,
if (!window)
return FALSE;
owner = wClient(window);
owner = dixClientForWindow(window);
drawable = &window->drawable;
/* 1. Test if the window matches the emulated mode on one of the outputs
@ -1788,7 +1789,7 @@ xwl_change_window_attributes(WindowPtr window, unsigned long mask)
for (others = wOtherClients(window); others; others = others->next) {
if (others->mask & (SubstructureRedirectMask | ResizeRedirectMask))
xwl_screen->wm_client_id = CLIENT_ID(others->resource);
xwl_screen->wm_client_id = dixClientIdForXID(others->resource);
}
return ret;

View File

@ -521,12 +521,12 @@ winCreateDefColormap(ScreenPtr pScreen)
#endif
/* Allocate an X colormap, owned by client 0 */
if (CreateColormap(pScreen->defColormap,
pScreen,
pVisual,
&pcmap,
(pVisual->class & DynamicClass) ? AllocNone : AllocAll,
0) != Success) {
if (dixCreateColormap(pScreen->defColormap,
pScreen,
pVisual,
&pcmap,
(pVisual->class & DynamicClass) ? AllocNone : AllocAll,
serverClient) != Success) {
ErrorF("winCreateDefColormap - CreateColormap failed\n");
return FALSE;
}

View File

@ -36,6 +36,8 @@
#include <xwin-config.h>
#endif
#include "dix/resource_priv.h"
#include "win.h"
#include "dixevents.h"
#include "winmultiwindowclass.h"
@ -714,7 +716,7 @@ XID
winGetWindowID(WindowPtr pWin)
{
WindowIDPairRec wi = { pWin, 0 };
ClientPtr c = wClient(pWin);
ClientPtr c = dixClientForWindow(pWin);
/* */
FindClientResourcesByType(c, X11_RESTYPE_WINDOW, winFindWindow, &wi);
@ -784,14 +786,14 @@ winReorderWindowsMultiWindow(void)
if (!pWinSib) { /* 1st window - raise to the top */
vlist[0] = Above;
ConfigureWindow(pWin, CWStackMode, vlist, wClient(pWin));
ConfigureWindow(pWin, CWStackMode, vlist, dixClientForWindow(pWin));
}
else { /* 2nd or deeper windows - just below the previous one */
vlist[0] = winGetWindowID(pWinSib);
vlist[1] = Below;
ConfigureWindow(pWin, CWSibling | CWStackMode,
vlist, wClient(pWin));
vlist, dixClientForWindow(pWin));
}
}
}
@ -893,7 +895,7 @@ winAdjustXWindow(WindowPtr pWin, HWND hwnd)
*/
vlist[0] = 0;
vlist[1] = 0;
return ConfigureWindow(pWin, CWX | CWY, vlist, wClient(pWin));
return ConfigureWindow(pWin, CWX | CWY, vlist, dixClientForWindow(pWin));
}
pDraw = &pWin->drawable;
@ -955,7 +957,7 @@ winAdjustXWindow(WindowPtr pWin, HWND hwnd)
(unsigned int)vlist[2], (unsigned int)vlist[3]);
#endif
return ConfigureWindow(pWin, CWX | CWY | CWWidth | CWHeight,
vlist, wClient(pWin));
vlist, dixClientForWindow(pWin));
#undef WIDTH
#undef HEIGHT

View File

@ -65,9 +65,6 @@ extern _X_EXPORT void AssignTypeAndName(DeviceIntPtr dev,
#define ClearBit(ptr, bit) (((BYTE *)(ptr))[(bit)>>3] &= ~(1 << ((bit) & 7)))
extern _X_EXPORT int CountBits(const uint8_t * mask, int len);
#define SameClient(obj,client) \
(CLIENT_BITS((obj)->resource) == (client)->clientAsMask)
#define EMASKSIZE (MAXDEVICES + 2)
/* This is the last XI2 event supported by the server. If you add

View File

@ -100,19 +100,6 @@ typedef uint32_t RESTYPE;
extern _X_EXPORT unsigned int ResourceClientBits(void);
/* bits and fields within a resource id */
#define RESOURCE_AND_CLIENT_COUNT 29 /* 29 bits for XIDs */
#define RESOURCE_CLIENT_BITS ResourceClientBits() /* client field offset */
#define CLIENTOFFSET (RESOURCE_AND_CLIENT_COUNT - RESOURCE_CLIENT_BITS)
/* resource field */
#define RESOURCE_ID_MASK ((1 << CLIENTOFFSET) - 1)
/* client field */
#define RESOURCE_CLIENT_MASK (((1 << RESOURCE_CLIENT_BITS) - 1) << CLIENTOFFSET)
/* extract the client mask from an XID */
#define CLIENT_BITS(id) ((id) & RESOURCE_CLIENT_MASK)
/* extract the client id from an XID */
#define CLIENT_ID(id) ((int)(CLIENT_BITS(id) >> CLIENTOFFSET))
#define SERVER_BIT (Mask)0x40000000 /* use illegal bit */
#ifdef INVALID
#undef INVALID /* needed on HP/UX */
@ -123,8 +110,6 @@ extern _X_EXPORT unsigned int ResourceClientBits(void);
#define BAD_RESOURCE 0xe0000000
#define rClient(obj) (clients[CLIENT_ID((obj)->resource)])
/* Resource state callback */
extern _X_EXPORT CallbackListPtr ResourceStateCallback;
@ -262,28 +247,7 @@ extern _X_EXPORT int dixLookupResourceByClass(void **result,
ClientPtr client,
Mask access_mode);
extern _X_EXPORT void GetXIDRange(int /*client */ ,
Bool /*server */ ,
XID * /*minp */ ,
XID * /*maxp */ );
extern _X_EXPORT unsigned int GetXIDList(ClientPtr /*client */ ,
unsigned int /*count */ ,
XID * /*pids */ );
extern _X_EXPORT RESTYPE lastResourceType;
extern _X_EXPORT RESTYPE TypeMask;
/** @brief A hashing function to be used for hashing resource IDs
@param id The resource ID to hash
@param numBits The number of bits in the resulting hash. Must be >=0.
@note This function is really only for handling
INITHASHSIZE..MAXHASHSIZE bit hashes, but will handle any number
of bits by either masking numBits lower bits of the ID or by
providing at most MAXHASHSIZE hashes.
*/
extern _X_EXPORT int HashResourceID(XID id, unsigned int numBits);
#endif /* RESOURCE_H */

View File

@ -195,7 +195,6 @@ extern _X_EXPORT Mask DontPropagateMasks[];
#define wBoundingShape(w) wUseDefault(w, boundingShape, NULL)
#define wClipShape(w) wUseDefault(w, clipShape, NULL)
#define wInputShape(w) wUseDefault(w, inputShape, NULL)
#define wClient(w) (clients[CLIENT_ID((w)->drawable.id)])
#define wBorderWidth(w) ((int) (w)->borderWidth)
/* true when w needs a border drawn. */

View File

@ -259,8 +259,8 @@ miCreateDefColormap(ScreenPtr pScreen)
else
alloctype = AllocAll;
if (CreateColormap(pScreen->defColormap, pScreen, pVisual, &cmap,
alloctype, 0) != Success)
if (dixCreateColormap(pScreen->defColormap, pScreen, pVisual, &cmap,
alloctype, serverClient) != Success)
return FALSE;
if (pScreen->rootDepth > 1) {

View File

@ -36,6 +36,7 @@ and Jim Haggerty of Metheus.
#include "dix/cursor_priv.h"
#include "dix/eventconvert.h"
#include "dix/resource_priv.h"
#include "os/client_priv.h"
#include "dixstruct.h"
@ -864,7 +865,7 @@ RecordInstallHooks(RecordClientsAndProtocolPtr pRCAP, XID oneclient)
if (pRCAP->pRequestMajorOpSet) {
RecordSetIteratePtr pIter = NULL;
RecordSetInterval interval;
ClientPtr pClient = clients[CLIENT_ID(client)];
ClientPtr pClient = dixClientForXID(client);
if (pClient && !RecordClientPrivate(pClient)) {
RecordClientPrivatePtr pClientPriv;
@ -947,7 +948,7 @@ RecordUninstallHooks(RecordClientsAndProtocolPtr pRCAP, XID oneclient)
while (client) {
if (client != XRecordFutureClients) {
if (pRCAP->pRequestMajorOpSet) {
ClientPtr pClient = clients[CLIENT_ID(client)];
ClientPtr pClient = dixClientForXID(client);
int c;
Bool otherRCAPwantsProcVector = FALSE;
RecordClientPrivatePtr pClientPriv = NULL;
@ -1141,7 +1142,6 @@ RecordSanityCheckClientSpecifiers(ClientPtr client, XID *clientspecs,
int nspecs, XID errorspec)
{
int i;
int clientIndex;
int rc;
void *value;
@ -1152,10 +1152,10 @@ RecordSanityCheckClientSpecifiers(ClientPtr client, XID *clientspecs,
continue;
if (errorspec && (CLIENT_BITS(clientspecs[i]) == errorspec))
return BadMatch;
clientIndex = CLIENT_ID(clientspecs[i]);
if (clientIndex && clients[clientIndex] &&
clients[clientIndex]->clientState == ClientStateRunning) {
if (clientspecs[i] == clients[clientIndex]->clientAsMask)
ClientPtr pClient = dixClientForXID(clientspecs[i]);
if (pClient && pClient->index != 0 &&
pClient->clientState == ClientStateRunning) {
if (clientspecs[i] == pClient->clientAsMask)
continue;
rc = dixLookupResourceByClass(&value, clientspecs[i], RC_ANY,
client, DixGetAttrAccess);

View File

@ -432,8 +432,8 @@ PictureInitIndexedFormat(ScreenPtr pScreen, PictFormatPtr format)
if (pVisual == NULL)
return FALSE;
if (CreateColormap(FakeClientID(0), pScreen, pVisual,
&format->index.pColormap, AllocNone, 0)
if (dixCreateColormap(FakeClientID(0), pScreen, pVisual,
&format->index.pColormap, AllocNone, serverClient)
!= Success)
return FALSE;
}

View File

@ -25,6 +25,8 @@
#include <dix-config.h>
#endif
#include "dix/resource_priv.h"
#include "scrnintstr.h"
#include "windowstr.h"
#include "exevents.h"

View File

@ -23,6 +23,7 @@
#include <dix-config.h>
#include "dix/dix_priv.h"
#include "dix/resource_priv.h"
#include "xfixesint.h"