diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2010-12-05 15:36:12 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2010-12-05 15:36:12 +0000 |
commit | a90ee792d96752ad1b71b9ada922fa6afe478c99 (patch) | |
tree | 6143b00f7646951d23dfe2a4fe2992ca40b77069 /xserver/Xi/exevents.c | |
parent | bc97d4ecc0aa9e1b823565b07282f848700bd11a (diff) |
Upgrade to xorg-server 1.9.2.
Tested by ajacoutot@, krw@, shadchin@ and jasper@ on various configurations
including multihead with both zaphod and xrandr.
Diffstat (limited to 'xserver/Xi/exevents.c')
-rw-r--r-- | xserver/Xi/exevents.c | 170 |
1 files changed, 79 insertions, 91 deletions
diff --git a/xserver/Xi/exevents.c b/xserver/Xi/exevents.c index 566b0ef60..e19e207fd 100644 --- a/xserver/Xi/exevents.c +++ b/xserver/Xi/exevents.c @@ -94,9 +94,6 @@ Bool ShouldFreeInputMasks(WindowPtr /* pWin */ , static Bool MakeInputMasks(WindowPtr /* pWin */ ); -/* Used to sture classes currently not in use by an MD */ -extern DevPrivateKey UnusedClassesPrivateKey; - /* * Only let the given client know of core events which will affect its * interpretation of input events, if the client's ClientPointer (or the @@ -224,9 +221,9 @@ DeepCopyFeedbackClasses(DeviceIntPtr from, DeviceIntPtr to) if (!to->intfeed) { - classes = dixLookupPrivate(&to->devPrivates, - UnusedClassesPrivateKey); + classes = to->unused_classes; to->intfeed = classes->intfeed; + classes->intfeed = NULL; } i = &to->intfeed; @@ -234,7 +231,7 @@ DeepCopyFeedbackClasses(DeviceIntPtr from, DeviceIntPtr to) { if (!(*i)) { - *i = xcalloc(1, sizeof(IntegerFeedbackClassRec)); + *i = calloc(1, sizeof(IntegerFeedbackClassRec)); if (!(*i)) { ErrorF("[Xi] Cannot alloc memory for class copy."); @@ -249,7 +246,7 @@ DeepCopyFeedbackClasses(DeviceIntPtr from, DeviceIntPtr to) } else if (to->intfeed && !from->intfeed) { ClassesPtr classes; - classes = dixLookupPrivate(&to->devPrivates, UnusedClassesPrivateKey); + classes = to->unused_classes; classes->intfeed = to->intfeed; to->intfeed = NULL; } @@ -260,9 +257,9 @@ DeepCopyFeedbackClasses(DeviceIntPtr from, DeviceIntPtr to) if (!to->stringfeed) { - classes = dixLookupPrivate(&to->devPrivates, - UnusedClassesPrivateKey); + classes = to->unused_classes; to->stringfeed = classes->stringfeed; + classes->stringfeed = NULL; } s = &to->stringfeed; @@ -270,7 +267,7 @@ DeepCopyFeedbackClasses(DeviceIntPtr from, DeviceIntPtr to) { if (!(*s)) { - *s = xcalloc(1, sizeof(StringFeedbackClassRec)); + *s = calloc(1, sizeof(StringFeedbackClassRec)); if (!(*s)) { ErrorF("[Xi] Cannot alloc memory for class copy."); @@ -285,7 +282,7 @@ DeepCopyFeedbackClasses(DeviceIntPtr from, DeviceIntPtr to) } else if (to->stringfeed && !from->stringfeed) { ClassesPtr classes; - classes = dixLookupPrivate(&to->devPrivates, UnusedClassesPrivateKey); + classes = to->unused_classes; classes->stringfeed = to->stringfeed; to->stringfeed = NULL; } @@ -296,9 +293,9 @@ DeepCopyFeedbackClasses(DeviceIntPtr from, DeviceIntPtr to) if (!to->bell) { - classes = dixLookupPrivate(&to->devPrivates, - UnusedClassesPrivateKey); + classes = to->unused_classes; to->bell = classes->bell; + classes->bell = NULL; } b = &to->bell; @@ -306,7 +303,7 @@ DeepCopyFeedbackClasses(DeviceIntPtr from, DeviceIntPtr to) { if (!(*b)) { - *b = xcalloc(1, sizeof(BellFeedbackClassRec)); + *b = calloc(1, sizeof(BellFeedbackClassRec)); if (!(*b)) { ErrorF("[Xi] Cannot alloc memory for class copy."); @@ -322,7 +319,7 @@ DeepCopyFeedbackClasses(DeviceIntPtr from, DeviceIntPtr to) } else if (to->bell && !from->bell) { ClassesPtr classes; - classes = dixLookupPrivate(&to->devPrivates, UnusedClassesPrivateKey); + classes = to->unused_classes; classes->bell = to->bell; to->bell = NULL; } @@ -333,9 +330,9 @@ DeepCopyFeedbackClasses(DeviceIntPtr from, DeviceIntPtr to) if (!to->leds) { - classes = dixLookupPrivate(&to->devPrivates, - UnusedClassesPrivateKey); + classes = to->unused_classes; to->leds = classes->leds; + classes->leds = NULL; } l = &to->leds; @@ -343,7 +340,7 @@ DeepCopyFeedbackClasses(DeviceIntPtr from, DeviceIntPtr to) { if (!(*l)) { - *l = xcalloc(1, sizeof(LedFeedbackClassRec)); + *l = calloc(1, sizeof(LedFeedbackClassRec)); if (!(*l)) { ErrorF("[Xi] Cannot alloc memory for class copy."); @@ -361,7 +358,7 @@ DeepCopyFeedbackClasses(DeviceIntPtr from, DeviceIntPtr to) } else if (to->leds && !from->leds) { ClassesPtr classes; - classes = dixLookupPrivate(&to->devPrivates, UnusedClassesPrivateKey); + classes = to->unused_classes; classes->leds = to->leds; to->leds = NULL; } @@ -381,12 +378,12 @@ DeepCopyKeyboardClasses(DeviceIntPtr from, DeviceIntPtr to) if (!to->kbdfeed) { - classes = dixLookupPrivate(&to->devPrivates, - UnusedClassesPrivateKey); + classes = to->unused_classes; to->kbdfeed = classes->kbdfeed; if (!to->kbdfeed) InitKeyboardDeviceStruct(to, NULL, NULL, NULL); + classes->kbdfeed = NULL; } k = &to->kbdfeed; @@ -394,7 +391,7 @@ DeepCopyKeyboardClasses(DeviceIntPtr from, DeviceIntPtr to) { if (!(*k)) { - *k = xcalloc(1, sizeof(KbdFeedbackClassRec)); + *k = calloc(1, sizeof(KbdFeedbackClassRec)); if (!*k) { ErrorF("[Xi] Cannot alloc memory for class copy."); @@ -413,7 +410,7 @@ DeepCopyKeyboardClasses(DeviceIntPtr from, DeviceIntPtr to) } else if (to->kbdfeed && !from->kbdfeed) { ClassesPtr classes; - classes = dixLookupPrivate(&to->devPrivates, UnusedClassesPrivateKey); + classes = to->unused_classes; classes->kbdfeed = to->kbdfeed; to->kbdfeed = NULL; } @@ -422,8 +419,7 @@ DeepCopyKeyboardClasses(DeviceIntPtr from, DeviceIntPtr to) { if (!to->key) { - classes = dixLookupPrivate(&to->devPrivates, - UnusedClassesPrivateKey); + classes = to->unused_classes; to->key = classes->key; if (!to->key) InitKeyboardDeviceStruct(to, NULL, NULL, NULL); @@ -435,7 +431,7 @@ DeepCopyKeyboardClasses(DeviceIntPtr from, DeviceIntPtr to) } else if (to->key && !from->key) { ClassesPtr classes; - classes = dixLookupPrivate(&to->devPrivates, UnusedClassesPrivateKey); + classes = to->unused_classes; classes->key = to->key; to->key = NULL; } @@ -472,12 +468,11 @@ DeepCopyKeyboardClasses(DeviceIntPtr from, DeviceIntPtr to) { WindowPtr *oldTrace; - classes = dixLookupPrivate(&to->devPrivates, - UnusedClassesPrivateKey); + classes = to->unused_classes; to->focus = classes->focus; if (!to->focus) { - to->focus = xcalloc(1, sizeof(FocusClassRec)); + to->focus = calloc(1, sizeof(FocusClassRec)); if (!to->focus) FatalError("[Xi] no memory for class shift.\n"); } else @@ -485,7 +480,7 @@ DeepCopyKeyboardClasses(DeviceIntPtr from, DeviceIntPtr to) oldTrace = to->focus->trace; memcpy(to->focus, from->focus, sizeof(FocusClassRec)); - to->focus->trace = xrealloc(oldTrace, + to->focus->trace = realloc(oldTrace, to->focus->traceSize * sizeof(WindowPtr)); if (!to->focus->trace && to->focus->traceSize) FatalError("[Xi] no memory for trace.\n"); @@ -496,7 +491,7 @@ DeepCopyKeyboardClasses(DeviceIntPtr from, DeviceIntPtr to) } else if (to->focus) { ClassesPtr classes; - classes = dixLookupPrivate(&to->devPrivates, UnusedClassesPrivateKey); + classes = to->unused_classes; classes->focus = to->focus; to->focus = NULL; } @@ -514,9 +509,9 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to) PtrFeedbackPtr *p, it; if (!to->ptrfeed) { - classes = dixLookupPrivate(&to->devPrivates, - UnusedClassesPrivateKey); + classes = to->unused_classes; to->ptrfeed = classes->ptrfeed; + classes->ptrfeed = NULL; } p = &to->ptrfeed; @@ -524,7 +519,7 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to) { if (!(*p)) { - *p = xcalloc(1, sizeof(PtrFeedbackClassRec)); + *p = calloc(1, sizeof(PtrFeedbackClassRec)); if (!*p) { ErrorF("[Xi] Cannot alloc memory for class copy."); @@ -539,7 +534,7 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to) } else if (to->ptrfeed && !from->ptrfeed) { ClassesPtr classes; - classes = dixLookupPrivate(&to->devPrivates, UnusedClassesPrivateKey); + classes = to->unused_classes; classes->ptrfeed = to->ptrfeed; to->ptrfeed = NULL; } @@ -549,14 +544,13 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to) ValuatorClassPtr v; if (!to->valuator) { - classes = dixLookupPrivate(&to->devPrivates, - UnusedClassesPrivateKey); + classes = to->unused_classes; to->valuator = classes->valuator; if (to->valuator) classes->valuator = NULL; } - to->valuator = xrealloc(to->valuator, sizeof(ValuatorClassRec) + + to->valuator = realloc(to->valuator, sizeof(ValuatorClassRec) + from->valuator->numAxes * sizeof(AxisInfo) + from->valuator->numAxes * sizeof(double)); v = to->valuator; @@ -573,7 +567,7 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to) } else if (to->valuator && !from->valuator) { ClassesPtr classes; - classes = dixLookupPrivate(&to->devPrivates, UnusedClassesPrivateKey); + classes = to->unused_classes; classes->valuator = to->valuator; to->valuator = NULL; } @@ -582,12 +576,11 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to) { if (!to->button) { - classes = dixLookupPrivate(&to->devPrivates, - UnusedClassesPrivateKey); + classes = to->unused_classes; to->button = classes->button; if (!to->button) { - to->button = xcalloc(1, sizeof(ButtonClassRec)); + to->button = calloc(1, sizeof(ButtonClassRec)); if (!to->button) FatalError("[Xi] no memory for class shift.\n"); } else @@ -598,14 +591,14 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to) { if (!to->button->xkb_acts) { - to->button->xkb_acts = xcalloc(1, sizeof(XkbAction)); + to->button->xkb_acts = calloc(1, sizeof(XkbAction)); if (!to->button->xkb_acts) FatalError("[Xi] not enough memory for xkb_acts.\n"); } memcpy(to->button->xkb_acts, from->button->xkb_acts, sizeof(XkbAction)); } else - xfree(to->button->xkb_acts); + free(to->button->xkb_acts); memcpy(to->button->labels, from->button->labels, from->button->numButtons * sizeof(Atom)); @@ -613,7 +606,7 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to) } else if (to->button && !from->button) { ClassesPtr classes; - classes = dixLookupPrivate(&to->devPrivates, UnusedClassesPrivateKey); + classes = to->unused_classes; classes->button = to->button; to->button = NULL; } @@ -622,12 +615,11 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to) { if (!to->proximity) { - classes = dixLookupPrivate(&to->devPrivates, - UnusedClassesPrivateKey); + classes = to->unused_classes; to->proximity = classes->proximity; if (!to->proximity) { - to->proximity = xcalloc(1, sizeof(ProximityClassRec)); + to->proximity = calloc(1, sizeof(ProximityClassRec)); if (!to->proximity) FatalError("[Xi] no memory for class shift.\n"); } else @@ -638,7 +630,7 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to) } else if (to->proximity) { ClassesPtr classes; - classes = dixLookupPrivate(&to->devPrivates, UnusedClassesPrivateKey); + classes = to->unused_classes; classes->proximity = to->proximity; to->proximity = NULL; } @@ -647,12 +639,11 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to) { if (!to->absolute) { - classes = dixLookupPrivate(&to->devPrivates, - UnusedClassesPrivateKey); + classes = to->unused_classes; to->absolute = classes->absolute; if (!to->absolute) { - to->absolute = xcalloc(1, sizeof(AbsoluteClassRec)); + to->absolute = calloc(1, sizeof(AbsoluteClassRec)); if (!to->absolute) FatalError("[Xi] no memory for class shift.\n"); } else @@ -663,7 +654,7 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to) } else if (to->absolute) { ClassesPtr classes; - classes = dixLookupPrivate(&to->devPrivates, UnusedClassesPrivateKey); + classes = to->unused_classes; classes->absolute = to->absolute; to->absolute = NULL; } @@ -709,7 +700,7 @@ XISendDeviceChangedEvent(DeviceIntPtr device, DeviceIntPtr master, DeviceChanged /* we don't actually swap if there's a NullClient, swapping is done * later when event is delivered. */ SendEventToAllWindows(master, XI_DeviceChangedMask, (xEvent*)dcce, 1); - xfree(dcce); + free(dcce); } static void @@ -762,7 +753,6 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent* event) KeyClassPtr k = NULL; ButtonClassPtr b = NULL; ValuatorClassPtr v = NULL; - BYTE *kptr = NULL; /* This event is always the first we get, before the actual events with * the data. However, the way how the DDX is set up, "device" will @@ -829,32 +819,31 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent* event) if (!k) return DONT_PROCESS; - kptr = &k->down[key >> 3]; - /* don't allow ddx to generate multiple downs, but repeats are okay */ - if ((*kptr & bit) && !event->key_repeat) + /* don't allow ddx to generate multiple downs, but repeats are okay */ + if (key_is_down(device, key, KEY_PROCESSED) && !event->key_repeat) return DONT_PROCESS; + if (device->valuator) device->valuator->motionHintWindow = NullWindow; - *kptr |= bit; + set_key_down(device, key, KEY_PROCESSED); } else if (event->type == ET_KeyRelease) { if (!k) return DONT_PROCESS; - kptr = &k->down[key >> 3]; - if (!(*kptr & bit)) /* guard against duplicates */ + if (!key_is_down(device, key, KEY_PROCESSED)) /* guard against duplicates */ return DONT_PROCESS; if (device->valuator) device->valuator->motionHintWindow = NullWindow; - *kptr &= ~bit; + set_key_up(device, key, KEY_PROCESSED); } else if (event->type == ET_ButtonPress) { Mask mask; if (!b) return DONT_PROCESS; - kptr = &b->down[key >> 3]; - if ((*kptr & bit) != 0) + if (button_is_down(device, key, BUTTON_PROCESSED)) return DONT_PROCESS; - *kptr |= bit; + + set_button_down(device, key, BUTTON_PROCESSED); if (device->valuator) device->valuator->motionHintWindow = NullWindow; if (!b->map[key]) @@ -874,8 +863,7 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent* event) if (!b) return DONT_PROCESS; - kptr = &b->down[key>>3]; - if (!(*kptr & bit)) + if (!button_is_down(device, key, BUTTON_PROCESSED)) return DONT_PROCESS; if (IsMaster(device)) { DeviceIntPtr sd; @@ -890,11 +878,11 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent* event) continue; if (!sd->button) continue; - if ((sd->button->down[key>>3] & bit) != 0) + if (button_is_down(sd, key, BUTTON_PROCESSED)) return DONT_PROCESS; } } - *kptr &= ~bit; + set_button_up(device, key, BUTTON_PROCESSED); if (device->valuator) device->valuator->motionHintWindow = NullWindow; if (!b->map[key]) @@ -937,9 +925,9 @@ ProcessRawEvent(RawDeviceEvent *ev, DeviceIntPtr device) } for (i = 0; i < screenInfo.numScreens; i++) - DeliverEventsToWindow(device, WindowTable[i], xi, 1, + DeliverEventsToWindow(device, screenInfo.screens[i]->root, xi, 1, GetEventFilter(device, xi), NULL); - xfree(xi); + free(xi); } } @@ -1053,7 +1041,7 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device) /* see comment in EnqueueEvents regarding the next three lines */ if (ev->any.type == ET_Motion) - ev->device_event.root = WindowTable[pSprite->hotPhys.pScreen->myNum]->drawable.id; + ev->device_event.root = pSprite->hotPhys.pScreen->root->drawable.id; eventinfo.device = device; eventinfo.event = ev; @@ -1127,7 +1115,7 @@ InitProximityClassDeviceStruct(DeviceIntPtr dev) { ProximityClassPtr proxc; - proxc = (ProximityClassPtr) xalloc(sizeof(ProximityClassRec)); + proxc = (ProximityClassPtr) malloc(sizeof(ProximityClassRec)); if (!proxc) return FALSE; proxc->sourceid = dev->id; @@ -1243,7 +1231,7 @@ DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail, btlen = bytes_to_int32(btlen); len = sizeof(xXIFocusInEvent) + btlen * 4; - xi2event = xcalloc(1, len); + xi2event = calloc(1, len); xi2event->type = GenericEvent; xi2event->extension = IReqCode; xi2event->evtype = type; @@ -1279,7 +1267,7 @@ DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail, DeliverEventsToWindow(dev, pWin, (xEvent*)xi2event, 1, GetEventFilter(dev, (xEvent*)xi2event), NullGrab); - xfree(xi2event); + free(xi2event); /* XI 1.x event */ event.deviceid = dev->id; @@ -1333,7 +1321,7 @@ DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail, } } - sev = ev = (deviceStateNotify *) xalloc(evcount * sizeof(xEvent)); + sev = ev = (deviceStateNotify *) malloc(evcount * sizeof(xEvent)); FixDeviceStateNotify(dev, ev, NULL, NULL, NULL, first); if (b != NULL) { @@ -1388,7 +1376,7 @@ DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail, DeliverEventsToWindow(dev, pWin, (xEvent *) sev, evcount, DeviceStateNotifyMask, NullGrab); - xfree(sev); + free(sev); } } @@ -1456,7 +1444,7 @@ GrabButton(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr modifier_device, if (rc != Success) { client->errorValue = param->cursor; - return (rc == BadValue) ? BadCursor : rc; + return rc; } access_mode |= DixForceAccess; } @@ -1554,7 +1542,7 @@ GrabWindow(ClientPtr client, DeviceIntPtr dev, int type, if (rc != Success) { client->errorValue = param->cursor; - return (rc == BadValue) ? BadCursor : rc; + return rc; } access_mode |= DixForceAccess; } @@ -1638,7 +1626,7 @@ AddExtensionClient(WindowPtr pWin, ClientPtr client, Mask mask, int mskidx) if (!pWin->optional && !MakeWindowOptional(pWin)) return BadAlloc; - others = xcalloc(1, sizeof(InputClients)); + others = calloc(1, sizeof(InputClients)); if (!others) return BadAlloc; if (!pWin->optional->inputMasks && !MakeInputMasks(pWin)) @@ -1657,7 +1645,7 @@ MakeInputMasks(WindowPtr pWin) { struct _OtherInputMasks *imasks; - imasks = xcalloc(1, sizeof(struct _OtherInputMasks)); + imasks = calloc(1, sizeof(struct _OtherInputMasks)); if (!imasks) return FALSE; pWin->optional->inputMasks = imasks; @@ -1713,21 +1701,21 @@ InputClientGone(WindowPtr pWin, XID id) InputClientsPtr other, prev; if (!wOtherInputMasks(pWin)) - return (Success); + return Success; prev = 0; for (other = wOtherInputMasks(pWin)->inputClients; other; other = other->next) { if (other->resource == id) { if (prev) { prev->next = other->next; - xfree(other); + free(other); } else if (!(other->next)) { if (ShouldFreeInputMasks(pWin, TRUE)) { wOtherInputMasks(pWin)->inputClients = other->next; - xfree(wOtherInputMasks(pWin)); + free(wOtherInputMasks(pWin)); pWin->optional->inputMasks = (OtherInputMasks *) NULL; CheckWindowOptionalNeed(pWin); - xfree(other); + free(other); } else { other->resource = FakeClientID(0); if (!AddResource(other->resource, RT_INPUTCLIENT, @@ -1736,10 +1724,10 @@ InputClientGone(WindowPtr pWin, XID id) } } else { wOtherInputMasks(pWin)->inputClients = other->next; - xfree(other); + free(other); } RecalculateDeviceDeliverableEvents(pWin); - return (Success); + return Success; } prev = other; } @@ -1840,7 +1828,7 @@ ChangeKeyMapping(ClientPtr client, KeyClassPtr k = dev->key; if (k == NULL) - return (BadMatch); + return BadMatch; if (len != (keyCodes * keySymsPerKeyCode)) return BadLength; @@ -1862,7 +1850,7 @@ ChangeKeyMapping(ClientPtr client, XkbApplyMappingChange(dev, &keysyms, firstKeyCode, keyCodes, NULL, serverClient); - return client->noClientException; + return Success; } static void @@ -1983,7 +1971,7 @@ MaybeSendDeviceMotionNotifyHint(deviceKeyButtonPointer * pEvents, Mask mask) pEvents->detail = NotifyNormal; } } - return (0); + return 0; } void @@ -2131,7 +2119,7 @@ SendEventToAllWindows(DeviceIntPtr dev, Mask mask, xEvent * ev, int count) WindowPtr pWin, p1; for (i = 0; i < screenInfo.numScreens; i++) { - pWin = WindowTable[i]; + pWin = screenInfo.screens[i]->root; if (!pWin) continue; DeliverEventsToWindow(dev, pWin, ev, count, mask, NullGrab); |