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

Unified Diff: base/win/win_util.cc

Issue 1838993002: Export the tablet mode checking function from base. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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: base/win/win_util.cc
diff --git a/base/win/win_util.cc b/base/win/win_util.cc
index 87bde159cd5ac0420d3043cd87797cacfaf3f133..e9f817fc6ed8e7386f2b438dfff70b20bf86e3b4 100644
--- a/base/win/win_util.cc
+++ b/base/win/win_util.cc
@@ -114,12 +114,14 @@ POWER_PLATFORM_ROLE GetPlatformRole() {
return PowerDeterminePlatformRoleEx(POWER_PLATFORM_ROLE_V2);
}
+} // namespace
+
// Uses the Windows 10 WRL API's to query the current system state. The API's
// we are using in the function below are supported in Win32 apps as per msdn.
// It looks like the API implementation is buggy at least on Surface 4 causing
// it to always return UserInteractionMode_Touch which as per documentation
// indicates tablet mode.
-bool IsWindows10TabletDevice() {
+bool IsWindows10TabletMode(HWND hwnd) {
if (GetVersion() < VERSION_WIN10)
return false;
@@ -178,7 +180,7 @@ bool IsWindows10TabletDevice() {
// Avoid using GetForegroundWindow here and pass in the HWND of the window
// intiating the request to display the keyboard.
hr = view_settings_interop->GetForWindow(
- ::GetForegroundWindow(),
+ hwnd,
__uuidof(ABI::Windows::UI::ViewManagement::IUIViewSettings),
view_settings.ReceiveVoid());
if (FAILED(hr))
@@ -190,8 +192,6 @@ bool IsWindows10TabletDevice() {
return mode == ABI::Windows::UI::ViewManagement::UserInteractionMode_Touch;
}
-} // namespace
-
// Returns true if a physical keyboard is detected on Windows 8 and up.
// Uses the Setup APIs to enumerate the attached keyboards and returns true
// if the keyboard count is 1 or more.. While this will work in most cases
@@ -475,7 +475,7 @@ bool IsTabletDevice(std::string* reason) {
return false;
}
- if (IsWindows10TabletDevice())
+ if (IsWindows10TabletMode(::GetForegroundWindow()))
return true;
if (GetSystemMetrics(SM_MAXIMUMTOUCHES) == 0) {
« 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