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 <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2009-02-01 20:18:33 +10:00
parent 8f94ec6f78
commit a371853698
4 changed files with 67 additions and 64 deletions

View File

@ -889,11 +889,6 @@ ProcessOtherEvent(xEventPtr ev, DeviceIntPtr device, int count)
DeviceIntPtr mouse = NULL, kbd = NULL; DeviceIntPtr mouse = NULL, kbd = NULL;
DeviceEvent *event = (DeviceEvent*)ev; 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)) if (IsPointerDevice(device))
{ {
kbd = GetPairedDevice(device); kbd = GetPairedDevice(device);
@ -989,15 +984,14 @@ ProcessOtherEvent(xEventPtr ev, DeviceIntPtr device, int count)
deactivateDeviceGrab = TRUE; deactivateDeviceGrab = TRUE;
} }
nevents = ConvertBackToXI((InternalEvent*)ev, xE);
if (grab) if (grab)
DeliverGrabbedEvent(xE, device, deactivateDeviceGrab, count); DeliverGrabbedEvent(event, device, deactivateDeviceGrab);
else if (device->focus && !IsPointerEvent(xE)) else if (device->focus && !IsPointerEvent((InternalEvent*)ev))
DeliverFocusedEvent(device, xE, GetSpriteWindow(device), count); DeliverFocusedEvent(device, event, GetSpriteWindow(device));
else else
DeliverDeviceEvents(GetSpriteWindow(device), xE, NullGrab, NullWindow, DeliverDeviceEvents(GetSpriteWindow(device), event, NullGrab,
device, count); NullWindow, device);
if (deactivateDeviceGrab == TRUE) if (deactivateDeviceGrab == TRUE)
(*device->deviceGrab.DeactivateGrab) (device); (*device->deviceGrab.DeactivateGrab) (device);

View File

