dix: pass the sourceid around for enter/leave events.

The sourceid for enter/leave events as a result of pointer motion is the ID
of the slave device. The sourceid for those as a result of a grab activating
is the device itself.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2009-07-29 16:34:28 +10:00
parent c299b2228f
commit 46ac9f9241
3 changed files with 34 additions and 23 deletions

View File

@ -218,6 +218,7 @@ CommonAncestor(
*/
static void
DeviceEnterNotifies(DeviceIntPtr dev,
int sourceid,
WindowPtr ancestor,
WindowPtr child,
int mode,
@ -227,8 +228,8 @@ DeviceEnterNotifies(DeviceIntPtr dev,
if (ancestor == parent)
return;
DeviceEnterNotifies(dev, ancestor, parent, mode, detail);
DeviceEnterLeaveEvent(dev, XI_Enter, mode, detail, parent,
DeviceEnterNotifies(dev, sourceid, ancestor, parent, mode, detail);
DeviceEnterLeaveEvent(dev, sourceid, XI_Enter, mode, detail, parent,
child->drawable.id);
}
@ -323,6 +324,7 @@ CoreLeaveNotifies(DeviceIntPtr dev,
*/
static void
DeviceLeaveNotifies(DeviceIntPtr dev,
int sourceid,
WindowPtr child,
WindowPtr ancestor,
int mode,
@ -334,7 +336,7 @@ DeviceLeaveNotifies(DeviceIntPtr dev,
return;
for (win = child->parent; win != ancestor; win = win->parent)
{
DeviceEnterLeaveEvent(dev, XI_Leave, mode, detail, win,
DeviceEnterLeaveEvent(dev, sourceid, XI_Leave, mode, detail, win,
child->drawable.id);
child = win;
}
@ -562,30 +564,31 @@ CoreEnterLeaveEvents(DeviceIntPtr dev,
static void
DeviceEnterLeaveEvents(DeviceIntPtr dev,
int sourceid,
WindowPtr from,
WindowPtr to,
int mode)
{
if (IsParent(from, to))
{
DeviceEnterLeaveEvent(dev, XI_Leave, mode, NotifyInferior, from, None);
DeviceEnterNotifies(dev, from, to, mode, NotifyVirtual);
DeviceEnterLeaveEvent(dev, XI_Enter, mode, NotifyAncestor, to, None);
DeviceEnterLeaveEvent(dev, sourceid, XI_Leave, mode, NotifyInferior, from, None);
DeviceEnterNotifies(dev, sourceid, from, to, mode, NotifyVirtual);
DeviceEnterLeaveEvent(dev, sourceid, XI_Enter, mode, NotifyAncestor, to, None);
}
else if (IsParent(to, from))
{
DeviceEnterLeaveEvent(dev, XI_Leave, mode, NotifyAncestor, from, None);
DeviceLeaveNotifies(dev, from, to, mode, NotifyVirtual);
DeviceEnterLeaveEvent(dev, XI_Enter, mode, NotifyInferior, to, None);
DeviceEnterLeaveEvent(dev, sourceid, XI_Leave, mode, NotifyAncestor, from, None);
DeviceLeaveNotifies(dev, sourceid, from, to, mode, NotifyVirtual);
DeviceEnterLeaveEvent(dev, sourceid, XI_Enter, mode, NotifyInferior, to, None);
}
else
{ /* neither from nor to is descendent of the other */
WindowPtr common = CommonAncestor(to, from);
/* common == NullWindow ==> different screens */
DeviceEnterLeaveEvent(dev, XI_Leave, mode, NotifyNonlinear, from, None);
DeviceLeaveNotifies(dev, from, common, mode, NotifyNonlinearVirtual);
DeviceEnterNotifies(dev, common, to, mode, NotifyNonlinearVirtual);
DeviceEnterLeaveEvent(dev, XI_Enter, mode, NotifyNonlinear, to, None);
DeviceEnterLeaveEvent(dev, sourceid, XI_Leave, mode, NotifyNonlinear, from, None);
DeviceLeaveNotifies(dev, sourceid, from, common, mode, NotifyNonlinearVirtual);
DeviceEnterNotifies(dev, sourceid, common, to, mode, NotifyNonlinearVirtual);
DeviceEnterLeaveEvent(dev, sourceid, XI_Enter, mode, NotifyNonlinear, to, None);
}
}
@ -598,6 +601,7 @@ DeviceEnterLeaveEvents(DeviceIntPtr dev,
*/
void
DoEnterLeaveEvents(DeviceIntPtr pDev,
int sourceid,
WindowPtr fromWin,
WindowPtr toWin,
int mode)
@ -610,7 +614,7 @@ DoEnterLeaveEvents(DeviceIntPtr pDev,
if (mode != XINotifyPassiveGrab && mode != XINotifyPassiveUngrab)
CoreEnterLeaveEvents(pDev, fromWin, toWin, mode);
DeviceEnterLeaveEvents(pDev, fromWin, toWin, mode);
DeviceEnterLeaveEvents(pDev, sourceid, fromWin, toWin, mode);
}
/**

View File

@ -33,6 +33,7 @@
extern void DoEnterLeaveEvents(
DeviceIntPtr pDev,
int sourceid,
WindowPtr fromWin,
WindowPtr toWin,
int mode
@ -64,6 +65,7 @@ extern void CoreEnterLeaveEvent(DeviceIntPtr mouse,
WindowPtr pWin,
Window child);
extern void DeviceEnterLeaveEvent(DeviceIntPtr mouse,
int sourceid,
int type,
int mode,
int detail,

View File

@ -1474,7 +1474,7 @@ ActivatePointerGrab(DeviceIntPtr mouse, GrabPtr grab,
mouse->spriteInfo->sprite->hotPhys.y = 0;
ConfineCursorToWindow(mouse, grab->confineTo, FALSE, TRUE);
}
DoEnterLeaveEvents(mouse, oldWin, grab->window, NotifyGrab);
DoEnterLeaveEvents(mouse, mouse->id, oldWin, grab->window, NotifyGrab);
mouse->valuator->motionHintWindow = NullWindow;
if (syncEvents.playingEvents)
grabinfo->grabTime = syncEvents.time;
@ -1511,7 +1511,7 @@ DeactivatePointerGrab(DeviceIntPtr mouse)
if (dev->deviceGrab.sync.other == grab)
dev->deviceGrab.sync.other = NullGrab;
}
DoEnterLeaveEvents(mouse, grab->window,
DoEnterLeaveEvents(mouse, mouse->id, grab->window,
mouse->spriteInfo->sprite->win, NotifyUngrab);
if (grab->confineTo)
ConfineCursorToWindow(mouse, RootWindow(mouse), FALSE, FALSE);
@ -2585,7 +2585,7 @@ ActivateFocusInGrab(DeviceIntPtr dev, WindowPtr old, WindowPtr win)
if (dev->deviceGrab.grab->window == win ||
IsParent(dev->deviceGrab.grab->window, win))
return FALSE;
DoEnterLeaveEvents(dev, old, win, XINotifyPassiveUngrab);
DoEnterLeaveEvents(dev, dev->id, old, win, XINotifyPassiveUngrab);
(*dev->deviceGrab.DeactivateGrab)(dev);
}
@ -2602,7 +2602,7 @@ ActivateFocusInGrab(DeviceIntPtr dev, WindowPtr old, WindowPtr win)
event.detail.button = 0;
rc = CheckPassiveGrabsOnWindow(win, dev, &event, FALSE);
if (rc)
DoEnterLeaveEvents(dev, old, win, XINotifyPassiveUngrab);
DoEnterLeaveEvents(dev, dev->id, old, win, XINotifyPassiveUngrab);
return rc;
}
@ -2625,7 +2625,7 @@ ActivateEnterGrab(DeviceIntPtr dev, WindowPtr old, WindowPtr win)
if (dev->deviceGrab.grab->window == win ||
IsParent(dev->deviceGrab.grab->window, win))
return FALSE;
DoEnterLeaveEvents(dev, old, win, XINotifyPassiveUngrab);
DoEnterLeaveEvents(dev, dev->id, old, win, XINotifyPassiveUngrab);
(*dev->deviceGrab.DeactivateGrab)(dev);
}
@ -2639,7 +2639,7 @@ ActivateEnterGrab(DeviceIntPtr dev, WindowPtr old, WindowPtr win)
event.detail.button = 0;
rc = CheckPassiveGrabsOnWindow(win, dev, &event, FALSE);
if (rc)
DoEnterLeaveEvents(dev, old, win, XINotifyPassiveGrab);
DoEnterLeaveEvents(dev, dev->id, old, win, XINotifyPassiveGrab);
return rc;
}
@ -2740,12 +2740,16 @@ CheckMotion(DeviceEvent *ev, DeviceIntPtr pDev)
if (newSpriteWin != prevSpriteWin)
{
if (!ev)
int sourceid;
if (!ev) {
UpdateCurrentTimeIf();
sourceid = pDev->id; /* when from WindowsRestructured */
} else
sourceid = ev->sourceid;
if (prevSpriteWin != NullWindow) {
if (!ActivateEnterGrab(pDev, prevSpriteWin, newSpriteWin))
DoEnterLeaveEvents(pDev, prevSpriteWin,
DoEnterLeaveEvents(pDev, sourceid, prevSpriteWin,
newSpriteWin, NotifyNormal);
}
/* set pSprite->win after ActivateEnterGrab, otherwise
@ -4216,6 +4220,7 @@ CoreEnterLeaveEvent(
void
DeviceEnterLeaveEvent(
DeviceIntPtr mouse,
int sourceid,
int type,
int mode,
int detail,
@ -4245,7 +4250,7 @@ DeviceEnterLeaveEvent(
event->detail = detail;
event->time = currentTime.milliseconds;
event->deviceid = mouse->id;
event->sourceid = 0; /*XXX */
event->sourceid = sourceid;
event->mode = mode;
event->root_x = FP1616(mouse->spriteInfo->sprite->hot.x, 0);
event->root_y = FP1616(mouse->spriteInfo->sprite->hot.y, 0);