summaryrefslogtreecommitdiff
path: root/dix
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2009-05-27 15:47:12 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2009-05-28 15:02:35 +1000
commita25f248fc3bd0375d91ca8a44320200d445ecfbb (patch)
treed73b23749564cede4bc67eaec7b40fc9563d4ee2 /dix
parenta7e23a79c1fc429aedbf9b6c0e78b1c8d7e02238 (diff)
Xi: Send Enter or Leave events with XIPassive(Un)grabNotify
If a passive enter or focus in grab activates, send additional enter or focus events with mode XIPassiveGrabNotify to the grabbing client. Likewise, if the grab deactivates, send additional leave or focus out events. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'dix')
-rw-r--r--dix/enterleave.c3
-rw-r--r--dix/events.c35
2 files changed, 27 insertions, 11 deletions
diff --git a/dix/enterleave.c b/dix/enterleave.c
index eadcc4558..d7f5f58bc 100644
--- a/dix/enterleave.c
+++ b/dix/enterleave.c
@@ -609,7 +609,8 @@ DoEnterLeaveEvents(DeviceIntPtr pDev,
if (fromWin == toWin)
return;
- CoreEnterLeaveEvents(pDev, fromWin, toWin, mode);
+ if (mode != XINotifyPassiveGrab && mode != XINotifyPassiveUngrab)
+ CoreEnterLeaveEvents(pDev, fromWin, toWin, mode);
DeviceEnterLeaveEvents(pDev, fromWin, toWin, mode);
}
diff --git a/dix/events.c b/dix/events.c
index 5d22016f7..503a58d76 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -2635,8 +2635,9 @@ XYToWindow(DeviceIntPtr pDev, int x, int y)
* @returns TRUE if the device has been grabbed, or FALSE otherwise.
*/
BOOL
-ActivateFocusInGrab(DeviceIntPtr dev, WindowPtr win)
+ActivateFocusInGrab(DeviceIntPtr dev, WindowPtr old, WindowPtr win)
{
+ BOOL rc = FALSE;
DeviceEvent event;
if (dev->deviceGrab.grab &&
@@ -2646,6 +2647,7 @@ ActivateFocusInGrab(DeviceIntPtr dev, WindowPtr win)
if (dev->deviceGrab.grab->window == win ||
IsParent(dev->deviceGrab.grab->window, win))
return FALSE;
+ DoEnterLeaveEvents(dev, old, win, XINotifyPassiveUngrab);
(*dev->deviceGrab.DeactivateGrab)(dev);
}
@@ -2660,18 +2662,22 @@ ActivateFocusInGrab(DeviceIntPtr dev, WindowPtr win)
event.deviceid = dev->id;
event.sourceid = dev->id;
event.detail.button = 0;
- return CheckPassiveGrabsOnWindow(win, dev, &event, FALSE);
+ rc = CheckPassiveGrabsOnWindow(win, dev, &event, FALSE);
+ if (rc)
+ DoEnterLeaveEvents(dev, old, win, XINotifyPassiveUngrab);
+ return rc;
}
/**
- * Ungrab a currently Enter grabbed device and grab the deice for the given
+ * Ungrab a currently Enter grabbed device and grab the device for the given
* window.
*
* @returns TRUE if the device has been grabbed, or FALSE otherwise.
*/
static BOOL
-ActivateEnterGrab(DeviceIntPtr dev, WindowPtr win)
+ActivateEnterGrab(DeviceIntPtr dev, WindowPtr old, WindowPtr win)
{
+ BOOL rc = FALSE;
DeviceEvent event;
if (dev->deviceGrab.grab &&
@@ -2681,6 +2687,7 @@ ActivateEnterGrab(DeviceIntPtr dev, WindowPtr win)
if (dev->deviceGrab.grab->window == win ||
IsParent(dev->deviceGrab.grab->window, win))
return FALSE;
+ DoEnterLeaveEvents(dev, old, win, XINotifyPassiveUngrab);
(*dev->deviceGrab.DeactivateGrab)(dev);
}
@@ -2692,7 +2699,11 @@ ActivateEnterGrab(DeviceIntPtr dev, WindowPtr win)
event.deviceid = dev->id;
event.sourceid = dev->id;
event.detail.button = 0;
- return CheckPassiveGrabsOnWindow(win, dev, &event, FALSE);
+ rc = CheckPassiveGrabsOnWindow(win, dev, &event, FALSE);
+ if (rc)
+ DoEnterLeaveEvents(dev, old, win, XINotifyPassiveGrab);
+
+ return rc;
}
/**
@@ -2795,7 +2806,7 @@ CheckMotion(DeviceEvent *ev, DeviceIntPtr pDev)
UpdateCurrentTimeIf();
if (prevSpriteWin != NullWindow) {
- if (!ActivateEnterGrab(pDev, newSpriteWin))
+ if (!ActivateEnterGrab(pDev, prevSpriteWin, newSpriteWin))
DoEnterLeaveEvents(pDev, prevSpriteWin,
newSpriteWin, NotifyNormal);
}
@@ -4267,6 +4278,10 @@ DeviceEnterLeaveEvent(
int btlen, len, i;
DeviceIntPtr kbd;
+ if ((mode == XINotifyPassiveGrab && type == XI_Leave) ||
+ (mode == XINotifyPassiveUngrab && type == XI_Enter))
+ return;
+
btlen = (mouse->button) ? (mouse->button->numButtons + 7)/8 : 0;
btlen = (btlen + 3)/4;
len = sizeof(xXIEnterEvent) + btlen * 4;
@@ -4426,11 +4441,11 @@ SetInputFocus(
mode = (dev->deviceGrab.grab) ? NotifyWhileGrabbed : NotifyNormal;
if (focus->win == FollowKeyboardWin)
{
- if (!ActivateFocusInGrab(dev, focusWin))
+ if (!ActivateFocusInGrab(dev, keybd->focus->win, focusWin))
DoFocusEvents(dev, keybd->focus->win, focusWin, mode);
} else
{
- if (!ActivateFocusInGrab(dev, focusWin))
+ if (!ActivateFocusInGrab(dev, focus->win, focusWin))
DoFocusEvents(dev, focus->win, focusWin, mode);
}
focus->time = time;
@@ -5413,13 +5428,13 @@ DeleteWindowFromAnyEvents(WindowPtr pWin, Bool freeResources)
|| clients[CLIENT_ID(parent->drawable.id)]->clientGone
#endif
);
- if (!ActivateFocusInGrab(keybd, parent))
+ if (!ActivateFocusInGrab(keybd, pWin, parent))
DoFocusEvents(keybd, pWin, parent, focusEventMode);
focus->win = parent;
focus->revert = RevertToNone;
break;
case RevertToPointerRoot:
- if (!ActivateFocusInGrab(keybd, PointerRootWin))
+ if (!ActivateFocusInGrab(keybd, pWin, PointerRootWin))
DoFocusEvents(keybd, pWin, PointerRootWin, focusEventMode);
focus->win = PointerRootWin;
focus->traceGood = 0;