summaryrefslogtreecommitdiffstats
path: root/base/win
diff options
context:
space:
mode:
authorcpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-13 18:36:27 +0000
committercpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-13 18:36:27 +0000
commit030582a38995eb4b86bedb45d6f05edc0ce59812 (patch)
treeade5ca70d2a06989466ef7c3154e32cd08d28091 /base/win
parent9394042fcd13abd50189f844f5fa84ce2f72b9e8 (diff)
downloadchromium_src-030582a38995eb4b86bedb45d6f05edc0ce59812.zip
chromium_src-030582a38995eb4b86bedb45d6f05edc0ce59812.tar.gz
chromium_src-030582a38995eb4b86bedb45d6f05edc0ce59812.tar.bz2
Add tablet heuristic detection
Useful for win8 metro launching BUG=141032 TEST=see bug Review URL: https://chromiumcodereview.appspot.com/10909206 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@156589 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/win')
-rw-r--r--base/win/win_util.cc10
-rw-r--r--base/win/win_util.h5
2 files changed, 15 insertions, 0 deletions
diff --git a/base/win/win_util.cc b/base/win/win_util.cc
index 37aae27..569de06 100644
--- a/base/win/win_util.cc
+++ b/base/win/win_util.cc
@@ -218,6 +218,16 @@ bool ShouldCrashOnProcessDetach() {
return g_crash_on_process_detach;
}
+bool IsMachineATablet() {
+ if (base::win::GetVersion() < base::win::VERSION_WIN7)
+ return false;
+ // TODO(ananta): Add keyboard detection logic if it can be made reliable.
+ const int kPenInput = NID_INTEGRATED_PEN | NID_EXTERNAL_PEN;
+ const int kMultiTouch = NID_INTEGRATED_TOUCH | NID_MULTI_INPUT | NID_READY;
+ int sm = GetSystemMetrics(SM_DIGITIZER);
+ return ((sm & kMultiTouch) == kMultiTouch) && ((sm & kPenInput) == 0);
+}
+
} // namespace win
} // namespace base
diff --git a/base/win/win_util.h b/base/win/win_util.h
index 51dfbd6..5a5a20a 100644
--- a/base/win/win_util.h
+++ b/base/win/win_util.h
@@ -105,6 +105,11 @@ BASE_EXPORT bool ReadCommandFromAutoRun(HKEY root_key,
BASE_EXPORT void SetShouldCrashOnProcessDetach(bool crash);
BASE_EXPORT bool ShouldCrashOnProcessDetach();
+// A tablet by this definition is something that has integrated multi-touch
+// but is not also pen-enabled. For example a Thinkpad X220 tablet is not
+// considered a tabled while a Samsum 700T tablet is.
+BASE_EXPORT bool IsMachineATablet();
+
// Get the size of a struct up to and including the specified member.
// This is necessary to set compatible struct sizes for different versions
// of certain Windows APIs (e.g. SystemParametersInfo).