Skip to content

Commit

Permalink
End physically active touches when device is disabled
Browse files Browse the repository at this point in the history
Otherwise:

* We can't end the touches while device is disabled
* New touches after enabling the device may erroneously be mapped to old
  logical touches

Signed-off-by: Chase Douglas <[email protected]>
Reviewed-by: Peter Hutterer <[email protected]>
Signed-off-by: Peter Hutterer <[email protected]>
  • Loading branch information
Chase Douglas authored and whot committed Oct 19, 2012
1 parent a69429a commit 3b67cd2
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions dix/devices.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ DisableDevice(DeviceIntPtr dev, BOOL sendevent)
if (*prev != dev)
return FALSE;

TouchEndPhysicallyActiveTouches(dev);
ReleaseButtonsAndKeys(dev);
SyncRemoveDeviceIdleTime(dev->idle_counter);
dev->idle_counter = NULL;
Expand Down
28 changes: 28 additions & 0 deletions dix/touch.c
Original file line number Diff line number Diff line change
Expand Up @@ -1029,3 +1029,31 @@ TouchAcceptReject(ClientPtr client, DeviceIntPtr dev, int mode,

return TouchListenerAcceptReject(dev, ti, i, mode);
}

/**
* End physically active touches for a device.
*/
void
TouchEndPhysicallyActiveTouches(DeviceIntPtr dev)
{
InternalEvent *eventlist = InitEventList(GetMaximumEventsNum());
int i;

OsBlockSignals();
mieqProcessInputEvents();
for (i = 0; i < dev->last.num_touches; i++) {
DDXTouchPointInfoPtr ddxti = dev->last.touches + i;

if (ddxti->active) {
int j;
int nevents = GetTouchEvents(eventlist, dev, ddxti->ddx_id,
XI_TouchEnd, 0, NULL);

for (j = 0; j < nevents; j++)
mieqProcessDeviceEvent(dev, eventlist + j, NULL);
}
}
OsReleaseSignals();

FreeEventList(eventlist, GetMaximumEventsNum());
}
1 change: 1 addition & 0 deletions include/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,7 @@ 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);
extern void TouchEndPhysicallyActiveTouches(DeviceIntPtr dev);

/* misc event helpers */
extern Mask GetEventMask(DeviceIntPtr dev, xEvent *ev, InputClientsPtr clients);
Expand Down

0 comments on commit 3b67cd2

Please sign in to comment.