Index: ui/base/touch/touch_device_linux.cc |
diff --git a/ui/base/touch/touch_device_linux.cc b/ui/base/touch/touch_device_linux.cc |
index 3ebf53c3a2fda51106671eeaa8e86a7a1fd3ff4d..d9ef84f2e6f6d4a56b1a8af7385210cfa281dd84 100644 |
--- a/ui/base/touch/touch_device_linux.cc |
+++ b/ui/base/touch/touch_device_linux.cc |
@@ -15,27 +15,44 @@ bool IsTouchDevicePresent() { |
return !InputDeviceManager::GetInstance()->GetTouchscreenDevices().empty(); |
} |
-// TODO(mustaq@chromium.org): Use mouse detection logic. crbug.com/495634 |
+bool isMouseOrTouchpadPresent() { |
sadrul
2017/05/17 15:32:17
IsMouseOrTouchpadPresent()
|
+ InputDeviceManager* input_manager = InputDeviceManager::GetInstance(); |
+ for (const ui::InputDevice& device : input_manager->GetTouchpadDevices()) { |
+ if (device.enabled) |
+ return true; |
+ } |
+ // We didn't find a touchpad then let's look if there is a mouse connected. |
+ for (const ui::InputDevice& device : input_manager->GetMouseDevices()) { |
+ if (device.enabled) |
+ return true; |
+ } |
+ return false; |
+} |
+ |
+} // namespace |
+ |
int GetAvailablePointerTypes() { |
- // Assume a mouse is there |
- int available_pointer_types = POINTER_TYPE_FINE; |
+ int available_pointer_types = 0; |
+ if (isMouseOrTouchpadPresent()) |
+ available_pointer_types |= POINTER_TYPE_FINE; |
+ |
if (IsTouchDevicePresent()) |
available_pointer_types |= POINTER_TYPE_COARSE; |
+ if (available_pointer_types == 0) |
+ available_pointer_types = POINTER_TYPE_NONE; |
+ |
DCHECK(available_pointer_types); |
return available_pointer_types; |
} |
-// TODO(mustaq@chromium.org): Use mouse detection logic. crbug.com/495634 |
int GetAvailableHoverTypes() { |
- int available_hover_types = HOVER_TYPE_HOVER; |
- if (IsTouchDevicePresent()) |
- available_hover_types |= HOVER_TYPE_NONE; |
+ int available_hover_types = HOVER_TYPE_NONE; |
+ if (isMouseOrTouchpadPresent()) |
+ available_hover_types |= HOVER_TYPE_HOVER; |
sadrul
2017/05/17 15:32:17
One sidenote: having both NONE and HOVER bits set
mustaq
2017/05/17 16:46:54
I agree this looks confusing but available_hover_t
|
return available_hover_types; |
} |
-} // namespace |
- |
TouchScreensAvailability GetTouchScreensAvailability() { |
if (!IsTouchDevicePresent()) |
return TouchScreensAvailability::NONE; |
@@ -56,10 +73,6 @@ int MaxTouchPoints() { |
return max_touch; |
} |
-std::pair<int, int> GetAvailablePointerAndHoverTypes() { |
- return std::make_pair(GetAvailablePointerTypes(), GetAvailableHoverTypes()); |
-} |
- |
PointerType GetPrimaryPointerType(int available_pointer_types) { |
if (available_pointer_types & POINTER_TYPE_FINE) |
return POINTER_TYPE_FINE; |