summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stone <daniel@fooishbar.org>2010-12-07 11:48:14 +0000
committerChase Douglas <chase.douglas@canonical.com>2011-01-05 13:17:32 -0500
commit097b6f3be2256b8b31fc548555182131cc0f9387 (patch)
tree5ab2574b1fc05ff4740366671d1aca8944d0e2a6
parent11e5655c512cbce09f76161e80608c562608a9df (diff)
Input: Make CheckPassiveGrabsOnWindow return grab, export
Change CheckPassiveGrabsOnWindow to return the GrabPtr it used (or NULL if none) rather than a boolean, and export it. Also add an additional boolean 'activate' parameter; use TRUE for existing behaviour, or FALSE to only find the grab and then return it. This will be used in forthcoming touch patches to find the grabs, rather than open-coding same. Signed-off-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--dix/events.c32
-rw-r--r--include/dix.h7
2 files changed, 22 insertions, 17 deletions
diff --git a/dix/events.c b/dix/events.c
index f1b787258..1ca33388e 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -209,10 +209,6 @@ static void CheckPhysLimits(DeviceIntPtr pDev,
Bool generateEvents,
Bool confineToScreen,
ScreenPtr pScreen);
-static Bool CheckPassiveGrabsOnWindow(WindowPtr pWin,
- DeviceIntPtr device,
- DeviceEvent *event,
- BOOL checkCore);
/** Key repeat hack. Do not use but in TryClientEvents */
extern BOOL EventIsKeyRepeat(xEvent *event);
@@ -2648,7 +2644,7 @@ ActivateFocusInGrab(DeviceIntPtr dev, WindowPtr old, WindowPtr win)
event.deviceid = dev->id;
event.sourceid = dev->id;
event.detail.button = 0;
- rc = CheckPassiveGrabsOnWindow(win, dev, &event, FALSE);
+ rc = (CheckPassiveGrabsOnWindow(win, dev, &event, FALSE, TRUE) != NULL);
if (rc)
DoEnterLeaveEvents(dev, dev->id, old, win, XINotifyPassiveUngrab);
return rc;
@@ -2685,10 +2681,9 @@ ActivateEnterGrab(DeviceIntPtr dev, WindowPtr old, WindowPtr win)
event.deviceid = dev->id;
event.sourceid = dev->id;
event.detail.button = 0;
- rc = CheckPassiveGrabsOnWindow(win, dev, &event, FALSE);
+ rc = (CheckPassiveGrabsOnWindow(win, dev, &event, FALSE, TRUE) != NULL);
if (rc)
DoEnterLeaveEvents(dev, dev->id, old, win, XINotifyPassiveGrab);
-
return rc;
}
@@ -3359,20 +3354,23 @@ BorderSizeNotEmpty(DeviceIntPtr pDev, WindowPtr pWin)
/**
* "CheckPassiveGrabsOnWindow" checks to see if the event passed in causes a
* passive grab set on the window to be activated.
- * If a passive grab is activated, the event will be delivered to the client.
+ * If activate is true and a passive grab is found, it will be activated,
+ * and the event will be delivered to the client.
*
* @param pWin The window that may be subject to a passive grab.
* @param device Device that caused the event.
* @param event The current device event.
* @param checkCore Check for core grabs too.
+ * @param activate If a grab is found, activate it and deliver the event.
*/
-static Bool
+GrabPtr
CheckPassiveGrabsOnWindow(
WindowPtr pWin,
DeviceIntPtr device,
DeviceEvent *event,
- BOOL checkCore)
+ BOOL checkCore,
+ BOOL activate)
{
SpritePtr pSprite = device->spriteInfo->sprite;
GrabPtr grab = wPassiveGrabs(pWin);
@@ -3384,7 +3382,7 @@ CheckPassiveGrabsOnWindow(
int match = 0;
if (!grab)
- return FALSE;
+ return NULL;
/* Fill out the grab details, but leave the type for later before
* comparing */
tempGrab.window = pWin;
@@ -3498,6 +3496,8 @@ CheckPassiveGrabsOnWindow(
continue;
}
+ if (!activate)
+ return grab;
if (match & CORE_MATCH)
{
@@ -3555,10 +3555,10 @@ CheckPassiveGrabsOnWindow(
if (match & (XI_MATCH | XI2_MATCH))
free(xE); /* on core match xE == &core */
- return TRUE;
+ return grab;
}
}
- return FALSE;
+ return NULL;
#undef CORE_MATCH
#undef XI_MATCH
#undef XI2_MATCH
@@ -3616,8 +3616,7 @@ CheckDeviceGrabs(DeviceIntPtr device, DeviceEvent *event, int checkFirst)
for (; i < focus->traceGood; i++)
{
pWin = focus->trace[i];
- if (pWin->optional &&
- CheckPassiveGrabsOnWindow(pWin, device, event, sendCore))
+ if (CheckPassiveGrabsOnWindow(pWin, device, event, sendCore, TRUE))
return TRUE;
}
@@ -3631,8 +3630,7 @@ CheckDeviceGrabs(DeviceIntPtr device, DeviceEvent *event, int checkFirst)
for (; i < device->spriteInfo->sprite->spriteTraceGood; i++)
{
pWin = device->spriteInfo->sprite->spriteTrace[i];
- if (pWin->optional &&
- CheckPassiveGrabsOnWindow(pWin, device, event, sendCore))
+ if (CheckPassiveGrabsOnWindow(pWin, device, event, sendCore, TRUE))
return TRUE;
}
diff --git a/include/dix.h b/include/dix.h
index a282a080f..0e435c6b9 100644
--- a/include/dix.h
+++ b/include/dix.h
@@ -372,6 +372,13 @@ extern void AllowSome(
extern void ReleaseActiveGrabs(
ClientPtr client);
+extern GrabPtr CheckPassiveGrabsOnWindow(
+ WindowPtr /* pWin */,
+ DeviceIntPtr /* device */,
+ DeviceEvent * /* event */,
+ BOOL /* checkCore */,
+ BOOL /* activate */);
+
extern _X_EXPORT int DeliverEventsToWindow(
DeviceIntPtr /* pWin */,
WindowPtr /* pWin */,