summaryrefslogtreecommitdiff
path: root/dix/devices.c
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2009-06-23 10:50:52 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2009-07-01 08:46:31 +1000
commit0814f511d56a89c7b1868b17eba7a89f990b9ab1 (patch)
tree606dcc0cfe2e2cbed05f03f71400d6b872b83298 /dix/devices.c
parent1bcc0d3c244ce7d9f5cbab626aa5fd5784b41a1c (diff)
input: store the master device's ID in the devPrivate for XTest devices.
Rather than storing a simple boolean in the devPrivate for XTest devices, store the actual master device's id (since it is constant for the life of the device anyway). Callers should use GetXtstDevice now instead of digging around in the devPrivates themselves. This patch allows for a cleanup in the creation of new master devices since GetMaster and GetXtstDevice spare the need for loops, IsPointer checks and similar. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Acked-by: Benjamin Close <Benjamin.Close@clearchain.com>
Diffstat (limited to 'dix/devices.c')
-rw-r--r--dix/devices.c42
1 files changed, 35 insertions, 7 deletions
diff --git a/dix/devices.c b/dix/devices.c
index 2d776577c..b7f21927f 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -639,8 +639,8 @@ InitCoreDevices(void)
is a slave device to inputInfo master devices
*/
if(AllocXtstDevice(serverClient, "Virtual core",
- &vxtstpointer,
- &vxtstkeyboard) != Success)
+ &vxtstpointer, &vxtstkeyboard,
+ inputInfo.pointer, inputInfo.keyboard) != Success)
FatalError("Failed to allocate XTst devices");
if (ActivateDevice(vxtstpointer, TRUE) != Success ||
@@ -2570,7 +2570,8 @@ AllocDevicePair (ClientPtr client, char* name,
* still need to be called.
*/
int AllocXtstDevice (ClientPtr client, char* name,
- DeviceIntPtr* ptr, DeviceIntPtr* keybd)
+ DeviceIntPtr* ptr, DeviceIntPtr* keybd,
+ DeviceIntPtr master_ptr, DeviceIntPtr master_keybd)
{
int retval;
int len = strlen(name);
@@ -2581,8 +2582,8 @@ int AllocXtstDevice (ClientPtr client, char* name,
retval = AllocDevicePair( client, xtstname, ptr, keybd, FALSE);
if ( retval == Success ){
- dixSetPrivate(&((*ptr)->devPrivates), XTstDevicePrivateKey, (void *)True );
- dixSetPrivate(&((*keybd)->devPrivates), XTstDevicePrivateKey,(void *)True);
+ dixSetPrivate(&((*ptr)->devPrivates), XTstDevicePrivateKey, (void *)master_ptr->id);
+ dixSetPrivate(&((*keybd)->devPrivates), XTstDevicePrivateKey, (void *)master_keybd->id);
}
xfree( xtstname );
@@ -2599,6 +2600,33 @@ int AllocXtstDevice (ClientPtr client, char* name,
BOOL
IsXtstDevice(DeviceIntPtr dev, DeviceIntPtr master)
{
- return (!IsMaster(dev) && (!master || dev->u.master == master) &&
- ( dixLookupPrivate(&dev->devPrivates, XTstDevicePrivateKey) != NULL));
+ int mid;
+ void *tmp; /* shut up, gcc! */
+
+ if (IsMaster(dev))
+ return FALSE;
+
+ tmp = dixLookupPrivate(&dev->devPrivates, XTstDevicePrivateKey);
+ mid = (int)tmp;
+
+ return (!master || mid == master->id);
}
+
+/**
+ * @return The X Test virtual device for the given master.
+ */
+DeviceIntPtr
+GetXtstDevice(DeviceIntPtr master)
+{
+ DeviceIntPtr it;
+
+ for (it = inputInfo.devices; it; it = it->next)
+ {
+ if (IsXtstDevice(it, master))
+ return it;
+ }
+
+ /* This only happens if master is a slave device. don't do that */
+ return NULL;
+}
+