Chromium Code Reviews| Index: ui/events/x/touch_factory_x11.cc |
| diff --git a/ui/events/x/touch_factory_x11.cc b/ui/events/x/touch_factory_x11.cc |
| index 62f6c89dab7956fd4632e18bd73f307eff8068fd..8257594d3de5852ea506228652f9cf741c0dce63 100644 |
| --- a/ui/events/x/touch_factory_x11.cc |
| +++ b/ui/events/x/touch_factory_x11.cc |
| @@ -8,6 +8,7 @@ |
| #include <X11/extensions/XInput.h> |
| #include <X11/extensions/XInput2.h> |
| #include <X11/extensions/XIproto.h> |
| +#include <X11/Xatom.h> |
| #include "base/basictypes.h" |
| #include "base/command_line.h" |
| @@ -81,6 +82,7 @@ void TouchFactory::UpdateDeviceList(Display* display) { |
| touch_device_available_ = false; |
| touch_device_lookup_.reset(); |
| touch_device_list_.clear(); |
| + touchscreen_ids_.clear(); |
| max_touch_points_ = -1; |
| #if !defined(USE_XI2_MT) |
| @@ -127,6 +129,7 @@ void TouchFactory::UpdateDeviceList(Display* display) { |
| for (int k = 0; k < devinfo->num_classes; ++k) { |
| XIAnyClassInfo* xiclassinfo = devinfo->classes[k]; |
| if (xiclassinfo->type == XITouchClass) { |
| + CacheTouchscreenIds(display, devinfo->deviceid); |
| XITouchClassInfo* tci = |
| reinterpret_cast<XITouchClassInfo *>(xiclassinfo); |
| // Only care direct touch device (such as touch screen) right now |
| @@ -268,4 +271,29 @@ void TouchFactory::SetPointerDeviceForTest( |
| } |
| } |
| +void TouchFactory::CacheTouchscreenIds(Display* display, int id) { |
| + XDevice* device = XOpenDevice(display, id); |
| + Atom actual_type_return; |
| + int actual_format_return; |
| + unsigned long nitems_return; |
| + unsigned long bytes_after_return; |
| + unsigned char *prop_return; |
| + |
| + if (XGetDeviceProperty(display, device, kDeviceProductIdAtom, 0, 2, |
| + False, XA_INTEGER, &actual_type_return, |
| + &actual_format_return, &nitems_return, |
| + &bytes_after_return, &prop_return) == Success) { |
| + // XA_INTEGER, which results in an actual_format_return of 32, implies that |
| + // the returned data is an array of longs. See the description of |
| + // |prop_return| in `man XGetDeviceProperty` for details. |
| + long* ptr = reinterpret_cast<long*>(prop_return); |
| + // Internal displays will have a vid and pid of 0. Ignore them. |
| + if (ptr[0] || ptr[1]) |
| + touchscreen_ids_.insert(std::make_pair(ptr[0], ptr[1])); |
|
sadrul
2013/12/12 18:22:19
How do you interpret these numbers?
tdresser
2013/12/12 19:05:01
Comment added.
|
| + XFree(prop_return); |
| + } |
| + |
| + XCloseDevice(display, device); |
| +} |
| + |
| } // namespace ui |