Chromium Code Reviews| Index: ui/events/devices/x11/touch_factory_x11.cc |
| diff --git a/ui/events/devices/x11/touch_factory_x11.cc b/ui/events/devices/x11/touch_factory_x11.cc |
| index 4201fa04bf3bdc35136b8400ab443280a7210df9..09aa717bb8ba101e44eb9933720bf39ba5354a07 100644 |
| --- a/ui/events/devices/x11/touch_factory_x11.cc |
| +++ b/ui/events/devices/x11/touch_factory_x11.cc |
| @@ -160,7 +160,21 @@ bool TouchFactory::ShouldProcessXI2Event(XEvent* xev) { |
| if (event->evtype == XI_TouchBegin || |
| event->evtype == XI_TouchUpdate || |
| event->evtype == XI_TouchEnd) { |
| - return !touch_events_disabled_ && IsTouchDevice(xiev->deviceid); |
| + // Since SetupXI2ForXWindow() selects events from all devices, for a |
| + // touchscreen attached to a master pointer device, X11 sends two |
| + // events for each touch: one from the slave (deviceid == the id of |
| + // the touchscreen device), and one from the master (deviceid == the |
| + // id of the master pointer device). Instead of processing both |
| + // events, discard the event that comes from the slave, and only |
| + // allow processing the event coming from the master. |
| + // For a 'floating' touchscreen device, X11 sends only one event for |
| + // each touch, with both deviceid and sourceid set to the id of the |
| + // touchscreen device. |
| + bool is_from_slave_device = !touch_device_list_[xiev->deviceid] && |
| + (xiev->sourceid == xiev->deviceid); |
|
sadrul
2015/03/11 07:43:49
Just one more nit:
bool is_from_master_or_float
|
| + return !touch_events_disabled_ && |
| + IsTouchDevice(xiev->deviceid) && |
| + !is_from_slave_device; |
| } |
| // Make sure only key-events from the virtual core keyboard are processed. |