| 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 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/win/win_util.h" | 8 #include "base/win/win_util.h" |
| 9 | 9 |
| 10 namespace ui { | 10 namespace ui { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 int available_pointer_types = POINTER_TYPE_FINE; | 45 int available_pointer_types = POINTER_TYPE_FINE; |
| 46 if (IsTouchDevicePresent()) | 46 if (IsTouchDevicePresent()) |
| 47 available_pointer_types |= POINTER_TYPE_COARSE; | 47 available_pointer_types |= POINTER_TYPE_COARSE; |
| 48 | 48 |
| 49 return available_pointer_types; | 49 return available_pointer_types; |
| 50 } | 50 } |
| 51 | 51 |
| 52 // This method follows the same logic as above but with hover types. | 52 // This method follows the same logic as above but with hover types. |
| 53 int GetAvailableHoverTypes() { | 53 int GetAvailableHoverTypes() { |
| 54 if (base::win::IsTabletDevice(nullptr)) | 54 if (base::win::IsTabletDevice(nullptr)) |
| 55 return HOVER_TYPE_ON_DEMAND; | |
| 56 | |
| 57 if (GetSystemMetrics(SM_MOUSEPRESENT) == 0) | |
| 58 return HOVER_TYPE_NONE; | 55 return HOVER_TYPE_NONE; |
| 59 | 56 |
| 60 int available_hover_types = HOVER_TYPE_HOVER; | 57 int available_hover_types; |
| 61 if (IsTouchDevicePresent()) | 58 if (GetSystemMetrics(SM_MOUSEPRESENT) != 0) { |
| 62 available_hover_types |= HOVER_TYPE_ON_DEMAND; | 59 available_hover_types = HOVER_TYPE_HOVER; |
| 60 if (IsTouchDevicePresent()) |
| 61 available_hover_types |= HOVER_TYPE_NONE; |
| 62 } else |
| 63 available_hover_types = HOVER_TYPE_NONE; |
| 63 | 64 |
| 64 return available_hover_types; | 65 return available_hover_types; |
| 65 } | 66 } |
| 66 | 67 |
| 67 } // namespace | 68 } // namespace |
| 68 | 69 |
| 69 TouchScreensAvailability GetTouchScreensAvailability() { | 70 TouchScreensAvailability GetTouchScreensAvailability() { |
| 70 if (!IsTouchDevicePresent()) | 71 if (!IsTouchDevicePresent()) |
| 71 return TouchScreensAvailability::NONE; | 72 return TouchScreensAvailability::NONE; |
| 72 | 73 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 85 return POINTER_TYPE_FINE; | 86 return POINTER_TYPE_FINE; |
| 86 if (available_pointer_types & POINTER_TYPE_COARSE) | 87 if (available_pointer_types & POINTER_TYPE_COARSE) |
| 87 return POINTER_TYPE_COARSE; | 88 return POINTER_TYPE_COARSE; |
| 88 DCHECK_EQ(available_pointer_types, POINTER_TYPE_NONE); | 89 DCHECK_EQ(available_pointer_types, POINTER_TYPE_NONE); |
| 89 return POINTER_TYPE_NONE; | 90 return POINTER_TYPE_NONE; |
| 90 } | 91 } |
| 91 | 92 |
| 92 HoverType GetPrimaryHoverType(int available_hover_types) { | 93 HoverType GetPrimaryHoverType(int available_hover_types) { |
| 93 if (available_hover_types & HOVER_TYPE_HOVER) | 94 if (available_hover_types & HOVER_TYPE_HOVER) |
| 94 return HOVER_TYPE_HOVER; | 95 return HOVER_TYPE_HOVER; |
| 95 if (available_hover_types & HOVER_TYPE_ON_DEMAND) | |
| 96 return HOVER_TYPE_ON_DEMAND; | |
| 97 DCHECK_EQ(available_hover_types, HOVER_TYPE_NONE); | 96 DCHECK_EQ(available_hover_types, HOVER_TYPE_NONE); |
| 98 return HOVER_TYPE_NONE; | 97 return HOVER_TYPE_NONE; |
| 99 } | 98 } |
| 100 | 99 |
| 101 std::pair<int, int> GetAvailablePointerAndHoverTypes() { | 100 std::pair<int, int> GetAvailablePointerAndHoverTypes() { |
| 102 return std::make_pair(GetAvailablePointerTypes(), GetAvailableHoverTypes()); | 101 return std::make_pair(GetAvailablePointerTypes(), GetAvailableHoverTypes()); |
| 103 } | 102 } |
| 104 | 103 |
| 105 } // namespace ui | 104 } // namespace ui |
| OLD | NEW |