diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2009-06-23 10:50:52 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2009-07-01 08:46:31 +1000 |
commit | 0814f511d56a89c7b1868b17eba7a89f990b9ab1 (patch) | |
tree | 606dcc0cfe2e2cbed05f03f71400d6b872b83298 /Xi | |
parent | 1bcc0d3c244ce7d9f5cbab626aa5fd5784b41a1c (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 'Xi')
-rw-r--r-- | Xi/xichangehierarchy.c | 84 |
1 files changed, 24 insertions, 60 deletions
diff --git a/Xi/xichangehierarchy.c b/Xi/xichangehierarchy.c index 137c20914..656515bfd 100644 --- a/Xi/xichangehierarchy.c +++ b/Xi/xichangehierarchy.c @@ -186,8 +186,9 @@ ProcXIChangeHierarchy(ClientPtr client) if (!c->send_core) ptr->coreEvents = keybd->coreEvents = FALSE; - /* Allocate virtual slave devices for xtest events */ - rc = AllocXtstDevice(client, name, &xtstptr, &xtstkeybd); + /* Allocate virtual slave devices for xtest events */ + rc = AllocXtstDevice(client, name, &xtstptr, &xtstkeybd, + ptr, keybd); if (rc != Success) { @@ -231,7 +232,6 @@ ProcXIChangeHierarchy(ClientPtr client) case XIRemoveMaster: { xXIRemoveMasterInfo* r = (xXIRemoveMasterInfo*)any; - DeviceIntPtr xtstdevice; if (r->return_mode != XIAttachToMaster && r->return_mode != XIFloating) @@ -257,69 +257,33 @@ ProcXIChangeHierarchy(ClientPtr client) goto unwind; } - for(xtstdevice = inputInfo.devices; xtstdevice ; xtstdevice = xtstdevice->next ) - if (IsXtstDevice(xtstdevice, ptr)) - break; - rc = dixLookupDevice(&xtstptr, xtstdevice->id, client, + ptr = GetMaster(ptr, MASTER_POINTER); + rc = dixLookupDevice(&ptr, + ptr->id, + client, + DixDestroyAccess); + if (rc != Success) + goto unwind; + keybd = GetMaster(ptr, MASTER_KEYBOARD); + rc = dixLookupDevice(&keybd, + keybd->id, + client, DixDestroyAccess); if (rc != Success) goto unwind; - /* find keyboards to destroy */ - if (IsPointerDevice(ptr)) - { - rc = dixLookupDevice(&keybd, - ptr->spriteInfo->paired->id, - client, - DixDestroyAccess); - if (rc != Success) - goto unwind; - - } - else - { - keybd = ptr; - rc = dixLookupDevice(&ptr, - keybd->spriteInfo->paired->id, - client, - DixDestroyAccess); - if (rc != Success) - goto unwind; - - } - - /* handle xtst pointer / keyboard slave devices */ - if ( IsPointerDevice(xtstptr)) - { - /* Search the matching keyboard */ - for(xtstdevice = inputInfo.devices; xtstdevice ; xtstdevice = xtstdevice->next ) - if(IsKeyboardDevice(xtstdevice) && IsXtstDevice(xtstdevice, keybd)) - break; - - rc = dixLookupDevice(&xtstkeybd, - xtstdevice->id, - client, - DixDestroyAccess); - - if (rc != Success) - goto unwind; - } - else - { - xtstkeybd = xtstptr; - /* Search the matching pointer */ - for(xtstdevice = inputInfo.devices; xtstdevice ; xtstdevice = xtstdevice->next ) - if(IsPointerDevice(xtstdevice) && IsXtstDevice(xtstdevice, ptr)) - break; - rc = dixLookupDevice(&xtstptr, - xtstdevice->id, - client, - DixDestroyAccess); + xtstptr = GetXtstDevice(ptr); + rc = dixLookupDevice(&xtstptr, xtstptr->id, client, + DixDestroyAccess); + if (rc != Success) + goto unwind; - if (rc != Success) - goto unwind; - } + xtstkeybd = GetXtstDevice(keybd); + rc = dixLookupDevice(&xtstkeybd, xtstkeybd->id, client, + DixDestroyAccess); + if (rc != Success) + goto unwind; /* Disabling sends the devices floating, reattach them if * desired. */ |