OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ash/display/screen_orientation_controller_chromeos.h" | 5 #include "ash/display/screen_orientation_controller_chromeos.h" |
6 | 6 |
7 #include "ash/common/ash_switches.h" | 7 #include "ash/common/ash_switches.h" |
8 #include "ash/common/display/display_info.h" | |
9 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 8 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
10 #include "ash/common/wm_shell.h" | 9 #include "ash/common/wm_shell.h" |
11 #include "ash/common/wm_window.h" | 10 #include "ash/common/wm_window.h" |
12 #include "ash/display/display_configuration_controller.h" | 11 #include "ash/display/display_configuration_controller.h" |
13 #include "ash/display/display_manager.h" | 12 #include "ash/display/display_manager.h" |
14 #include "ash/shell.h" | 13 #include "ash/shell.h" |
15 #include "base/auto_reset.h" | 14 #include "base/auto_reset.h" |
16 #include "base/command_line.h" | 15 #include "base/command_line.h" |
17 #include "chromeos/accelerometer/accelerometer_reader.h" | 16 #include "chromeos/accelerometer/accelerometer_reader.h" |
18 #include "chromeos/accelerometer/accelerometer_types.h" | 17 #include "chromeos/accelerometer/accelerometer_types.h" |
19 #include "ui/chromeos/accelerometer/accelerometer_util.h" | 18 #include "ui/chromeos/accelerometer/accelerometer_util.h" |
20 #include "ui/display/display.h" | 19 #include "ui/display/display.h" |
| 20 #include "ui/display/manager/managed_display_info.h" |
21 #include "ui/gfx/geometry/size.h" | 21 #include "ui/gfx/geometry/size.h" |
22 | 22 |
23 namespace ash { | 23 namespace ash { |
24 | 24 |
25 namespace { | 25 namespace { |
26 | 26 |
27 // The angle which the screen has to be rotated past before the display will | 27 // The angle which the screen has to be rotated past before the display will |
28 // rotate to match it (i.e. 45.0f is no stickiness). | 28 // rotate to match it (i.e. 45.0f is no stickiness). |
29 const float kDisplayRotationStickyAngleDegrees = 60.0f; | 29 const float kDisplayRotationStickyAngleDegrees = 60.0f; |
30 | 30 |
31 // The minimum acceleration in m/s^2 in a direction required to trigger screen | 31 // The minimum acceleration in m/s^2 in a direction required to trigger screen |
32 // rotation. This prevents rapid toggling of rotation when the device is near | 32 // rotation. This prevents rapid toggling of rotation when the device is near |
33 // flat and there is very little screen aligned force on it. The value is | 33 // flat and there is very little screen aligned force on it. The value is |
34 // effectively the sine of the rise angle required times the acceleration due | 34 // effectively the sine of the rise angle required times the acceleration due |
35 // to gravity, with the current value requiring at least a 25 degree rise. | 35 // to gravity, with the current value requiring at least a 25 degree rise. |
36 const float kMinimumAccelerationScreenRotation = 4.2f; | 36 const float kMinimumAccelerationScreenRotation = 4.2f; |
37 | 37 |
38 blink::WebScreenOrientationLockType GetDisplayNaturalOrientation() { | 38 blink::WebScreenOrientationLockType GetDisplayNaturalOrientation() { |
39 if (!display::Display::HasInternalDisplay()) | 39 if (!display::Display::HasInternalDisplay()) |
40 return blink::WebScreenOrientationLockLandscape; | 40 return blink::WebScreenOrientationLockLandscape; |
41 | 41 |
42 DisplayInfo info = | 42 display::ManagedDisplayInfo info = |
43 WmShell::Get()->GetDisplayInfo(display::Display::InternalDisplayId()); | 43 WmShell::Get()->GetDisplayInfo(display::Display::InternalDisplayId()); |
44 gfx::Size size = info.size_in_pixel(); | 44 gfx::Size size = info.size_in_pixel(); |
45 switch (info.GetActiveRotation()) { | 45 switch (info.GetActiveRotation()) { |
46 case display::Display::ROTATE_0: | 46 case display::Display::ROTATE_0: |
47 case display::Display::ROTATE_180: | 47 case display::Display::ROTATE_180: |
48 return size.height() >= size.width() | 48 return size.height() >= size.width() |
49 ? blink::WebScreenOrientationLockPortrait | 49 ? blink::WebScreenOrientationLockPortrait |
50 : blink::WebScreenOrientationLockLandscape; | 50 : blink::WebScreenOrientationLockLandscape; |
51 case display::Display::ROTATE_90: | 51 case display::Display::ROTATE_90: |
52 case display::Display::ROTATE_270: | 52 case display::Display::ROTATE_270: |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 } | 418 } |
419 | 419 |
420 bool ScreenOrientationController::CanRotateInLockedState() { | 420 bool ScreenOrientationController::CanRotateInLockedState() { |
421 return rotation_locked_orientation_ == | 421 return rotation_locked_orientation_ == |
422 blink::WebScreenOrientationLockLandscape || | 422 blink::WebScreenOrientationLockLandscape || |
423 rotation_locked_orientation_ == | 423 rotation_locked_orientation_ == |
424 blink::WebScreenOrientationLockPortrait; | 424 blink::WebScreenOrientationLockPortrait; |
425 } | 425 } |
426 | 426 |
427 } // namespace ash | 427 } // namespace ash |
OLD | NEW |