From a3718536989fa7d3358e0b2d859c25fde0a2d93e Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Sun, 1 Feb 2009 20:18:33 +1000 Subject: [PATCH] dix: Deliver{Grabbed|Focused|Device}Events API changed to InternalEvents. With the API change, we can now purge the XI conversion from POE. Note: this commit breaks DGA even more. Signed-off-by: Peter Hutterer --- Xi/exevents.c | 16 ++----- dix/events.c | 94 ++++++++++++++++++++----------------- hw/xfree86/common/xf86DGA.c | 6 +++ include/dix.h | 15 +++--- 4 files changed, 67 insertions(+), 64 deletions(-) diff --git a/Xi/exevents.c b/Xi/exevents.c index bb5fe6176..1ce3688a8 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -889,11 +889,6 @@ ProcessOtherEvent(xEventPtr ev, DeviceIntPtr device, int count) DeviceIntPtr mouse = NULL, kbd = NULL; DeviceEvent *event = (DeviceEvent*)ev; - /* FIXME: temporary solution only. */ - static int nevents; - static xEvent xE[1000]; /* enough bytes for the events we have atm */ - - if (IsPointerDevice(device)) { kbd = GetPairedDevice(device); @@ -989,15 +984,14 @@ ProcessOtherEvent(xEventPtr ev, DeviceIntPtr device, int count) deactivateDeviceGrab = TRUE; } - nevents = ConvertBackToXI((InternalEvent*)ev, xE); if (grab) - DeliverGrabbedEvent(xE, device, deactivateDeviceGrab, count); - else if (device->focus && !IsPointerEvent(xE)) - DeliverFocusedEvent(device, xE, GetSpriteWindow(device), count); + DeliverGrabbedEvent(event, device, deactivateDeviceGrab); + else if (device->focus && !IsPointerEvent((InternalEvent*)ev)) + DeliverFocusedEvent(device, event, GetSpriteWindow(device)); else - DeliverDeviceEvents(GetSpriteWindow(device), xE, NullGrab, NullWindow, - device, count); + DeliverDeviceEvents(GetSpriteWindow(device), event, NullGrab, + NullWindow, device); if (deactivateDeviceGrab == TRUE) (*device->deviceGrab.DeactivateGrab) (device); diff --git a/dix/events.c b/dix/events.c index 514c7a157..83f7b8d94 100644 --- a/dix/events.c +++ b/dix/events.c @@ -1213,10 +1213,6 @@ ComputeFreezes(void) GrabPtr grab; DeviceIntPtr dev; - /* FIXME: temporary solution only. */ - static int count; - static xEvent xE[1000]; /* enough bytes for the events we have atm */ - for (dev = inputInfo.devices; dev; dev = dev->next) FreezeThaw(dev, dev->deviceGrab.sync.other || (dev->deviceGrab.sync.state >= FROZEN)); @@ -1227,9 +1223,6 @@ ComputeFreezes(void) { DeviceEvent* event = replayDev->deviceGrab.sync.event; - /* FIXME: temporary */ - count = ConvertBackToXI(replayDev->deviceGrab.sync.event); - syncEvents.replayDev = (DeviceIntPtr)NULL; w = XYToWindow(replayDev, event->root_x, event->root_y); @@ -1240,19 +1233,20 @@ ComputeFreezes(void) { if (!CheckDeviceGrabs(replayDev, event, i+1)) { if (replayDev->focus && !IsPointerEvent((InternalEvent*)event)) - DeliverFocusedEvent(replayDev, xE, w, count); + DeliverFocusedEvent(replayDev, (InternalEvent*)event, w); else - DeliverDeviceEvents(w, xE, NullGrab, NullWindow, - replayDev, count); + DeliverDeviceEvents(w, (InternalEvent*)event, NullGrab, + NullWindow, replayDev); } goto playmore; } } /* must not still be in the same stack */ if (replayDev->focus && !IsPointerEvent((InternalEvent*)event)) - DeliverFocusedEvent(replayDev, xE, w, count); + DeliverFocusedEvent(replayDev, (InternalEvent*)event, w); else - DeliverDeviceEvents(w, xE, NullGrab, NullWindow, replayDev, count); + DeliverDeviceEvents(w, (InternalEvent*)event, NullGrab, + NullWindow, replayDev); } playmore: for (dev = inputInfo.devices; dev; dev = dev->next) @@ -2241,16 +2235,24 @@ FixUpEventFromWindow( * @see DeliverFocusedEvent */ int -DeliverDeviceEvents(WindowPtr pWin, xEvent *xE, GrabPtr grab, - WindowPtr stopAt, DeviceIntPtr dev, int count) +DeliverDeviceEvents(WindowPtr pWin, InternalEvent *event, GrabPtr grab, + WindowPtr stopAt, DeviceIntPtr dev) { Window child = None; - int type = xE->u.u.type; - Mask filter = filters[dev->id][type]; + int type; + Mask filter; int deliveries = 0; OtherInputMasks *inputMasks; int mskidx = dev->id; xEvent core; + /* FIXME: temporary solution only. */ + static int count; + static xEvent xE[1000]; /* enough bytes for the events we have atm */ + + /* FIXME: temporary only */ + count = ConvertBackToXI((InternalEvent*)event, xE); + type = xE->u.u.type; + filter = filters[dev->id][type]; if (XaceHook(XACE_SEND_ACCESS, NULL, dev, pWin, xE, count)) return 0; @@ -3362,7 +3364,7 @@ CheckDeviceGrabs(DeviceIntPtr device, DeviceEvent *event, int checkFirst) * @param count number of events in xE. */ void -DeliverFocusedEvent(DeviceIntPtr keybd, xEvent *xE, WindowPtr window, int count) +DeliverFocusedEvent(DeviceIntPtr keybd, InternalEvent *event, WindowPtr window) { DeviceIntPtr pointer; WindowPtr focus = keybd->focus->win; @@ -3370,18 +3372,25 @@ DeliverFocusedEvent(DeviceIntPtr keybd, xEvent *xE, WindowPtr window, int count) xEvent core; int deliveries = 0; + /* FIXME: temporary solution only. */ + static int count; + static xEvent xE[1000]; /* enough bytes for the events we have atm */ + + /* FIXME: temporary only */ + count = ConvertBackToXI((InternalEvent*)event, xE); + if (focus == FollowKeyboardWin) focus = inputInfo.keyboard->focus->win; if (!focus) return; if (focus == PointerRootWin) { - DeliverDeviceEvents(window, xE, NullGrab, NullWindow, keybd, count); + DeliverDeviceEvents(window, event, NullGrab, NullWindow, keybd); return; } if ((focus == window) || IsParent(focus, window)) { - if (DeliverDeviceEvents(window, xE, NullGrab, focus, keybd, count)) + if (DeliverDeviceEvents(window, event, NullGrab, focus, keybd)) return; } pointer = GetPairedDevice(keybd); @@ -3421,17 +3430,24 @@ DeliverFocusedEvent(DeviceIntPtr keybd, xEvent *xE, WindowPtr window, int count) * @param deactivateGrab True if the device's grab should be deactivated. */ void -DeliverGrabbedEvent(xEvent *xE, DeviceIntPtr thisDev, - Bool deactivateGrab, int count) +DeliverGrabbedEvent(InternalEvent *event, DeviceIntPtr thisDev, + Bool deactivateGrab) { GrabPtr grab; GrabInfoPtr grabinfo; int deliveries = 0; DeviceIntPtr dev; - xEvent *dxE, core; + xEvent core; SpritePtr pSprite = thisDev->spriteInfo->sprite; BOOL sendCore = FALSE; + /* FIXME: temporary solution only. */ + static int count; + static xEvent xE[1000]; /* enough bytes for the events we have atm */ + + /* FIXME: temporary only */ + count = ConvertBackToXI((InternalEvent*)event, xE); + grabinfo = &thisDev->deviceGrab; grab = grabinfo->grab; @@ -3443,7 +3459,7 @@ DeliverGrabbedEvent(xEvent *xE, DeviceIntPtr thisDev, * for the type of event, to see if we really want to deliver it to * the focus window. For pointer events, the answer is no. */ - if (IsPointerEvent(xE)) + if (IsPointerEvent(event)) focus = PointerRootWin; else if (thisDev->focus) { @@ -3454,15 +3470,15 @@ DeliverGrabbedEvent(xEvent *xE, DeviceIntPtr thisDev, else focus = PointerRootWin; if (focus == PointerRootWin) - deliveries = DeliverDeviceEvents(pSprite->win, xE, grab, - NullWindow, thisDev, count); + deliveries = DeliverDeviceEvents(pSprite->win, event, grab, + NullWindow, thisDev); else if (focus && (focus == pSprite->win || IsParent(focus, pSprite->win))) - deliveries = DeliverDeviceEvents(pSprite->win, xE, grab, focus, - thisDev, count); + deliveries = DeliverDeviceEvents(pSprite->win, event, grab, focus, + thisDev); else if (focus) - deliveries = DeliverDeviceEvents(focus, xE, grab, focus, - thisDev, count); + deliveries = DeliverDeviceEvents(focus, event, grab, focus, + thisDev); } if (!deliveries) { @@ -3538,12 +3554,10 @@ DeliverGrabbedEvent(xEvent *xE, DeviceIntPtr thisDev, } } - if (deliveries && (xE->u.u.type == MotionNotify - || xE->u.u.type == DeviceMotionNotify)) + if (deliveries && (event->u.any.type == ET_Motion)) thisDev->valuator->motionHintWindow = grab->window; } - if (deliveries && !deactivateGrab && - (xE->u.u.type != MotionNotify && xE->u.u.type != DeviceMotionNotify)) + if (deliveries && !deactivateGrab && event->u.any.type != ET_Motion) { switch (grabinfo->sync.state) { @@ -3564,17 +3578,9 @@ DeliverGrabbedEvent(xEvent *xE, DeviceIntPtr thisDev, case FREEZE_NEXT_EVENT: grabinfo->sync.state = FROZEN_WITH_EVENT; FreezeThaw(thisDev, TRUE); -#if 0 - /* FIXME: Sorry, frozen grabs are broken ATM */ - if (grabinfo->sync.evcount < count) - { - grabinfo->sync.event = xrealloc(grabinfo->sync.event, - count * sizeof(xEvent)); - } - grabinfo->sync.evcount = count; - for (dxE = grabinfo->sync.event; --count >= 0; dxE++, xE++) - *dxE = *xE; -#endif + if (!grabinfo->sync.event) + grabinfo->sync.event = xcalloc(1, sizeof(InternalEvent)); + *grabinfo->sync.event = *(DeviceEvent*)event; break; } } diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c index a974333f9..e630b5503 100644 --- a/hw/xfree86/common/xf86DGA.c +++ b/hw/xfree86/common/xf86DGA.c @@ -1067,6 +1067,8 @@ DGAProcessKeyboardEvent (ScreenPtr pScreen, dgaEvent *de, DeviceIntPtr keybd) /* If the keyboard is actively grabbed, deliver a grabbed core event */ if (keybd->deviceGrab.grab && !keybd->deviceGrab.fromPassiveGrab) { +#if 0 + /* FIXME: Hello. I am broken. Please fix me. Thanks. */ xi.u.u.type = (IEventBase - 1) + coreEquiv; xi.u.u.detail = de->u.u.detail; xi.u.keyButtonPointer.time = de->u.event.time; @@ -1077,6 +1079,7 @@ DGAProcessKeyboardEvent (ScreenPtr pScreen, dgaEvent *de, DeviceIntPtr keybd) xi.u.keyButtonPointer.state = de->u.event.state; ((deviceKeyButtonPointer*)&xi)->deviceid = keybd->id; DeliverGrabbedEvent (&xi, keybd, FALSE, 1); +#endif } } } @@ -1118,6 +1121,8 @@ DGAProcessPointerEvent (ScreenPtr pScreen, dgaEvent *de, DeviceIntPtr mouse) /* If the pointer is actively grabbed, deliver a grabbed core event */ if (mouse->deviceGrab.grab && !mouse->deviceGrab.fromPassiveGrab) { +#if 0 + /* FIXME: Hello. I am broken. Please fix me. Thanks. */ xi.u.u.type = (IEventBase - 1 ) + coreEquiv; xi.u.u.detail = de->u.u.detail; xi.u.keyButtonPointer.time = de->u.event.time; @@ -1127,6 +1132,7 @@ DGAProcessPointerEvent (ScreenPtr pScreen, dgaEvent *de, DeviceIntPtr mouse) xi.u.keyButtonPointer.rootY = de->u.event.dy; xi.u.keyButtonPointer.state = de->u.event.state; DeliverGrabbedEvent (&xi, mouse, FALSE, 1); +#endif } } } diff --git a/include/dix.h b/include/dix.h index e61808a33..d48d83af3 100644 --- a/include/dix.h +++ b/include/dix.h @@ -371,11 +371,10 @@ extern _X_EXPORT int DeliverEventsToWindow( extern _X_EXPORT int DeliverDeviceEvents( WindowPtr /* pWin */, - xEventPtr /* xE */, + InternalEvent* /* event */, GrabPtr /* grab */, WindowPtr /* stopAt */, - DeviceIntPtr /* dev */, - int /* count */); + DeviceIntPtr /* dev */); extern _X_EXPORT void InitializeSprite( DeviceIntPtr /* pDev */, @@ -395,15 +394,13 @@ extern _X_EXPORT Bool CheckDeviceGrabs( extern _X_EXPORT void DeliverFocusedEvent( DeviceIntPtr /* keybd */, - xEventPtr /* xE */, - WindowPtr /* window */, - int /* count */); + InternalEvent* /* event */, + WindowPtr /* window */); extern _X_EXPORT void DeliverGrabbedEvent( - xEventPtr /* xE */, + InternalEvent* /* event */, DeviceIntPtr /* thisDev */, - Bool /* deactivateGrab */, - int /* count */); + Bool /* deactivateGrab */); extern _X_EXPORT void FixKeyState( DeviceEvent* /* event */,