| 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/wm/maximize_mode/maximize_mode_controller.h" | 5 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
| 6 | 6 |
| 7 #include "ash/accelerometer/accelerometer_controller.h" | 7 #include "ash/accelerometer/accelerometer_controller.h" |
| 8 #include "ash/display/display_manager.h" | 8 #include "ash/display/display_manager.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/wm/maximize_mode/maximize_mode_event_blocker.h" |
| 10 #include "ui/gfx/vector3d_f.h" | 11 #include "ui/gfx/vector3d_f.h" |
| 11 | 12 |
| 12 namespace ash { | 13 namespace ash { |
| 13 | 14 |
| 14 namespace { | 15 namespace { |
| 15 | 16 |
| 16 // The hinge angle at which to enter maximize mode. | 17 // The hinge angle at which to enter maximize mode. |
| 17 const float kEnterMaximizeModeAngle = 200.0f; | 18 const float kEnterMaximizeModeAngle = 200.0f; |
| 18 | 19 |
| 19 // The angle at which to exit maximize mode, this is specifically less than the | 20 // The angle at which to exit maximize mode, this is specifically less than the |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 float angle = ClockwiseAngleBetweenVectorsInDegrees(base, lid, hinge_vector); | 107 float angle = ClockwiseAngleBetweenVectorsInDegrees(base, lid, hinge_vector); |
| 107 | 108 |
| 108 // Toggle maximize mode on or off when corresponding thresholds are passed. | 109 // Toggle maximize mode on or off when corresponding thresholds are passed. |
| 109 // TODO(flackr): Make MaximizeModeController own the MaximizeModeWindowManager | 110 // TODO(flackr): Make MaximizeModeController own the MaximizeModeWindowManager |
| 110 // such that observations of state changes occur after the change and shell | 111 // such that observations of state changes occur after the change and shell |
| 111 // has fewer states to track. | 112 // has fewer states to track. |
| 112 if (maximize_mode_engaged && | 113 if (maximize_mode_engaged && |
| 113 angle > kFullyOpenAngleErrorTolerance && | 114 angle > kFullyOpenAngleErrorTolerance && |
| 114 angle < kExitMaximizeModeAngle) { | 115 angle < kExitMaximizeModeAngle) { |
| 115 Shell::GetInstance()->EnableMaximizeModeWindowManager(false); | 116 Shell::GetInstance()->EnableMaximizeModeWindowManager(false); |
| 117 event_blocker_.reset(); |
| 116 } else if (!maximize_mode_engaged && | 118 } else if (!maximize_mode_engaged && |
| 117 angle > kEnterMaximizeModeAngle) { | 119 angle > kEnterMaximizeModeAngle) { |
| 118 Shell::GetInstance()->EnableMaximizeModeWindowManager(true); | 120 Shell::GetInstance()->EnableMaximizeModeWindowManager(true); |
| 121 event_blocker_.reset(new MaximizeModeEventBlocker); |
| 119 } | 122 } |
| 120 } | 123 } |
| 121 | 124 |
| 122 void MaximizeModeController::HandleScreenRotation(const gfx::Vector3dF& lid) { | 125 void MaximizeModeController::HandleScreenRotation(const gfx::Vector3dF& lid) { |
| 123 bool maximize_mode_engaged = | 126 bool maximize_mode_engaged = |
| 124 Shell::GetInstance()->IsMaximizeModeWindowManagerEnabled(); | 127 Shell::GetInstance()->IsMaximizeModeWindowManagerEnabled(); |
| 125 | 128 |
| 126 DisplayManager* display_manager = | 129 DisplayManager* display_manager = |
| 127 Shell::GetInstance()->display_manager(); | 130 Shell::GetInstance()->display_manager(); |
| 128 gfx::Display::Rotation current_rotation = display_manager->GetDisplayInfo( | 131 gfx::Display::Rotation current_rotation = display_manager->GetDisplayInfo( |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 // When exiting maximize mode return rotation to 0. When entering, rotate to | 195 // When exiting maximize mode return rotation to 0. When entering, rotate to |
| 193 // match screen orientation. | 196 // match screen orientation. |
| 194 if (new_rotation == gfx::Display::ROTATE_0 || | 197 if (new_rotation == gfx::Display::ROTATE_0 || |
| 195 maximize_mode_engaged) { | 198 maximize_mode_engaged) { |
| 196 display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(), | 199 display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(), |
| 197 new_rotation); | 200 new_rotation); |
| 198 } | 201 } |
| 199 } | 202 } |
| 200 | 203 |
| 201 } // namespace ash | 204 } // namespace ash |
| OLD | NEW |