From 325380adb20ec2b82e176d75599fd4bc97a3b918 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 1 May 2007 11:02:05 +0930 Subject: [PATCH] Check and re-set paired devices when initializing sprites. If we don't do this, a device that is paired before a sprite has been initialized for the paired device will not actually get the right sprite and segfault the server on focus events. Happens for the VCK. --- dix/devices.c | 1 + dix/events.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/dix/devices.c b/dix/devices.c index 27271f304..a415a8e26 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -2158,6 +2158,7 @@ PairDevices(ClientPtr client, DeviceIntPtr ptr, DeviceIntPtr kbd) } kbd->spriteInfo->sprite = ptr->spriteInfo->sprite; + kbd->spriteInfo->paired = ptr; return Success; } diff --git a/dix/events.c b/dix/events.c index 836d755f6..f767f7095 100644 --- a/dix/events.c +++ b/dix/events.c @@ -2528,9 +2528,25 @@ InitializeSprite(DeviceIntPtr pDev, WindowPtr pWin) if (!pDev->spriteInfo->sprite) { + DeviceIntPtr it; + pDev->spriteInfo->sprite = (SpritePtr)xcalloc(1, sizeof(SpriteRec)); if (!pDev->spriteInfo->sprite) FatalError("InitializeSprite: failed to allocate sprite struct"); + + /* We may have paired another device with this device before our + * device had a actual sprite. We need to check for this and reset the + * sprite field for all paired devices. + * + * The VCK is always paired with the VCP before the VCP has a sprite. + */ + for (it = inputInfo.devices; it; it = it->next) + { + if (it->spriteInfo->paired == pDev) + it->spriteInfo->sprite = pDev->spriteInfo->sprite; + } + if (inputInfo.keyboard->spriteInfo->paired == pDev) + inputInfo.keyboard->spriteInfo->sprite = pDev->spriteInfo->sprite; } pSprite = pDev->spriteInfo->sprite;