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

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

Issue 2737123003: Fix 'pointer', 'any-pointer', 'hover' and 'any-hover' value on detachable/convertible devices. (Closed)
Patch Set: Fix 'pointer', 'any-pointer', 'hover' and 'any-hover' value on detachable/convertible devices. Created 3 years, 9 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 | « base/win/win_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/touch/touch_device_win.cc
diff --git a/ui/base/touch/touch_device_win.cc b/ui/base/touch/touch_device_win.cc
index 0e1655f40b2a5568f1e42abc2ef401eb2fb0a535..6c350cb1fa8476d549f17b5f8de02340e32cc2ff 100644
--- a/ui/base/touch/touch_device_win.cc
+++ b/ui/base/touch/touch_device_win.cc
@@ -2,10 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/base/touch/touch_device.h"
#include "base/logging.h"
-#include "base/win/windows_version.h"
-#include <windows.h>
+#include "base/win/win_util.h"
+#include "ui/base/touch/touch_device.h"
grt (UTC plus 2) 2017/03/09 09:39:17 since this is conceptually the .h corresponding to
namespace ui {
@@ -17,29 +16,49 @@ bool IsTouchDevicePresent() {
((value & NID_INTEGRATED_TOUCH) || (value & NID_EXTERNAL_TOUCH));
}
+// The following method logic is as follow :
+// - On versions prior to Windows 8 it will always return POINTER_TYPE_FINE
+// and/or POINTER_TYPE_COARSE (if the device has a touch screen).
+// - If the device is a detachable/convertible win8/10 device and the keyboard/
+// trackpad is detached/flipped it will always return POINTER_TYPE_COARSE.
+// It does not cover the case where an external mouse/keyboard is connected
+// while the device is used as a tablet. This is because Windows doesn't provide
+// us a reliable way to detect keyboard/mouse presence with
+// GetSystemMetrics(SM_MOUSEPRESENT).
+// - If the device doesn't have a touch screen it will return POINTER_TYPE_FINE.
+// In the rare cases (this is Microsoft documentation) where
+// GetSystemMetrics(SM_MOUSEPRESENT) returns 0 we will return POINTER_TYPE_NONE.
+// - If the device has a touch screen the available pointer devices are
+// POINTER_TYPE_FINE and POINTER_TYPE_COARSE.
int GetAvailablePointerTypes() {
- int available_pointer_types = 0;
+ // IsTabletDevice guarantees us that :
+ // - The device has a touch screen.
+ // - It is used as a tablet which means that it has no keyboard connected.
+ // On Windows 10 it means that it is verifying with ConvertibleSlateMode.
+ if (base::win::IsTabletDevice(nullptr))
+ return POINTER_TYPE_COARSE;
+
+ if (GetSystemMetrics(SM_MOUSEPRESENT) == 0)
+ return POINTER_TYPE_NONE;
+
+ int available_pointer_types = POINTER_TYPE_FINE;
if (IsTouchDevicePresent())
available_pointer_types |= POINTER_TYPE_COARSE;
- if (GetSystemMetrics(SM_MOUSEPRESENT) != 0 &&
- GetSystemMetrics(SM_CMOUSEBUTTONS) > 0)
- available_pointer_types |= POINTER_TYPE_FINE;
-
- if (available_pointer_types == 0)
- available_pointer_types = POINTER_TYPE_NONE;
return available_pointer_types;
}
+// This method follows the same logic as above but with hover types.
int GetAvailableHoverTypes() {
- int available_hover_types = 0;
+ if (base::win::IsTabletDevice(nullptr))
+ return HOVER_TYPE_ON_DEMAND;
+
+ if (GetSystemMetrics(SM_MOUSEPRESENT) == 0)
+ return HOVER_TYPE_NONE;
+
+ int available_hover_types = HOVER_TYPE_HOVER;
if (IsTouchDevicePresent())
available_hover_types |= HOVER_TYPE_ON_DEMAND;
- if (GetSystemMetrics(SM_MOUSEPRESENT) != 0)
- available_hover_types |= HOVER_TYPE_HOVER;
-
- if (available_hover_types == 0)
- available_hover_types = HOVER_TYPE_NONE;
return available_hover_types;
}
« no previous file with comments | « base/win/win_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698