[PATCH 3/4 v2] Move replay-window check from ComputeFreezes to CheckDeviceGrabs.
Jamey Sharp
jamey at minilop.net
Wed Aug 11 17:51:06 PDT 2010
This just simplifies ComputeFreezes, eliminating some duplicated code
and a goto.
Signed-off-by: Jamey Sharp <jamey at minilop.net>
Cc: Peter Hutterer <peter.hutterer at who-t.net>
---
I could have sworn I tested these before sending them, but apparently I
split this out of another patch and forgot a part.
v2: (i > checkFirst) was just checking whether the preceding loop ran at
least once, in which case pWin will be non-null.
dix/events.c | 46 +++++++++++++++++++---------------------------
include/dix.h | 2 +-
2 files changed, 20 insertions(+), 28 deletions(-)
diff --git a/dix/events.c b/dix/events.c
index 51a04d5..01cec7b 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -1276,7 +1276,6 @@ static void
ComputeFreezes(void)
{
DeviceIntPtr replayDev = syncEvents.replayDev;
- int i;
WindowPtr w;
GrabPtr grab;
DeviceIntPtr dev;
@@ -1294,29 +1293,15 @@ ComputeFreezes(void)
syncEvents.replayDev = (DeviceIntPtr)NULL;
w = XYToWindow(replayDev, event->root_x, event->root_y);
- for (i = 0; i < replayDev->spriteInfo->sprite->spriteTraceGood; i++)
- {
- if (syncEvents.replayWin ==
- replayDev->spriteInfo->sprite->spriteTrace[i])
- {
- if (!CheckDeviceGrabs(replayDev, event, i+1)) {
- if (replayDev->focus && !IsPointerEvent((InternalEvent*)event))
- DeliverFocusedEvent(replayDev, (InternalEvent*)event, w);
- else
- 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, (InternalEvent*)event, w);
- else
- DeliverDeviceEvents(w, (InternalEvent*)event, NullGrab,
- NullWindow, replayDev);
+ if (!CheckDeviceGrabs(replayDev, event, syncEvents.replayWin))
+ {
+ if (replayDev->focus && !IsPointerEvent((InternalEvent*)event))
+ DeliverFocusedEvent(replayDev, (InternalEvent*)event, w);
+ else
+ DeliverDeviceEvents(w, (InternalEvent*)event, NullGrab,
+ NullWindow, replayDev);
+ }
}
-playmore:
for (dev = inputInfo.devices; dev; dev = dev->next)
{
if (!dev->deviceGrab.sync.frozen)
@@ -3611,7 +3596,7 @@ CheckPassiveGrabsOnWindow(
*/
Bool
-CheckDeviceGrabs(DeviceIntPtr device, DeviceEvent *event, int checkFirst)
+CheckDeviceGrabs(DeviceIntPtr device, DeviceEvent *event, WindowPtr ancestor)
{
int i;
WindowPtr pWin = NULL;
@@ -3629,7 +3614,15 @@ CheckDeviceGrabs(DeviceIntPtr device, DeviceEvent *event, int checkFirst)
if (device->deviceGrab.grab)
return FALSE;
- i = checkFirst;
+ i = 0;
+ if (ancestor)
+ {
+ while (i < device->spriteInfo->sprite->spriteTraceGood)
+ if (device->spriteInfo->sprite->spriteTrace[i++] == ancestor)
+ break;
+ if (i == device->spriteInfo->sprite->spriteTraceGood)
+ return FALSE;
+ }
if (focus)
{
@@ -3642,8 +3635,7 @@ CheckDeviceGrabs(DeviceIntPtr device, DeviceEvent *event, int checkFirst)
if ((focus->win == NoneWin) ||
(i >= device->spriteInfo->sprite->spriteTraceGood) ||
- ((i > checkFirst) &&
- (pWin != device->spriteInfo->sprite->spriteTrace[i-1])))
+ (pWin && pWin != device->spriteInfo->sprite->spriteTrace[i-1]))
return FALSE;
}
diff --git a/include/dix.h b/include/dix.h
index a282a08..7485e8e 100644
--- a/include/dix.h
+++ b/include/dix.h
@@ -401,7 +401,7 @@ extern _X_EXPORT void WindowHasNewCursor(
extern Bool CheckDeviceGrabs(
DeviceIntPtr /* device */,
DeviceEvent* /* event */,
- int /* checkFirst */);
+ WindowPtr /* ancestor */);
extern void DeliverFocusedEvent(
DeviceIntPtr /* keybd */,
--
1.7.0
More information about the xorg-devel
mailing list