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..32596c624e98994f520c171a2ac6c4fe35436427 100644 |
--- a/ui/events/devices/x11/touch_factory_x11.cc |
+++ b/ui/events/devices/x11/touch_factory_x11.cc |
@@ -160,7 +160,22 @@ 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_master_or_float = touch_device_list_[xiev->deviceid]; |
+ bool is_from_slave_device = !is_from_master_or_float |
+ && xiev->sourceid == xiev->deviceid; |
+ return !touch_events_disabled_ && |
+ IsTouchDevice(xiev->deviceid) && |
+ !is_from_slave_device; |
} |
// Make sure only key-events from the virtual core keyboard are processed. |