diff options
author | Peter Hutterer <peter@cs.unisa.edu.au> | 2008-04-10 19:25:43 +0930 |
---|---|---|
committer | Peter Hutterer <peter@cs.unisa.edu.au> | 2008-04-10 19:25:43 +0930 |
commit | b4380d8030927c940ddaea83c4cf24e0b9eb7b96 (patch) | |
tree | 4449de55cdd8a1fbee062a735624af4c7c932b55 /dix | |
parent | 04dff74ffdf727015e3721aae4ea13acc498cd1c (diff) |
dix: don't free MDs classes on init.
The device classes aren't deleted anymore on a class change, so there's no
need to store the MD's original classes. We should however restore the MD to
sane defaults when disconnecting the last device, consider this as TODO item.
Diffstat (limited to 'dix')
-rw-r--r-- | dix/devices.c | 103 |
1 files changed, 1 insertions, 102 deletions
diff --git a/dix/devices.c b/dix/devices.c index 2d7885e28..a78a1255d 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -88,8 +88,6 @@ SOFTWARE. /* The client that is allowed to change pointer-keyboard pairings. */ static ClientPtr pairingClient = NULL; - -DevPrivateKey MasterDevClassesPrivateKey = &MasterDevClassesPrivateKey; DevPrivateKey CoreDevicePrivateKey = &CoreDevicePrivateKey; /** @@ -409,7 +407,6 @@ CoreKeyboardProc(DeviceIntPtr pDev, int what) XkbComponentNamesRec names; #endif ClassesPtr classes; - DeviceIntRec dummy; switch (what) { case DEVICE_INIT: @@ -419,8 +416,6 @@ CoreKeyboardProc(DeviceIntPtr pDev, int what) return BadAlloc; } - dixSetPrivate(&pDev->devPrivates, MasterDevClassesPrivateKey, NULL); - keySyms.minKeyCode = 8; keySyms.maxKeyCode = 255; keySyms.mapWidth = 4; @@ -459,53 +454,9 @@ CoreKeyboardProc(DeviceIntPtr pDev, int what) xfree(keySyms.map); xfree(modMap); - - classes->key = pDev->key; - classes->valuator = pDev->valuator; - classes->button = pDev->button; - classes->focus = pDev->focus; - classes->proximity = pDev->proximity; - classes->absolute = pDev->absolute; - classes->kbdfeed = pDev->kbdfeed; - classes->ptrfeed = pDev->ptrfeed; - classes->intfeed = pDev->intfeed; - classes->stringfeed = pDev->stringfeed; - classes->bell = pDev->bell; - classes->leds = pDev->leds; - - /* Each time we switch classes we free the MD's classes and copy the - * SD's classes into the MD. We mustn't lose the first set of classes - * though as we need it to restore them when the last SD disconnects. - * - * So we create a fake device, seem to copy from the fake to the real - * one, thus ending up with a copy of the original ones in our MD. - * - * If we don't do that, we're in SIGABRT territory (double-frees, etc) - */ - memcpy(&dummy, pDev, sizeof(DeviceIntRec)); - /* Need to set them to NULL. Otherwise, Xkb does some weird stuff and - * the dev->key->xkbInfo->kbdProc starts calling itself. This can - * probably be fixed in a better way, but I don't know how. (whot) */ - pDev->key = NULL; - pDev->valuator = NULL; - pDev->button = NULL; - pDev->focus = NULL; - pDev->proximity = NULL; - pDev->absolute = NULL; - pDev->kbdfeed = NULL; - pDev->ptrfeed = NULL; - pDev->intfeed = NULL; - pDev->stringfeed = NULL; - pDev->bell = NULL; - pDev->leds = NULL; - DeepCopyDeviceClasses(&dummy, pDev); - - dixSetPrivate(&pDev->devPrivates, MasterDevClassesPrivateKey, - classes); break; case DEVICE_CLOSE: - dixSetPrivate(&pDev->devPrivates, CoreDevicePrivateKey, NULL); break; default: @@ -526,16 +477,12 @@ CorePointerProc(DeviceIntPtr pDev, int what) BYTE map[33]; int i = 0; ClassesPtr classes; - DeviceIntRec dummy; - switch (what) { case DEVICE_INIT: if (!(classes = xcalloc(1, sizeof(ClassesRec)))) return BadAlloc; - dixSetPrivate(&pDev->devPrivates, MasterDevClassesPrivateKey, NULL); - for (i = 1; i <= 32; i++) map[i] = i; InitPointerDeviceStruct((DevicePtr)pDev, map, 32, @@ -545,43 +492,9 @@ CorePointerProc(DeviceIntPtr pDev, int what) pDev->lastx = pDev->valuator->axisVal[0]; pDev->valuator->axisVal[1] = screenInfo.screens[0]->height / 2; pDev->lasty = pDev->valuator->axisVal[1]; - - classes->key = pDev->key; - classes->valuator = pDev->valuator; - classes->button = pDev->button; - classes->focus = pDev->focus; - classes->proximity = pDev->proximity; - classes->absolute = pDev->absolute; - classes->kbdfeed = pDev->kbdfeed; - classes->ptrfeed = pDev->ptrfeed; - classes->intfeed = pDev->intfeed; - classes->stringfeed = pDev->stringfeed; - classes->bell = pDev->bell; - classes->leds = pDev->leds; - - /* See comment in CoreKeyboardProc. */ - memcpy(&dummy, pDev, sizeof(DeviceIntRec)); - /* Need to set them to NULL for the VCK (see CoreKeyboardProc). Not - * sure if also necessary for the VCP, but it doesn't seem to hurt */ - pDev->key = NULL; - pDev->valuator = NULL; - pDev->button = NULL; - pDev->focus = NULL; - pDev->proximity = NULL; - pDev->absolute = NULL; - pDev->kbdfeed = NULL; - pDev->ptrfeed = NULL; - pDev->intfeed = NULL; - pDev->stringfeed = NULL; - pDev->bell = NULL; - pDev->leds = NULL; - DeepCopyDeviceClasses(&dummy, pDev); - - dixSetPrivate(&pDev->devPrivates, MasterDevClassesPrivateKey, classes); break; case DEVICE_CLOSE: - dixSetPrivate(&pDev->devPrivates, CoreDevicePrivateKey, NULL); break; default: @@ -857,13 +770,6 @@ CloseDevice(DeviceIntPtr dev) xfree(dev->name); - if (dev->isMaster) - { - classes = (ClassesPtr)dixLookupPrivate(&dev->devPrivates, - MasterDevClassesPrivateKey); - FreeAllDeviceClasses(classes); - } - classes = (ClassesPtr)&dev->key; FreeAllDeviceClasses(classes); @@ -2543,16 +2449,9 @@ AttachDevice(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr master) if (!it) /* no dev is paired with old master */ { - ClassesPtr classes; + /* XXX: reset to defaults */ EventList event = { NULL, 0}; char* classbuf; - DeviceIntRec dummy; - - FreeAllDeviceClasses((ClassesPtr)&oldmaster->key); - classes = (ClassesPtr)dixLookupPrivate(&oldmaster->devPrivates, - MasterDevClassesPrivateKey); - memcpy(&dummy.key, classes, sizeof(ClassesRec)); - DeepCopyDeviceClasses(&dummy, oldmaster); /* Send event to clients */ CreateClassesChangedEvent(&event, oldmaster, oldmaster); |