7683114
From 11eea736f44a236dde884b52ad51cb5d1271b7a5 Mon Sep 17 00:00:00 2001
7683114
From: Peter Hutterer <peter.hutterer@who-t.net>
7683114
Date: Wed, 13 Jan 2010 15:03:45 +1000
7683114
Subject: [PATCH] Xi: reset the sli pointers after copying device classes. (#25640)
7683114
7683114
If the indicator flags have the XkbSLI_IsDefault bit set, the indicator map
7683114
and names aren't their own bit of memory but rather point into the
7683114
device->key->xkbInfo->desc structure. XkbCopySrvLedInfo knows about this and
7683114
leaves the pointers alone.
7683114
7683114
When copying the classes from the slave to the master, these pointers are
7683114
copied and still point to the dev->key class of the slave device. If the
7683114
slave device is removed, the memory becomes invalid and a call to modify
7683114
this data (e.g. XkbSetIndicators) may cause a deadlock.
7683114
7683114
The copying of dev->key relies on dev->kbdfeed to be already set up. Hence
7683114
the pointers need to be reset once _both_ kbdfeed and key have been copied
7683114
into the master device.
7683114
7683114
X.Org Bug 25640 <http://bugs.freedesktop.org/show_bug.cgi?id=25640>
7683114
Fedora Bug 540584 <https://bugzilla.redhat.com/show_bug.cgi?id=540584>
7683114
---
7683114
 Xi/exevents.c |   20 ++++++++++++++++++++
7683114
 1 files changed, 20 insertions(+), 0 deletions(-)
7683114
7683114
diff --git a/Xi/exevents.c b/Xi/exevents.c
7683114
index cb2452b..ee32ba8 100644
7683114
--- a/Xi/exevents.c
7683114
+++ b/Xi/exevents.c
7683114
@@ -444,6 +444,26 @@ DeepCopyKeyboardClasses(DeviceIntPtr from, DeviceIntPtr to)
7683114
         to->key      = NULL;
7683114
     }
7683114
 
7683114
+    /* If a SrvLedInfoPtr's flags are XkbSLI_IsDefault, the names and maps
7683114
+     * pointer point into the xkbInfo->desc struct.  XkbCopySrvLedInfo
7683114
+     * didn't update the pointers so we need to do it manually here.
7683114
+     */
7683114
+    if (to->kbdfeed)
7683114
+    {
7683114
+        KbdFeedbackPtr k;
7683114
+
7683114
+        for (k = to->kbdfeed; k; k = k->next)
7683114
+        {
7683114
+            if (!k->xkb_sli)
7683114
+                continue;
7683114
+            if (k->xkb_sli->flags & XkbSLI_IsDefault)
7683114
+            {
7683114
+                k->xkb_sli->names = to->key->xkbInfo->desc->names->indicators;
7683114
+                k->xkb_sli->maps = to->key->xkbInfo->desc->indicators->maps;
7683114
+            }
7683114
+        }
7683114
+    }
7683114
+
7683114
     /* We can't just copy over the focus class. When an app sets the focus,
7683114
      * it'll do so on the master device. Copying the SDs focus means losing
7683114
      * the focus.
7683114
-- 
7683114
1.6.6
7683114