diff options
-rw-r--r-- | Xi/xichangehierarchy.c | 28 | ||||
-rw-r--r-- | dix/devices.c | 13 | ||||
-rw-r--r-- | include/input.h | 1 |
3 files changed, 19 insertions, 23 deletions
diff --git a/Xi/xichangehierarchy.c b/Xi/xichangehierarchy.c index 917a0d7d9..137c20914 100644 --- a/Xi/xichangehierarchy.c +++ b/Xi/xichangehierarchy.c @@ -54,8 +54,6 @@ #include "xichangehierarchy.h" -extern DevPrivateKey XTstDevicePrivateKey; - /** * Send the current state of the device hierarchy to all clients. */ @@ -260,8 +258,7 @@ ProcXIChangeHierarchy(ClientPtr client) } for(xtstdevice = inputInfo.devices; xtstdevice ; xtstdevice = xtstdevice->next ) - if( !IsMaster(xtstdevice) && xtstdevice->u.master == ptr && - dixLookupPrivate(&xtstdevice->devPrivates, XTstDevicePrivateKey )) + if (IsXtstDevice(xtstdevice, ptr)) break; rc = dixLookupDevice(&xtstptr, xtstdevice->id, client, @@ -297,10 +294,7 @@ ProcXIChangeHierarchy(ClientPtr client) { /* Search the matching keyboard */ for(xtstdevice = inputInfo.devices; xtstdevice ; xtstdevice = xtstdevice->next ) - if( !IsMaster(xtstdevice) && - xtstdevice->u.master == keybd && - IsKeyboardDevice(xtstdevice) && - dixLookupPrivate(&xtstdevice->devPrivates, XTstDevicePrivateKey )) + if(IsKeyboardDevice(xtstdevice) && IsXtstDevice(xtstdevice, keybd)) break; rc = dixLookupDevice(&xtstkeybd, @@ -316,11 +310,7 @@ ProcXIChangeHierarchy(ClientPtr client) xtstkeybd = xtstptr; /* Search the matching pointer */ for(xtstdevice = inputInfo.devices; xtstdevice ; xtstdevice = xtstdevice->next ) - if( !IsMaster(xtstdevice) && - xtstdevice->u.master == ptr && - IsPointerDevice(xtstdevice) && - dixLookupPrivate(&xtstdevice->devPrivates, XTstDevicePrivateKey ) - ) + if(IsPointerDevice(xtstdevice) && IsXtstDevice(xtstdevice, ptr)) break; rc = dixLookupDevice(&xtstptr, xtstdevice->id, @@ -412,7 +402,6 @@ ProcXIChangeHierarchy(ClientPtr client) case XIDetachSlave: { xXIDetachSlaveInfo* c = (xXIDetachSlaveInfo*)any; - DeviceIntPtr *xtstdevice; rc = dixLookupDevice(&ptr, c->deviceid, client, DixManageAccess); @@ -426,11 +415,8 @@ ProcXIChangeHierarchy(ClientPtr client) goto unwind; } - xtstdevice = dixLookupPrivate( &ptr->devPrivates, - XTstDevicePrivateKey ); - /* Don't allow changes to Xtst Devices, these are fixed */ - if( xtstdevice ) + if (IsXtstDevice(ptr, NULL)) { client->errorValue = c->deviceid; rc = BadDevice; @@ -445,7 +431,6 @@ ProcXIChangeHierarchy(ClientPtr client) { xXIAttachSlaveInfo* c = (xXIAttachSlaveInfo*)any; DeviceIntPtr newmaster; - DeviceIntPtr *xtstdevice; rc = dixLookupDevice(&ptr, c->deviceid, client, DixManageAccess); @@ -459,11 +444,8 @@ ProcXIChangeHierarchy(ClientPtr client) goto unwind; } - xtstdevice = dixLookupPrivate( &ptr->devPrivates, - XTstDevicePrivateKey ); - /* Don't allow changes to Xtst Devices, these are fixed */ - if( xtstdevice ) + if (IsXtstDevice(ptr, NULL)) { client->errorValue = c->deviceid; rc = BadDevice; diff --git a/dix/devices.c b/dix/devices.c index b237e03b1..2d776577c 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -2589,3 +2589,16 @@ int AllocXtstDevice (ClientPtr client, char* name, return retval; } + +/** + * If master is NULL, return TRUE if the given device is an xtest device or + * FALSE otherwise. + * If master is not NULL, return TRUE if the given device is this master's + * xtest device. + */ +BOOL +IsXtstDevice(DeviceIntPtr dev, DeviceIntPtr master) +{ + return (!IsMaster(dev) && (!master || dev->u.master == master) && + ( dixLookupPrivate(&dev->devPrivates, XTstDevicePrivateKey) != NULL)); +} diff --git a/include/input.h b/include/input.h index 9711fa87d..1dfbbff0b 100644 --- a/include/input.h +++ b/include/input.h @@ -497,6 +497,7 @@ extern int AllocXtstDevice(ClientPtr client, char* name, DeviceIntPtr* ptr, DeviceIntPtr* keybd); +extern BOOL IsXtstDevice(DeviceIntPtr dev, DeviceIntPtr master); /* misc event helpers */ extern Mask GetEventFilter(DeviceIntPtr dev, xEvent *event); |