| 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/cursorfont.h> | 7 #include <X11/cursorfont.h> |
| 8 #include <X11/extensions/XInput.h> | 8 #include <X11/extensions/XInput.h> |
| 9 #include <X11/extensions/XInput2.h> | 9 #include <X11/extensions/XInput2.h> |
| 10 #include <X11/extensions/XIproto.h> | 10 #include <X11/extensions/XIproto.h> |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 84 |
| 85 #if !defined(USE_XI2_MT) | 85 #if !defined(USE_XI2_MT) |
| 86 // NOTE: The new API for retrieving the list of devices (XIQueryDevice) does | 86 // NOTE: The new API for retrieving the list of devices (XIQueryDevice) does |
| 87 // not provide enough information to detect a touch device. As a result, the | 87 // not provide enough information to detect a touch device. As a result, the |
| 88 // old version of query function (XListInputDevices) is used instead. | 88 // old version of query function (XListInputDevices) is used instead. |
| 89 // If XInput2 is not supported, this will return null (with count of -1) so | 89 // If XInput2 is not supported, this will return null (with count of -1) so |
| 90 // we assume there cannot be any touch devices. | 90 // we assume there cannot be any touch devices. |
| 91 // With XI2.1 or older, we allow only single touch devices. | 91 // With XI2.1 or older, we allow only single touch devices. |
| 92 XDeviceList dev_list = | 92 XDeviceList dev_list = |
| 93 DeviceListCacheX::GetInstance()->GetXDeviceList(display); | 93 DeviceListCacheX::GetInstance()->GetXDeviceList(display); |
| 94 Atom xi_touchscreen = XInternAtom(display, XI_TOUCHSCREEN, false); |
| 94 for (int i = 0; i < dev_list.count; i++) { | 95 for (int i = 0; i < dev_list.count; i++) { |
| 95 if (dev_list[i].type) { | 96 if (dev_list[i].type == xi_touchscreen) { |
| 96 XScopedString devtype(XGetAtomName(display, dev_list[i].type)); | 97 touch_device_lookup_[dev_list[i].id] = true; |
| 97 if (devtype.string() && !strcmp(devtype.string(), XI_TOUCHSCREEN)) { | 98 touch_device_list_[dev_list[i].id] = false; |
| 98 touch_device_lookup_[dev_list[i].id] = true; | 99 touch_device_available_ = true; |
| 99 touch_device_list_[dev_list[i].id] = false; | |
| 100 touch_device_available_ = true; | |
| 101 } | |
| 102 } | 100 } |
| 103 } | 101 } |
| 104 #endif | 102 #endif |
| 105 | 103 |
| 106 // Instead of asking X for the list of devices all the time, let's maintain a | 104 // Instead of asking X for the list of devices all the time, let's maintain a |
| 107 // list of pointer devices we care about. | 105 // list of pointer devices we care about. |
| 108 // It should not be necessary to select for slave devices. XInput2 provides | 106 // It should not be necessary to select for slave devices. XInput2 provides |
| 109 // enough information to the event callback to decide which slave device | 107 // enough information to the event callback to decide which slave device |
| 110 // triggered the event, thus decide whether the 'pointer event' is a | 108 // triggered the event, thus decide whether the 'pointer event' is a |
| 111 // 'mouse event' or a 'touch event'. | 109 // 'mouse event' or a 'touch event'. |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 iter != devices.end(); ++iter) { | 243 iter != devices.end(); ++iter) { |
| 246 DCHECK(*iter < touch_device_lookup_.size()); | 244 DCHECK(*iter < touch_device_lookup_.size()); |
| 247 touch_device_lookup_[*iter] = true; | 245 touch_device_lookup_[*iter] = true; |
| 248 touch_device_list_[*iter] = true; | 246 touch_device_list_[*iter] = true; |
| 249 } | 247 } |
| 250 touch_device_available_ = true; | 248 touch_device_available_ = true; |
| 251 touch_events_disabled_ = false; | 249 touch_events_disabled_ = false; |
| 252 } | 250 } |
| 253 | 251 |
| 254 } // namespace ui | 252 } // namespace ui |
| OLD | NEW |