diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2011-12-05 15:39:01 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2011-12-05 15:39:37 +1000 |
commit | 1dc1a1fa1d0f723b622b2b4dba6c435e7997a7da (patch) | |
tree | 467348729ed523c91ab31f091f2b862984299da1 | |
parent | 5b26430104dab04880379a399c7f9864650480e4 (diff) |
When accepting a grab, set a flag so we don't re-accept all the time
With the server fix in place, we now keep getting events when we accept a
grab (rightly-so), so the TouchEnd doesn't arrive until the physical end of
the touch.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | multitouch.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/multitouch.c b/multitouch.c index 481a1e0..f787107 100644 --- a/multitouch.c +++ b/multitouch.c @@ -46,8 +46,13 @@ struct touchpoint { Bool owned; }; +enum TouchFlags { + TFLAG_ACCEPTED = (1 << 0), +}; + struct grabpoint { enum TouchState state; + int flags; uint32_t touchid; double startx, starty; /* x/y of TouchBegin */ double x, y; /* last recorded x/y position */ @@ -467,6 +472,7 @@ static void handle_grabbed_event(struct multitouch *mt, XIDeviceEvent *event) grab->starty = event->event_y; grab->grab_window = event->event; grab->nevents = 0; + grab->flags = 0; break; } else if (event->evtype != XI_TouchBegin) { if (grab->state != TSTATE_END && grab->touchid == event->detail) @@ -486,7 +492,7 @@ static void handle_grabbed_event(struct multitouch *mt, XIDeviceEvent *event) paint_grabs(mt); expose(mt, 0, 0, mt->width, mt->height); - if (grab->state != TSTATE_END && + if (grab->state != TSTATE_END && (grab->flags & TFLAG_ACCEPTED) == 0 && (event->evtype == XI_TouchEnd || (grab->nevents > 100 && event->evtype != XI_TouchOwnership))) { int mode = XIAcceptTouch; @@ -495,8 +501,12 @@ static void handle_grabbed_event(struct multitouch *mt, XIDeviceEvent *event) { mode = XIRejectTouch; modestr = "Reject"; + grab->state = TSTATE_END; } - grab->state = TSTATE_END; + + if (mode == XIAcceptTouch) + grab->flags |= TFLAG_ACCEPTED; + msg("%s touch %d on %s.\n", modestr, event->detail, window_to_name(mt, event->event)); XIAllowTouchEvents(mt->dpy, event->deviceid, event->detail, event->event, mode); |