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; | |
66 std::vector<int> device_ids; | 65 std::vector<int> device_ids; |
67 int devid; | 66 for (const base::StringPiece& dev : |
68 base::SplitString(touch_devices, ',', &devs); | 67 base::SplitStringPiece(touch_devices, ",", base::TRIM_WHITESPACE, |
69 for (std::vector<std::string>::iterator iter = devs.begin(); | 68 base::SPLIT_WANT_ALL)) { |
70 iter != devs.end(); ++iter) { | 69 int devid; |
71 if (base::StringToInt(*iter, reinterpret_cast<int*>(&devid))) | 70 if (base::StringToInt(dev, &devid)) |
72 device_ids.push_back(devid); | 71 device_ids.push_back(devid); |
73 else | 72 else |
74 DLOG(WARNING) << "Invalid touch-device id: " << *iter; | 73 DLOG(WARNING) << "Invalid touch-device id: " << dev.as_string(); |
75 } | 74 } |
76 ui::TouchFactory::GetInstance()->SetTouchDeviceList(device_ids); | 75 ui::TouchFactory::GetInstance()->SetTouchDeviceList(device_ids); |
77 } | 76 } |
78 } | 77 } |
79 | 78 |
80 void TouchFactory::UpdateDeviceList(Display* display) { | 79 void TouchFactory::UpdateDeviceList(Display* display) { |
81 // Detect touch devices. | 80 // Detect touch devices. |
82 touch_device_lookup_.reset(); | 81 touch_device_lookup_.reset(); |
83 touch_device_list_.clear(); | 82 touch_device_list_.clear(); |
84 touchscreen_ids_.clear(); | 83 touchscreen_ids_.clear(); |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 std::find_if(touchscreens.begin(), touchscreens.end(), | 313 std::find_if(touchscreens.begin(), touchscreens.end(), |
315 [device_id](const TouchscreenDevice& touchscreen) { | 314 [device_id](const TouchscreenDevice& touchscreen) { |
316 return touchscreen.id == device_id; | 315 return touchscreen.id == device_id; |
317 }); | 316 }); |
318 // Internal displays will have a vid and pid of 0. Ignore them. | 317 // Internal displays will have a vid and pid of 0. Ignore them. |
319 if (it != touchscreens.end() && it->vendor_id && it->product_id) | 318 if (it != touchscreens.end() && it->vendor_id && it->product_id) |
320 touchscreen_ids_.insert(std::make_pair(it->vendor_id, it->product_id)); | 319 touchscreen_ids_.insert(std::make_pair(it->vendor_id, it->product_id)); |
321 } | 320 } |
322 | 321 |
323 } // namespace ui | 322 } // namespace ui |
OLD | NEW |