OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/base/touch/touch_device.h" | 5 #include "ui/base/touch/touch_device.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ui/events/devices/device_data_manager.h" | 8 #include "ui/events/devices/device_data_manager.h" |
9 #include "ui/events/devices/x11/touch_factory_x11.h" | |
10 | 9 |
11 namespace ui { | 10 namespace ui { |
12 | 11 |
13 bool IsTouchDevicePresent() { | 12 bool IsTouchDevicePresent() { |
14 return ui::DeviceDataManager::GetInstance()->touchscreen_devices().size() > 0; | 13 return ui::DeviceDataManager::GetInstance()->touchscreen_devices().size() > 0; |
15 } | 14 } |
16 | 15 |
17 int MaxTouchPoints() { | 16 int MaxTouchPoints() { |
18 return ui::TouchFactory::GetInstance()->GetMaxTouchPoints(); | 17 int max_touch = -1; |
| 18 const std::vector<ui::TouchscreenDevice>& touchscreen_devices = |
| 19 ui::DeviceDataManager::GetInstance()->touchscreen_devices(); |
| 20 for (const ui::TouchscreenDevice& device : touchscreen_devices) { |
| 21 if (device.touch_points > max_touch) |
| 22 max_touch = device.touch_points; |
| 23 } |
| 24 return max_touch; |
19 } | 25 } |
20 | 26 |
21 // TODO(mustaq@chromium.org): Use mouse detection logic. crbug.com/440503 | 27 // TODO(mustaq@chromium.org): Use mouse detection logic. crbug.com/440503 |
22 int GetAvailablePointerTypes() { | 28 int GetAvailablePointerTypes() { |
23 // Assume a mouse is there | 29 // Assume a mouse is there |
24 int available_pointer_types = POINTER_TYPE_FINE; | 30 int available_pointer_types = POINTER_TYPE_FINE; |
25 if (IsTouchDevicePresent()) | 31 if (IsTouchDevicePresent()) |
26 available_pointer_types |= POINTER_TYPE_COARSE; | 32 available_pointer_types |= POINTER_TYPE_COARSE; |
27 | 33 |
28 DCHECK(available_pointer_types); | 34 DCHECK(available_pointer_types); |
(...skipping 25 matching lines...) Expand all Loading... |
54 int available_hover_types = GetAvailableHoverTypes(); | 60 int available_hover_types = GetAvailableHoverTypes(); |
55 if (available_hover_types & HOVER_TYPE_HOVER) | 61 if (available_hover_types & HOVER_TYPE_HOVER) |
56 return HOVER_TYPE_HOVER; | 62 return HOVER_TYPE_HOVER; |
57 if (available_hover_types & HOVER_TYPE_ON_DEMAND) | 63 if (available_hover_types & HOVER_TYPE_ON_DEMAND) |
58 return HOVER_TYPE_ON_DEMAND; | 64 return HOVER_TYPE_ON_DEMAND; |
59 DCHECK_EQ(available_hover_types, HOVER_TYPE_NONE); | 65 DCHECK_EQ(available_hover_types, HOVER_TYPE_NONE); |
60 return HOVER_TYPE_NONE; | 66 return HOVER_TYPE_NONE; |
61 } | 67 } |
62 | 68 |
63 } // namespace ui | 69 } // namespace ui |
OLD | NEW |