@ -1213,10 +1213,6 @@ ComputeFreezes(void)
GrabPtr grab; GrabPtr grab;
DeviceIntPtr dev; 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) for (dev = inputInfo.devices; dev; dev = dev->next)
FreezeThaw(dev, dev->deviceGrab.sync.other || FreezeThaw(dev, dev->deviceGrab.sync.other ||
(dev->deviceGrab.sync.state >= FROZEN)); (dev->deviceGrab.sync.state >= FROZEN));
@ -1227,9 +1223,6 @@ ComputeFreezes(void)
{ {
DeviceEvent* event = replayDev->deviceGrab.sync.event; DeviceEvent* event = replayDev->deviceGrab.sync.event;
/* FIXME: temporary */
count = ConvertBackToXI(replayDev->deviceGrab.sync.event);
syncEvents.replayDev = (DeviceIntPtr)NULL; syncEvents.replayDev = (DeviceIntPtr)NULL;
w = XYToWindow(replayDev, event->root_x, event->root_y); w = XYToWindow(replayDev, event->root_x, event->root_y);
@ -1240,19 +1233,20 @@ ComputeFreezes(void)
{ {
if (!CheckDeviceGrabs(replayDev, event, i+1)) { if (!CheckDeviceGrabs(replayDev, event, i+1)) {
if (replayDev->focus && !IsPointerEvent((InternalEvent*)event)) if (replayDev->focus && !IsPointerEvent((InternalEvent*)event))
DeliverFocusedEvent(replayDev, xE, w, count); DeliverFocusedEvent(replayDev, (InternalEvent*)event, w);
else else
DeliverDeviceEvents(w, xE, NullGrab, NullWindow, DeliverDeviceEvents(w, (InternalEvent*)event, NullGrab,
replayDev, count); NullWindow, replayDev);
} }
goto playmore; goto playmore;
} }
} }
/* must not still be in the same stack */ /* must not still be in the same stack */
if (replayDev->focus && !IsPointerEvent((InternalEvent*)event)) if (replayDev->focus && !IsPointerEvent((InternalEvent*)event))
DeliverFocusedEvent(replayDev, xE, w, count); DeliverFocusedEvent(replayDev, (InternalEvent*)event, w);
else else
DeliverDeviceEvents(w, xE, NullGrab, NullWindow, replayDev, count); DeliverDeviceEvents(w, (InternalEvent*)event, NullGrab,
NullWindow, replayDev);
} }
playmore: playmore:
for (dev = inputInfo.devices; dev; dev = dev->next) for (dev = inputInfo.devices; dev; dev = dev->next)
@ -2241,16 +2235,24 @@ FixUpEventFromWindow(
* @see DeliverFocusedEvent * @see DeliverFocusedEvent
*/ */
int int
DeliverDeviceEvents(WindowPtr pWin, xEvent *xE, GrabPtr grab, DeliverDeviceEvents(WindowPtr pWin, InternalEvent *event, GrabPtr grab,
WindowPtr stopAt, DeviceIntPtr dev, int count) WindowPtr stopAt, DeviceIntPtr dev)
{ {
Window child = None; Window child = None;
int type = xE->u.u.type; int type;
Mask filter = filters[dev->id][type]; Mask filter;
int deliveries = 0; int deliveries = 0;
OtherInputMasks *inputMasks; OtherInputMasks *inputMasks;
int mskidx = dev->id; int mskidx = dev->id;
xEvent core; 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)) if (XaceHook(XACE_SEND_ACCESS, NULL, dev, pWin, xE, count))
return 0; return 0;
@ -3362,7 +3364,7 @@ CheckDeviceGrabs(DeviceIntPtr device, DeviceEvent *event, int checkFirst)
* @param count number of events in xE. * @param count number of events in xE.
*/ */
void void
DeliverFocusedEvent(DeviceIntPtr keybd, xEvent *xE, WindowPtr window, int count) DeliverFocusedEvent(DeviceIntPtr keybd, InternalEvent *event, WindowPtr window)
{ {
DeviceIntPtr pointer; DeviceIntPtr pointer;
WindowPtr focus = keybd->focus->win; WindowPtr focus = keybd->focus->win;
@ -3370,18 +3372,25 @@ DeliverFocusedEvent(DeviceIntPtr keybd, xEvent *xE, WindowPtr window, int count)
xEvent core; xEvent core;
int deliveries = 0; 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) if (focus == FollowKeyboardWin)
focus = inputInfo.keyboard->focus->win; focus = inputInfo.keyboard->focus->win;
if (!focus) if (!focus)
return; return;
if (focus == PointerRootWin) if (focus == PointerRootWin)
{ {
DeliverDeviceEvents(window, xE, NullGrab, NullWindow, keybd, count); DeliverDeviceEvents(window, event, NullGrab, NullWindow, keybd);
return; return;
} }
if ((focus == window) || IsParent(focus, window)) if ((focus == window) || IsParent(focus, window))
{ {
if (DeliverDeviceEvents(window, xE, NullGrab, focus, keybd, count)) if (DeliverDeviceEvents(window, event, NullGrab, focus, keybd))
return; return;
} }
pointer = GetPairedDevice(keybd); 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. * @param deactivateGrab True if the device's grab should be deactivated.
*/ */
void void
DeliverGrabbedEvent(xEvent *xE, DeviceIntPtr thisDev, DeliverGrabbedEvent(InternalEvent *event, DeviceIntPtr thisDev,
Bool deactivateGrab, int count) Bool deactivateGrab)
{ {
GrabPtr grab; GrabPtr grab;
GrabInfoPtr grabinfo; GrabInfoPtr grabinfo;
int deliveries = 0; int deliveries = 0;
DeviceIntPtr dev; DeviceIntPtr dev;
xEvent *dxE, core; xEvent core;
SpritePtr pSprite = thisDev->spriteInfo->sprite; SpritePtr pSprite = thisDev->spriteInfo->sprite;
BOOL sendCore = FALSE; 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; grabinfo = &thisDev->deviceGrab;
grab = grabinfo->grab; 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 * 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. * the focus window. For pointer events, the answer is no.
*/ */
if (IsPointerEvent(xE)) if (IsPointerEvent(event))
focus = PointerRootWin; focus = PointerRootWin;
else if (thisDev->focus) else if (thisDev->focus)
{ {
@ -3454,15 +3470,15 @@ DeliverGrabbedEvent(xEvent *xE, DeviceIntPtr thisDev,
else else
focus = PointerRootWin; focus = PointerRootWin;
if (focus == PointerRootWin) if (focus == PointerRootWin)
deliveries = DeliverDeviceEvents(pSprite->win, xE, grab, deliveries = DeliverDeviceEvents(pSprite->win, event, grab,
NullWindow, thisDev, count); NullWindow, thisDev);
else if (focus && (focus == pSprite->win || else if (focus && (focus == pSprite->win ||
IsParent(focus, pSprite->win))) IsParent(focus, pSprite->win)))
deliveries = DeliverDeviceEvents(pSprite->win, xE, grab, focus, deliveries = DeliverDeviceEvents(pSprite->win, event, grab, focus,
thisDev, count); thisDev);
else if (focus) else if (focus)
deliveries = DeliverDeviceEvents(focus, xE, grab, focus, deliveries = DeliverDeviceEvents(focus, event, grab, focus,
thisDev, count); thisDev);
} }
if (!deliveries) if (!deliveries)
{ {
@ -3538,12 +3554,10 @@ DeliverGrabbedEvent(xEvent *xE, DeviceIntPtr thisDev,
} }
} }
if (deliveries && (xE->u.u.type == MotionNotify if (deliveries && (event->u.any.type == ET_Motion))
|| xE->u.u.type == DeviceMotionNotify))
thisDev->valuator->motionHintWindow = grab->window; thisDev->valuator->motionHintWindow = grab->window;
} }
if (deliveries && !deactivateGrab && if (deliveries && !deactivateGrab && event->u.any.type != ET_Motion)
(xE->u.u.type != MotionNotify && xE->u.u.type != DeviceMotionNotify))
{ {
switch (grabinfo->sync.state) switch (grabinfo->sync.state)
{ {
@ -3564,17 +3578,9 @@ DeliverGrabbedEvent(xEvent *xE, DeviceIntPtr thisDev,
case FREEZE_NEXT_EVENT: case FREEZE_NEXT_EVENT:
grabinfo->sync.state = FROZEN_WITH_EVENT; grabinfo->sync.state = FROZEN_WITH_EVENT;
FreezeThaw(thisDev, TRUE); FreezeThaw(thisDev, TRUE);
#if 0 if (!grabinfo->sync.event)
/* FIXME: Sorry, frozen grabs are broken ATM */ grabinfo->sync.event = xcalloc(1, sizeof(InternalEvent));
if (grabinfo->sync.evcount < count) *grabinfo->sync.event = *(DeviceEvent*)event;
{
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
break; break;
} }
} }

View File

@ -1067,6 +1067,8 @@ DGAProcessKeyboardEvent (ScreenPtr pScreen, dgaEvent *de, DeviceIntPtr keybd)
/* If the keyboard is actively grabbed, deliver a grabbed core event */ /* If the keyboard is actively grabbed, deliver a grabbed core event */
if (keybd->deviceGrab.grab && !keybd->deviceGrab.fromPassiveGrab) 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.type = (IEventBase - 1) + coreEquiv;
xi.u.u.detail = de->u.u.detail; xi.u.u.detail = de->u.u.detail;
xi.u.keyButtonPointer.time = de->u.event.time; 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; xi.u.keyButtonPointer.state = de->u.event.state;
((deviceKeyButtonPointer*)&xi)->deviceid = keybd->id; ((deviceKeyButtonPointer*)&xi)->deviceid = keybd->id;
DeliverGrabbedEvent (&xi, keybd, FALSE, 1); 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 the pointer is actively grabbed, deliver a grabbed core event */
if (mouse->deviceGrab.grab && !mouse->deviceGrab.fromPassiveGrab) 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.type = (IEventBase - 1 ) + coreEquiv;
xi.u.u.detail = de->u.u.detail; xi.u.u.detail = de->u.u.detail;
xi.u.keyButtonPointer.time = de->u.event.time; 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.rootY = de->u.event.dy;
xi.u.keyButtonPointer.state = de->u.event.state; xi.u.keyButtonPointer.state = de->u.event.state;
DeliverGrabbedEvent (&xi, mouse, FALSE, 1); DeliverGrabbedEvent (&xi, mouse, FALSE, 1);
#endif
} }
} }
} }

