dix: adjust PickPointer and PickKeyboard to get the first master device.

Simplifies it a lot, since we always have at least one master device
available at all times, so less mucking around.
This commit is contained in:
Peter Hutterer 2007-10-14 08:00:06 +09:30
parent 0c5f65ecd3
commit 9ecbbf198f

View File

@ -6117,34 +6117,22 @@ SetClientPointer(ClientPtr client, ClientPtr setter, DeviceIntPtr device)
return TRUE; return TRUE;
} }
/* PickPointer will pick an appropriate pointer for the given client. /* PickPointer will pick an appropriate pointer for the given client. */
*
* If a client pointer is set, it will pick the client pointer, otherwise the
* first available pointer in the list. If no physical device is attached, it
* will pick the core pointer, but will not store it on the client.
*/
_X_EXPORT DeviceIntPtr _X_EXPORT DeviceIntPtr
PickPointer(ClientPtr client) PickPointer(ClientPtr client)
{ {
if (!client->clientPtr) if (!client->clientPtr)
{ {
/* look if there is a real device attached */
DeviceIntPtr it = inputInfo.devices; DeviceIntPtr it = inputInfo.devices;
while (it) while (it)
{ {
if (it != inputInfo.pointer && it->spriteInfo->spriteOwner) if (it->isMaster && it->spriteInfo->spriteOwner)
{ {
client->clientPtr = it; client->clientPtr = it;
break; break;
} }
it = it->next; it = it->next;
} }
if (!it)
{
ErrorF("[dix] Picking VCP\n");
return inputInfo.pointer;
}
} }
return client->clientPtr; return client->clientPtr;
} }
@ -6159,18 +6147,15 @@ _X_EXPORT DeviceIntPtr
PickKeyboard(ClientPtr client) PickKeyboard(ClientPtr client)
{ {
DeviceIntPtr ptr = PickPointer(client); DeviceIntPtr ptr = PickPointer(client);
DeviceIntPtr kbd = inputInfo.devices; DeviceIntPtr kbd = ptr->spriteInfo->paired;
while(kbd) if (!kbd)
{ {
if (ptr != kbd && ErrorF("[dix] ClientPointer not paired with a keyboard. This "
IsKeyboardDevice(kbd) && "is a bug.\n");
ptr->spriteInfo->sprite == kbd->spriteInfo->sprite)
return kbd;
kbd = kbd->next;
} }
return (kbd) ? kbd : inputInfo.keyboard; return kbd;
} }
/* A client that has one or more core grabs does not get core events from /* A client that has one or more core grabs does not get core events from