Chromium Code Reviews| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 for (int i = 0; i < dev_list.count; i++) { | 94 for (int i = 0; i < dev_list.count; i++) { |
| 95 if (dev_list[i].type) { | 95 if (dev_list[i].type) { |
| 96 XScopedString devtype(XGetAtomName(display, dev_list[i].type)); | 96 char* devtype = XGetAtomName(display, dev_list[i].type); |
| 97 if (devtype.string() && !strcmp(devtype.string(), XI_TOUCHSCREEN)) { | 97 if (devtype && !strcmp(devtype, XI_TOUCHSCREEN)) { |
| 98 touch_device_lookup_[dev_list[i].id] = true; | 98 touch_device_lookup_[dev_list[i].id] = true; |
| 99 touch_device_list_[dev_list[i].id] = false; | 99 touch_device_list_[dev_list[i].id] = false; |
| 100 touch_device_available_ = true; | 100 touch_device_available_ = true; |
| 101 } | 101 } |
| 102 XFree(devtype); | |
| 102 } | 103 } |
|
sadrul
2013/10/31 15:30:36
Can you do this like the following instead:
dev
| |
| 103 } | 104 } |
| 104 #endif | 105 #endif |
| 105 | 106 |
| 106 // Instead of asking X for the list of devices all the time, let's maintain a | 107 // Instead of asking X for the list of devices all the time, let's maintain a |
| 107 // list of pointer devices we care about. | 108 // list of pointer devices we care about. |
| 108 // It should not be necessary to select for slave devices. XInput2 provides | 109 // It should not be necessary to select for slave devices. XInput2 provides |
| 109 // enough information to the event callback to decide which slave device | 110 // enough information to the event callback to decide which slave device |
| 110 // triggered the event, thus decide whether the 'pointer event' is a | 111 // triggered the event, thus decide whether the 'pointer event' is a |
| 111 // 'mouse event' or a 'touch event'. | 112 // 'mouse event' or a 'touch event'. |
| 112 // However, on some desktops, some events from a master pointer are | 113 // However, on some desktops, some events from a master pointer are |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 iter != devices.end(); ++iter) { | 246 iter != devices.end(); ++iter) { |
| 246 DCHECK(*iter < touch_device_lookup_.size()); | 247 DCHECK(*iter < touch_device_lookup_.size()); |
| 247 touch_device_lookup_[*iter] = true; | 248 touch_device_lookup_[*iter] = true; |
| 248 touch_device_list_[*iter] = true; | 249 touch_device_list_[*iter] = true; |
| 249 } | 250 } |
| 250 touch_device_available_ = true; | 251 touch_device_available_ = true; |
| 251 touch_events_disabled_ = false; | 252 touch_events_disabled_ = false; |
| 252 } | 253 } |
| 253 | 254 |
| 254 } // namespace ui | 255 } // namespace ui |
| OLD | NEW |