OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/events/x/touch_factory_x11.h" | 5 #include "ui/events/x/touch_factory_x11.h" |
6 | 6 |
7 #include <X11/Xatom.h> | 7 #include <X11/Xatom.h> |
8 #include <X11/cursorfont.h> | 8 #include <X11/cursorfont.h> |
9 #include <X11/extensions/XInput.h> | 9 #include <X11/extensions/XInput.h> |
10 #include <X11/extensions/XInput2.h> | 10 #include <X11/extensions/XInput2.h> |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 XIEvent* event = static_cast<XIEvent*>(xev->xcookie.data); | 167 XIEvent* event = static_cast<XIEvent*>(xev->xcookie.data); |
168 XIDeviceEvent* xiev = reinterpret_cast<XIDeviceEvent*>(event); | 168 XIDeviceEvent* xiev = reinterpret_cast<XIDeviceEvent*>(event); |
169 | 169 |
170 #if defined(USE_XI2_MT) | 170 #if defined(USE_XI2_MT) |
171 if (event->evtype == XI_TouchBegin || | 171 if (event->evtype == XI_TouchBegin || |
172 event->evtype == XI_TouchUpdate || | 172 event->evtype == XI_TouchUpdate || |
173 event->evtype == XI_TouchEnd) { | 173 event->evtype == XI_TouchEnd) { |
174 return !touch_events_disabled_ && IsTouchDevice(xiev->deviceid); | 174 return !touch_events_disabled_ && IsTouchDevice(xiev->deviceid); |
175 } | 175 } |
176 #endif | 176 #endif |
| 177 // Make sure only key-events from the master device are processed. |
| 178 if (event->evtype == XI_KeyPress || event->evtype == XI_KeyRelease) |
| 179 return xiev->deviceid == xiev->sourceid; |
| 180 |
177 if (event->evtype != XI_ButtonPress && | 181 if (event->evtype != XI_ButtonPress && |
178 event->evtype != XI_ButtonRelease && | 182 event->evtype != XI_ButtonRelease && |
179 event->evtype != XI_Motion) | 183 event->evtype != XI_Motion) |
180 return true; | 184 return true; |
181 | 185 |
182 if (!pointer_device_lookup_[xiev->deviceid]) | 186 if (!pointer_device_lookup_[xiev->deviceid]) |
183 return false; | 187 return false; |
184 | 188 |
185 return IsTouchDevice(xiev->deviceid) ? !touch_events_disabled_ : true; | 189 return IsTouchDevice(xiev->deviceid) ? !touch_events_disabled_ : true; |
186 } | 190 } |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 if (ptr[0] || ptr[1]) | 322 if (ptr[0] || ptr[1]) |
319 touchscreen_ids_.insert(std::make_pair(ptr[0], ptr[1])); | 323 touchscreen_ids_.insert(std::make_pair(ptr[0], ptr[1])); |
320 } | 324 } |
321 XFree(prop_return); | 325 XFree(prop_return); |
322 } | 326 } |
323 | 327 |
324 XCloseDevice(display, device); | 328 XCloseDevice(display, device); |
325 } | 329 } |
326 | 330 |
327 } // namespace ui | 331 } // namespace ui |
OLD | NEW |