Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(654)

Unified Diff: ui/base/touch/touch_device_linux.cc

Issue 2827803002: Make Interaction Media Features MQ dynamic on Linux. (Closed)
Patch Set: Patch for landing, added the mojo bits Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/touch/touch_device.h ('k') | ui/base/touch/touch_device_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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() {
+ 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;
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;
« no previous file with comments | « ui/base/touch/touch_device.h ('k') | ui/base/touch/touch_device_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698