View File

@ -371,11 +371,10 @@ extern _X_EXPORT int DeliverEventsToWindow(
extern _X_EXPORT int DeliverDeviceEvents( extern _X_EXPORT int DeliverDeviceEvents(
WindowPtr /* pWin */, WindowPtr /* pWin */,
xEventPtr /* xE */, InternalEvent* /* event */,
GrabPtr /* grab */, GrabPtr /* grab */,
WindowPtr /* stopAt */, WindowPtr /* stopAt */,
DeviceIntPtr /* dev */, DeviceIntPtr /* dev */);
int /* count */);
extern _X_EXPORT void InitializeSprite( extern _X_EXPORT void InitializeSprite(
DeviceIntPtr /* pDev */, DeviceIntPtr /* pDev */,
@ -395,15 +394,13 @@ extern _X_EXPORT Bool CheckDeviceGrabs(
extern _X_EXPORT void DeliverFocusedEvent( extern _X_EXPORT void DeliverFocusedEvent(
DeviceIntPtr /* keybd */, DeviceIntPtr /* keybd */,
xEventPtr /* xE */, InternalEvent* /* event */,
WindowPtr /* window */, WindowPtr /* window */);
int /* count */);
extern _X_EXPORT void DeliverGrabbedEvent( extern _X_EXPORT void DeliverGrabbedEvent(
xEventPtr /* xE */, InternalEvent* /* event */,
DeviceIntPtr /* thisDev */, DeviceIntPtr /* thisDev */,
Bool /* deactivateGrab */, Bool /* deactivateGrab */);
int /* count */);
extern _X_EXPORT void FixKeyState( extern _X_EXPORT void FixKeyState(
DeviceEvent* /* event */, DeviceEvent* /* event */,