diff options
author | Peter Hutterer <peter@cs.unisa.edu.au> | 2008-04-10 14:36:10 +0930 |
---|---|---|
committer | Peter Hutterer <peter@cs.unisa.edu.au> | 2008-04-10 14:36:10 +0930 |
commit | 48249425275cc90242497aee9968e5f1ffc86698 (patch) | |
tree | 1ab8fcc4ffb9a5fd7753a5e9b5ca306c6b0164a7 | |
parent | bce6091c6b04ff2db704ae4f161179d21dcbec59 (diff) |
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.
-rw-r--r-- | Xi/exevents.c | 24 |
1 files 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) + { + 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) { - FreeDeviceClass(FocusClass, (pointer)&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) { |