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/devices/x11/touch_factory_x11.h" | 5 #include "ui/events/devices/x11/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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 } | 153 } |
154 | 154 |
155 bool TouchFactory::ShouldProcessXI2Event(XEvent* xev) { | 155 bool TouchFactory::ShouldProcessXI2Event(XEvent* xev) { |
156 DCHECK_EQ(GenericEvent, xev->type); | 156 DCHECK_EQ(GenericEvent, xev->type); |
157 XIEvent* event = static_cast<XIEvent*>(xev->xcookie.data); | 157 XIEvent* event = static_cast<XIEvent*>(xev->xcookie.data); |
158 XIDeviceEvent* xiev = reinterpret_cast<XIDeviceEvent*>(event); | 158 XIDeviceEvent* xiev = reinterpret_cast<XIDeviceEvent*>(event); |
159 | 159 |
160 if (event->evtype == XI_TouchBegin || | 160 if (event->evtype == XI_TouchBegin || |
161 event->evtype == XI_TouchUpdate || | 161 event->evtype == XI_TouchUpdate || |
162 event->evtype == XI_TouchEnd) { | 162 event->evtype == XI_TouchEnd) { |
163 return !touch_events_disabled_ && IsTouchDevice(xiev->deviceid); | 163 return !touch_events_disabled_ && |
164 IsTouchDevice(xiev->deviceid) && | |
165 // For Linux, both master and attached-slaved devices send the same | |
166 // touch events, we will use the ones from attached-slave device. | |
167 (xiev->sourceid == xiev->deviceid); | |
sadrul
2015/03/05 09:38:52
We actually want to process only the event that is
lanwei
2015/03/07 04:22:50
check if the device is attached-slave by looking a
| |
164 } | 168 } |
165 | 169 |
166 // Make sure only key-events from the virtual core keyboard are processed. | 170 // Make sure only key-events from the virtual core keyboard are processed. |
167 if (event->evtype == XI_KeyPress || event->evtype == XI_KeyRelease) { | 171 if (event->evtype == XI_KeyPress || event->evtype == XI_KeyRelease) { |
168 return (virtual_core_keyboard_device_ < 0) || | 172 return (virtual_core_keyboard_device_ < 0) || |
169 (virtual_core_keyboard_device_ == xiev->deviceid); | 173 (virtual_core_keyboard_device_ == xiev->deviceid); |
170 } | 174 } |
171 | 175 |
172 if (event->evtype != XI_ButtonPress && | 176 if (event->evtype != XI_ButtonPress && |
173 event->evtype != XI_ButtonRelease && | 177 event->evtype != XI_ButtonRelease && |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
324 if (ptr[0] || ptr[1]) | 328 if (ptr[0] || ptr[1]) |
325 touchscreen_ids_.insert(std::make_pair(ptr[0], ptr[1])); | 329 touchscreen_ids_.insert(std::make_pair(ptr[0], ptr[1])); |
326 } | 330 } |
327 XFree(prop_return); | 331 XFree(prop_return); |
328 } | 332 } |
329 | 333 |
330 XCloseDevice(display, device); | 334 XCloseDevice(display, device); |
331 } | 335 } |
332 | 336 |
333 } // namespace ui | 337 } // namespace ui |
OLD | NEW |