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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 // static | 55 // static |
56 void TouchFactory::SetTouchDeviceListFromCommandLine() { | 56 void TouchFactory::SetTouchDeviceListFromCommandLine() { |
57 // Get a list of pointer-devices that should be treated as touch-devices. | 57 // Get a list of pointer-devices that should be treated as touch-devices. |
58 // This is primarily used for testing/debugging touch-event processing when a | 58 // This is primarily used for testing/debugging touch-event processing when a |
59 // touch-device isn't available. | 59 // touch-device isn't available. |
60 std::string touch_devices = | 60 std::string touch_devices = |
61 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 61 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
62 switches::kTouchDevices); | 62 switches::kTouchDevices); |
63 | 63 |
64 if (!touch_devices.empty()) { | 64 if (!touch_devices.empty()) { |
| 65 std::vector<std::string> devs; |
65 std::vector<int> device_ids; | 66 std::vector<int> device_ids; |
66 for (const base::StringPiece& dev : | 67 int devid; |
67 base::SplitStringPiece(touch_devices, ",", base::TRIM_WHITESPACE, | 68 base::SplitString(touch_devices, ',', &devs); |
68 base::SPLIT_WANT_ALL)) { | 69 for (std::vector<std::string>::iterator iter = devs.begin(); |
69 int devid; | 70 iter != devs.end(); ++iter) { |
70 if (base::StringToInt(dev, &devid)) | 71 if (base::StringToInt(*iter, reinterpret_cast<int*>(&devid))) |
71 device_ids.push_back(devid); | 72 device_ids.push_back(devid); |
72 else | 73 else |
73 DLOG(WARNING) << "Invalid touch-device id: " << dev.as_string(); | 74 DLOG(WARNING) << "Invalid touch-device id: " << *iter; |
74 } | 75 } |
75 ui::TouchFactory::GetInstance()->SetTouchDeviceList(device_ids); | 76 ui::TouchFactory::GetInstance()->SetTouchDeviceList(device_ids); |
76 } | 77 } |
77 } | 78 } |
78 | 79 |
79 void TouchFactory::UpdateDeviceList(Display* display) { | 80 void TouchFactory::UpdateDeviceList(Display* display) { |
80 // Detect touch devices. | 81 // Detect touch devices. |
81 touch_device_lookup_.reset(); | 82 touch_device_lookup_.reset(); |
82 touch_device_list_.clear(); | 83 touch_device_list_.clear(); |
83 touchscreen_ids_.clear(); | 84 touchscreen_ids_.clear(); |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 std::find_if(touchscreens.begin(), touchscreens.end(), | 314 std::find_if(touchscreens.begin(), touchscreens.end(), |
314 [device_id](const TouchscreenDevice& touchscreen) { | 315 [device_id](const TouchscreenDevice& touchscreen) { |
315 return touchscreen.id == device_id; | 316 return touchscreen.id == device_id; |
316 }); | 317 }); |
317 // Internal displays will have a vid and pid of 0. Ignore them. | 318 // Internal displays will have a vid and pid of 0. Ignore them. |
318 if (it != touchscreens.end() && it->vendor_id && it->product_id) | 319 if (it != touchscreens.end() && it->vendor_id && it->product_id) |
319 touchscreen_ids_.insert(std::make_pair(it->vendor_id, it->product_id)); | 320 touchscreen_ids_.insert(std::make_pair(it->vendor_id, it->product_id)); |
320 } | 321 } |
321 | 322 |
322 } // namespace ui | 323 } // namespace ui |
OLD | NEW |