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/layout.h" | 5 #include "ui/base/layout.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
15 #include "ui/base/ui_base_switches.h" | 15 #include "ui/base/ui_base_switches.h" |
16 | 16 |
17 #if defined(USE_AURA) && !defined(OS_WIN) | 17 #if defined(USE_AURA) && !defined(OS_WIN) |
18 #include "ui/aura/root_window.h" | 18 #include "ui/aura/root_window.h" |
19 #include "ui/compositor/compositor.h" | 19 #include "ui/compositor/compositor.h" |
20 #endif // defined(USE_AURA) && !defined(OS_WIN) | 20 #endif // defined(USE_AURA) && !defined(OS_WIN) |
21 | 21 |
22 #if defined(USE_AURA) && defined(USE_X11) | |
23 #include "ui/base/touch/touch_factory.h" | |
24 #endif // defined(USE_AURA) && defined(USE_X11) | |
25 | |
26 #if defined(OS_MACOSX) | 22 #if defined(OS_MACOSX) |
27 #include "base/mac/mac_util.h" | 23 #include "base/mac/mac_util.h" |
28 #endif | 24 #endif |
29 | 25 |
30 #if defined(OS_WIN) | 26 #if defined(OS_WIN) |
31 #include "base/win/metro.h" | 27 #include "base/win/metro.h" |
32 #include <Windows.h> | 28 #include <Windows.h> |
33 #endif // defined(OS_WIN) | 29 #endif // defined(OS_WIN) |
34 | 30 |
35 namespace { | 31 namespace { |
(...skipping 16 matching lines...) Expand all Loading... |
52 return false; | 48 return false; |
53 } else if (switch_value != switches::kTouchOptimizedUIAuto) { | 49 } else if (switch_value != switches::kTouchOptimizedUIAuto) { |
54 LOG(ERROR) << "Invalid --touch-optimized-ui option: " << switch_value; | 50 LOG(ERROR) << "Invalid --touch-optimized-ui option: " << switch_value; |
55 } | 51 } |
56 } | 52 } |
57 | 53 |
58 #if defined(OS_WIN) | 54 #if defined(OS_WIN) |
59 // On Windows, we use the touch layout only when we are running in | 55 // On Windows, we use the touch layout only when we are running in |
60 // Metro mode. | 56 // Metro mode. |
61 return base::win::IsMetroProcess() && base::win::IsTouchEnabled(); | 57 return base::win::IsMetroProcess() && base::win::IsTouchEnabled(); |
62 #elif defined(USE_AURA) && defined(USE_X11) | |
63 // Determine whether touch-screen hardware is currently available. | |
64 // For now we must ensure this won't change over the life of the process, | |
65 // since we don't yet support updating the UI. crbug.com/124399 | |
66 static bool has_touch_device = | |
67 ui::TouchFactory::GetInstance()->IsTouchDevicePresent(); | |
68 | |
69 // Work-around for late device detection in some cases. If we've asked for | |
70 // touch calibration then we're certainly expecting a touch screen, it must | |
71 // just not be ready yet. Force-enable touch-ui mode in this case. | |
72 static bool enable_touch_calibration = CommandLine::ForCurrentProcess()-> | |
73 HasSwitch(switches::kEnableTouchCalibration); | |
74 if (!has_touch_device && enable_touch_calibration) | |
75 has_touch_device = true; | |
76 | |
77 return has_touch_device; | |
78 #else | 58 #else |
79 return false; | 59 return false; |
80 #endif | 60 #endif |
81 } | 61 } |
82 | 62 |
83 const float kScaleFactorScales[] = {1.0, 2.0}; | 63 const float kScaleFactorScales[] = {1.0, 2.0}; |
84 const size_t kScaleFactorScalesLength = arraysize(kScaleFactorScales); | 64 const size_t kScaleFactorScalesLength = arraysize(kScaleFactorScales); |
85 | 65 |
86 std::vector<ui::ScaleFactor>& GetSupportedScaleFactorsInternal() { | 66 std::vector<ui::ScaleFactor>& GetSupportedScaleFactorsInternal() { |
87 static std::vector<ui::ScaleFactor>* supported_scale_factors = | 67 static std::vector<ui::ScaleFactor>* supported_scale_factors = |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 return GetScaleFactorFromScale( | 144 return GetScaleFactorFromScale( |
165 view->GetRootWindow()->compositor()->device_scale_factor()); | 145 view->GetRootWindow()->compositor()->device_scale_factor()); |
166 #else | 146 #else |
167 NOTIMPLEMENTED(); | 147 NOTIMPLEMENTED(); |
168 return SCALE_FACTOR_NONE; | 148 return SCALE_FACTOR_NONE; |
169 #endif | 149 #endif |
170 } | 150 } |
171 #endif // !defined(OS_MACOSX) | 151 #endif // !defined(OS_MACOSX) |
172 | 152 |
173 } // namespace ui | 153 } // namespace ui |
OLD | NEW |