input: abstract Xtst device lookup
The callers should need to use the dev privates key to look up xtest devices. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Acked-by: Benjamin Close <Benjamin.Close@clearchain.com>
This commit is contained in:
parent
34424fab9a
commit
1bcc0d3c24
|
@ -54,8 +54,6 @@
|
||||||
|
|
||||||
#include "xichangehierarchy.h"
|
#include "xichangehierarchy.h"
|
||||||
|
|
||||||
extern DevPrivateKey XTstDevicePrivateKey;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send the current state of the device hierarchy to all clients.
|
* 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 )
|
for(xtstdevice = inputInfo.devices; xtstdevice ; xtstdevice = xtstdevice->next )
|
||||||
if( !IsMaster(xtstdevice) && xtstdevice->u.master == ptr &&
|
if (IsXtstDevice(xtstdevice, ptr))
|
||||||
dixLookupPrivate(&xtstdevice->devPrivates, XTstDevicePrivateKey ))
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
rc = dixLookupDevice(&xtstptr, xtstdevice->id, client,
|
rc = dixLookupDevice(&xtstptr, xtstdevice->id, client,
|
||||||
|
@ -297,10 +294,7 @@ ProcXIChangeHierarchy(ClientPtr client)
|
||||||
{
|
{
|
||||||
/* Search the matching keyboard */
|
/* Search the matching keyboard */
|
||||||
for(xtstdevice = inputInfo.devices; xtstdevice ; xtstdevice = xtstdevice->next )
|
for(xtstdevice = inputInfo.devices; xtstdevice ; xtstdevice = xtstdevice->next )
|
||||||
if( !IsMaster(xtstdevice) &&
|
if(IsKeyboardDevice(xtstdevice) && IsXtstDevice(xtstdevice, keybd))
|
||||||
xtstdevice->u.master == keybd &&
|
|
||||||
IsKeyboardDevice(xtstdevice) &&
|
|
||||||
dixLookupPrivate(&xtstdevice->devPrivates, XTstDevicePrivateKey ))
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
rc = dixLookupDevice(&xtstkeybd,
|
rc = dixLookupDevice(&xtstkeybd,
|
||||||
|
@ -316,11 +310,7 @@ ProcXIChangeHierarchy(ClientPtr client)
|
||||||
xtstkeybd = xtstptr;
|
xtstkeybd = xtstptr;
|
||||||
/* Search the matching pointer */
|
/* Search the matching pointer */
|
||||||
for(xtstdevice = inputInfo.devices; xtstdevice ; xtstdevice = xtstdevice->next )
|
for(xtstdevice = inputInfo.devices; xtstdevice ; xtstdevice = xtstdevice->next )
|
||||||
if( !IsMaster(xtstdevice) &&
|
if(IsPointerDevice(xtstdevice) && IsXtstDevice(xtstdevice, ptr))
|
||||||
xtstdevice->u.master == ptr &&
|
|
||||||
IsPointerDevice(xtstdevice) &&
|
|
||||||
dixLookupPrivate(&xtstdevice->devPrivates, XTstDevicePrivateKey )
|
|
||||||
)
|
|
||||||
break;
|
break;
|
||||||
rc = dixLookupDevice(&xtstptr,
|
rc = dixLookupDevice(&xtstptr,
|
||||||
xtstdevice->id,
|
xtstdevice->id,
|
||||||
|
@ -412,7 +402,6 @@ ProcXIChangeHierarchy(ClientPtr client)
|
||||||
case XIDetachSlave:
|
case XIDetachSlave:
|
||||||
{
|
{
|
||||||
xXIDetachSlaveInfo* c = (xXIDetachSlaveInfo*)any;
|
xXIDetachSlaveInfo* c = (xXIDetachSlaveInfo*)any;
|
||||||
DeviceIntPtr *xtstdevice;
|
|
||||||
|
|
||||||
rc = dixLookupDevice(&ptr, c->deviceid, client,
|
rc = dixLookupDevice(&ptr, c->deviceid, client,
|
||||||
DixManageAccess);
|
DixManageAccess);
|
||||||
|
@ -426,11 +415,8 @@ ProcXIChangeHierarchy(ClientPtr client)
|
||||||
goto unwind;
|
goto unwind;
|
||||||
}
|
}
|
||||||
|
|
||||||
xtstdevice = dixLookupPrivate( &ptr->devPrivates,
|
|
||||||
XTstDevicePrivateKey );
|
|
||||||
|
|
||||||
/* Don't allow changes to Xtst Devices, these are fixed */
|
/* Don't allow changes to Xtst Devices, these are fixed */
|
||||||
if( xtstdevice )
|
if (IsXtstDevice(ptr, NULL))
|
||||||
{
|
{
|
||||||
client->errorValue = c->deviceid;
|
client->errorValue = c->deviceid;
|
||||||
rc = BadDevice;
|
rc = BadDevice;
|
||||||
|
@ -445,7 +431,6 @@ ProcXIChangeHierarchy(ClientPtr client)
|
||||||
{
|
{
|
||||||
xXIAttachSlaveInfo* c = (xXIAttachSlaveInfo*)any;
|
xXIAttachSlaveInfo* c = (xXIAttachSlaveInfo*)any;
|
||||||
DeviceIntPtr newmaster;
|
DeviceIntPtr newmaster;
|
||||||
DeviceIntPtr *xtstdevice;
|
|
||||||
|
|
||||||
rc = dixLookupDevice(&ptr, c->deviceid, client,
|
rc = dixLookupDevice(&ptr, c->deviceid, client,
|
||||||
DixManageAccess);
|
DixManageAccess);
|
||||||
|
@ -459,11 +444,8 @@ ProcXIChangeHierarchy(ClientPtr client)
|
||||||
goto unwind;
|
goto unwind;
|
||||||
}
|
}
|
||||||
|
|
||||||
xtstdevice = dixLookupPrivate( &ptr->devPrivates,
|
|
||||||
XTstDevicePrivateKey );
|
|
||||||
|
|
||||||
/* Don't allow changes to Xtst Devices, these are fixed */
|
/* Don't allow changes to Xtst Devices, these are fixed */
|
||||||
if( xtstdevice )
|
if (IsXtstDevice(ptr, NULL))
|
||||||
{
|
{
|
||||||
client->errorValue = c->deviceid;
|
client->errorValue = c->deviceid;
|
||||||
rc = BadDevice;
|
rc = BadDevice;
|
||||||
|
|
|
@ -2589,3 +2589,16 @@ int AllocXtstDevice (ClientPtr client, char* name,
|
||||||
|
|
||||||
return retval;
|
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));
|
||||||
|
}
|
||||||
|
|
|
@ -497,6 +497,7 @@ extern int AllocXtstDevice(ClientPtr client,
|
||||||
char* name,
|
char* name,
|
||||||
DeviceIntPtr* ptr,
|
DeviceIntPtr* ptr,
|
||||||
DeviceIntPtr* keybd);
|
DeviceIntPtr* keybd);
|
||||||
|
extern BOOL IsXtstDevice(DeviceIntPtr dev, DeviceIntPtr master);
|
||||||
|
|
||||||
/* misc event helpers */
|
/* misc event helpers */
|
||||||
extern Mask GetEventFilter(DeviceIntPtr dev, xEvent *event);
|
extern Mask GetEventFilter(DeviceIntPtr dev, xEvent *event);
|
||||||
|
|
Loading…
Reference in New Issue