From 48249425275cc90242497aee9968e5f1ffc86698 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 10 Apr 2008 14:36:10 +0930 Subject: [PATCH] Xi: dont copy FocusClassRec if the master already has one. Blindly copying will override the focus setting of the master. If there's XI applications running, they may set the SD focus, while leaving the MD's focus as it was. In this case, after a class swap we still want to get the MD's events to the same window as before. --- Xi/exevents.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/Xi/exevents.c b/Xi/exevents.c index 38f6cb57a..ba7f3b2bb 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -459,11 +459,29 @@ DeepCopyDeviceClasses(DeviceIntPtr from, DeviceIntPtr to) } - ALLOC_COPY_CLASS_IF(focus, FocusClassRec); - if (to->focus && !from->focus) + /* We can't just copy over the focus class. When an app sets the focus, + * it'll do so on the master device. Copying the SDs focus means losing + * the focus. + * So we only copy the focus class if the device didn't have one, + * otherwise we leave it as it is. + */ + if (from->focus) { - FreeDeviceClass(FocusClass, (pointer)&to->focus); + if (!to->focus) + { + to->focus = xcalloc(1, sizeof(FocusClassRec)); + if (!to->focus) + FatalError("[Xi] no memory for class shift.\n"); + memcpy(to->focus->trace, from->focus->trace, + from->focus->traceSize * sizeof(WindowPtr)); + } + } else if (to->focus) + { + /* properly freeing the class would also free the sprite trace, which + * is still in use by the SD. just xfree the struct. */ + xfree(to->focus); } + ALLOC_COPY_CLASS_IF(proximity, ProximityClassRec); if (to->proximity && !from->proximity) {