OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/base/touch/touch_device.h" | 5 #include "ui/base/touch/touch_device.h" |
6 #include "base/logging.h" | |
6 #include "base/win/windows_version.h" | 7 #include "base/win/windows_version.h" |
7 #include <windows.h> | 8 #include <windows.h> |
8 | 9 |
9 namespace ui { | 10 namespace ui { |
10 | 11 |
11 bool IsTouchDevicePresent() { | 12 bool IsTouchDevicePresent() { |
12 int value = GetSystemMetrics(SM_DIGITIZER); | 13 int value = GetSystemMetrics(SM_DIGITIZER); |
13 return (value & NID_READY) && | 14 return (value & NID_READY) && |
14 ((value & NID_INTEGRATED_TOUCH) || (value & NID_EXTERNAL_TOUCH)); | 15 ((value & NID_INTEGRATED_TOUCH) || (value & NID_EXTERNAL_TOUCH)); |
15 } | 16 } |
16 | 17 |
17 int MaxTouchPoints() { | 18 int MaxTouchPoints() { |
18 if (!IsTouchDevicePresent()) | 19 if (!IsTouchDevicePresent()) |
19 return 0; | 20 return 0; |
20 | 21 |
21 return GetSystemMetrics(SM_MAXIMUMTOUCHES); | 22 return GetSystemMetrics(SM_MAXIMUMTOUCHES); |
22 } | 23 } |
23 | 24 |
24 int GetAvailablePointerTypes() { | 25 int GetAvailablePointerTypes() { |
25 // TODO(mustaq): Replace the stub below | 26 int available_pointer_types = 0; |
26 return POINTER_TYPE_NONE; | 27 if (IsTouchDevicePresent()) |
28 available_pointer_types |= POINTER_TYPE_COARSE; | |
29 if (GetSystemMetrics(SM_MOUSEPRESENT) != 0 && | |
30 GetSystemMetrics(SM_CMOUSEBUTTONS) > 0) | |
31 available_pointer_types |= POINTER_TYPE_FINE; | |
32 | |
33 // When no types are found, assume there's a POINTER_TYPE_NONE | |
34 if (available_pointer_types == 0) | |
35 available_pointer_types = POINTER_TYPE_NONE; | |
36 | |
37 return available_pointer_types; | |
27 } | 38 } |
28 | 39 |
29 PointerType GetPrimaryPointerType() { | 40 PointerType GetPrimaryPointerType() { |
30 // TODO(mustaq): Replace the stub below | 41 int available_pointer_types = GetAvailablePointerTypes(); |
42 if (available_pointer_types & POINTER_TYPE_FINE) | |
43 return POINTER_TYPE_FINE; | |
44 if (available_pointer_types & POINTER_TYPE_COARSE) | |
45 return POINTER_TYPE_COARSE; | |
46 DCHECK(available_pointer_types & POINTER_TYPE_NONE); | |
31 return POINTER_TYPE_NONE; | 47 return POINTER_TYPE_NONE; |
32 } | 48 } |
33 | 49 |
34 int GetAvailableHoverTypes() { | 50 int GetAvailableHoverTypes() { |
35 // TODO(mustaq): Replace the stub below | 51 int available_hover_types = 0; |
52 if (IsTouchDevicePresent()) | |
53 available_hover_types |= HOVER_TYPE_ON_DEMAND; | |
54 if (GetSystemMetrics(SM_MOUSEPRESENT) != 0) | |
55 available_hover_types |= HOVER_TYPE_HOVER; | |
56 | |
57 // When no types are found, assume there's a HOVER_TYPE_NONE | |
58 if (available_hover_types == 0) | |
59 available_hover_types = HOVER_TYPE_NONE; | |
60 | |
61 return available_hover_types; | |
62 } | |
63 | |
64 HoverType GetPrimaryHoverType() { | |
65 int available_hover_types = GetAvailableHoverTypes(); | |
66 if (available_hover_types & HOVER_TYPE_HOVER) | |
67 return HOVER_TYPE_HOVER; | |
68 if (available_hover_types & HOVER_TYPE_ON_DEMAND) | |
69 return HOVER_TYPE_ON_DEMAND; | |
70 DCHECK(available_hover_types & HOVER_TYPE_NONE); | |
sadrul
2014/12/07 17:46:18
The implementations of GetPrimaryHoverType() and G
mustaq
2014/12/09 20:46:19
No because the assumptions vary with platforms. E.
| |
36 return HOVER_TYPE_NONE; | 71 return HOVER_TYPE_NONE; |
37 } | 72 } |
38 | 73 |
39 HoverType GetPrimaryHoverType() { | |
40 // TODO(mustaq): Replace the stub below | |
41 return HOVER_TYPE_NONE; | |
42 } | |
43 | |
44 } // namespace ui | 74 } // namespace ui |
OLD | NEW |