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

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

Issue 781753005: Pointer/hover media query support: platform-dependent changes #2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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_ozone.cc ('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 18f6968deea3b1fc2a762751610ad7e43f5e4a0d..91d2bf99f8932bc03cd63d1e40be8e9d7eb02371 100644
--- a/ui/base/touch/touch_device_win.cc
+++ b/ui/base/touch/touch_device_win.cc
@@ -3,6 +3,7 @@
// 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>
@@ -22,22 +23,51 @@ int MaxTouchPoints() {
}
int GetAvailablePointerTypes() {
- // TODO(mustaq): Replace the stub below
- return POINTER_TYPE_NONE;
+ int available_pointer_types = 0;
+ if (IsTouchDevicePresent())
+ available_pointer_types |= POINTER_TYPE_COARSE;
+ if (GetSystemMetrics(SM_MOUSEPRESENT) != 0 &&
+ GetSystemMetrics(SM_CMOUSEBUTTONS) > 0)
+ available_pointer_types |= POINTER_TYPE_FINE;
+
+ // When no types are found, assume there's a POINTER_TYPE_NONE
+ if (available_pointer_types == 0)
+ available_pointer_types = POINTER_TYPE_NONE;
+
+ return available_pointer_types;
}
PointerType GetPrimaryPointerType() {
- // TODO(mustaq): Replace the stub below
+ int available_pointer_types = GetAvailablePointerTypes();
+ if (available_pointer_types & POINTER_TYPE_FINE)
+ return POINTER_TYPE_FINE;
+ if (available_pointer_types & POINTER_TYPE_COARSE)
+ return POINTER_TYPE_COARSE;
+ DCHECK(available_pointer_types & POINTER_TYPE_NONE);
return POINTER_TYPE_NONE;
}
int GetAvailableHoverTypes() {
- // TODO(mustaq): Replace the stub below
- return HOVER_TYPE_NONE;
+ int available_hover_types = 0;
+ if (IsTouchDevicePresent())
+ available_hover_types |= HOVER_TYPE_ON_DEMAND;
+ if (GetSystemMetrics(SM_MOUSEPRESENT) != 0)
+ available_hover_types |= HOVER_TYPE_HOVER;
+
+ // When no types are found, assume there's a HOVER_TYPE_NONE
+ if (available_hover_types == 0)
+ available_hover_types = HOVER_TYPE_NONE;
+
+ return available_hover_types;
}
HoverType GetPrimaryHoverType() {
- // TODO(mustaq): Replace the stub below
+ int available_hover_types = GetAvailableHoverTypes();
+ if (available_hover_types & HOVER_TYPE_HOVER)
+ return HOVER_TYPE_HOVER;
+ if (available_hover_types & HOVER_TYPE_ON_DEMAND)
+ return HOVER_TYPE_ON_DEMAND;
+ DCHECK(available_hover_types & HOVER_TYPE_NONE);
return HOVER_TYPE_NONE;
}
« no previous file with comments | « ui/base/touch/touch_device_ozone.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698