summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter@cs.unisa.edu.au>2007-05-01 11:02:05 +0930
committerPeter Hutterer <peter@cs.unisa.edu.au>2007-05-01 11:02:05 +0930
commit325380adb20ec2b82e176d75599fd4bc97a3b918 (patch)
treeb0e1fa58507227b57a3854cecd78640052e8d945
parentb043a184509cfe5c4c4691ecde1a4a065e53d575 (diff)
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.
-rw-r--r--dix/devices.c1
-rw-r--r--dix/events.c16
2 files changed, 17 insertions, 0 deletions
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;