Commit 2bb2eeb0 authored by Chase Douglas's avatar Chase Douglas Committed by Peter Hutterer

Split out helper function TouchListenerAcceptReject()

This will be used for accepting and rejecting touches in the future.
Signed-off-by: default avatarChase Douglas <chase.douglas@canonical.com>
Reviewed-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 447fe7a1)
parent a37539e7
......@@ -1272,18 +1272,11 @@ ComputeFreezes(void)
event->root_x, event->root_y);
if (!CheckDeviceGrabs(replayDev, event, syncEvents.replayWin)) {
if (IsTouchEvent((InternalEvent *) event)) {
InternalEvent *events = InitEventList(GetMaximumEventsNum());
int i, nev;
TouchPointInfoPtr ti =
TouchFindByClientID(replayDev, event->touchid);
BUG_WARN(!ti);
nev =
GetTouchOwnershipEvents(events, replayDev, ti,
XIRejectTouch,
ti->listeners[0].listener, 0);
for (i = 0; i < nev; i++)
mieqProcessDeviceEvent(replayDev, events + i, NULL);
ProcessInputEvents();
TouchListenerAcceptReject(replayDev, ti, 0, XIRejectTouch);
}
else if (replayDev->focus &&
!IsPointerEvent((InternalEvent *) event))
......
......@@ -959,16 +959,49 @@ TouchListenerGone(XID resource)
FreeEventList(events, GetMaximumEventsNum());
}
int
TouchListenerAcceptReject(DeviceIntPtr dev, TouchPointInfoPtr ti, int listener,
int mode)
{
InternalEvent *events;
int nev;
int i;
if (listener > 0) {
if (mode == XIRejectTouch)
TouchRejected(dev, ti, ti->listeners[listener].listener, NULL);
else
ti->listeners[listener].state = LISTENER_EARLY_ACCEPT;
return Success;
}
events = InitEventList(GetMaximumEventsNum());
if (!events) {
BUG_WARN_MSG(TRUE, "Failed to allocate touch ownership events\n");
return BadAlloc;
}
nev = GetTouchOwnershipEvents(events, dev, ti, mode,
ti->listeners[0].listener, 0);
BUG_WARN_MSG(nev == 0, "Failed to get touch ownership events\n");
for (i = 0; i < nev; i++)
mieqProcessDeviceEvent(dev, events + i, NULL);
ProcessInputEvents();
FreeEventList(events, GetMaximumEventsNum());
return nev ? Success : BadMatch;
}
int
TouchAcceptReject(ClientPtr client, DeviceIntPtr dev, int mode,
uint32_t touchid, Window grab_window, XID *error)
{
TouchPointInfoPtr ti;
int nev, i;
InternalEvent *events = InitEventList(GetMaximumEventsNum());
if (!events)
return BadAlloc;
int i;
if (!dev->touch) {
*error = dev->id;
......@@ -989,24 +1022,5 @@ TouchAcceptReject(ClientPtr client, DeviceIntPtr dev, int mode,
if (i == ti->num_listeners)
return BadAccess;
if (i > 0) {
if (mode == XIRejectTouch)
TouchRejected(dev, ti, ti->listeners[i].listener, NULL);
else
ti->listeners[i].state = LISTENER_EARLY_ACCEPT;
return Success;
}
nev = GetTouchOwnershipEvents(events, dev, ti, mode,
ti->listeners[0].listener, 0);
if (nev == 0)
return BadAlloc;
for (i = 0; i < nev; i++)
mieqProcessDeviceEvent(dev, events + i, NULL);
ProcessInputEvents();
FreeEventList(events, GetMaximumEventsNum());
return Success;
return TouchListenerAcceptReject(dev, ti, i, mode);
}
......@@ -572,6 +572,8 @@ extern int TouchConvertToPointerEvent(const InternalEvent *ev,
extern int TouchGetPointerEventType(const InternalEvent *ev);
extern void TouchRemovePointerGrab(DeviceIntPtr dev);
extern void TouchListenerGone(XID resource);
extern int TouchListenerAcceptReject(DeviceIntPtr dev, TouchPointInfoPtr ti,
int listener, int mode);
extern int TouchAcceptReject(ClientPtr client, DeviceIntPtr dev, int mode,
uint32_t touchid, Window grab_window, XID *error);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment