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/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/display/display_configuration_controller.h" | 8 #include "ash/display/display_configuration_controller.h" |
9 #include "ash/shared/app_types.h" | 9 #include "ash/shared/app_types.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 chromeos::ACCELEROMETER_SOURCE_SCREEN)) { | 281 chromeos::ACCELEROMETER_SOURCE_SCREEN)) { |
282 HandleScreenRotation(update->get(chromeos::ACCELEROMETER_SOURCE_SCREEN)); | 282 HandleScreenRotation(update->get(chromeos::ACCELEROMETER_SOURCE_SCREEN)); |
283 } | 283 } |
284 } | 284 } |
285 | 285 |
286 void ScreenOrientationController::OnDisplayConfigurationChanged() { | 286 void ScreenOrientationController::OnDisplayConfigurationChanged() { |
287 if (ignore_display_configuration_updates_) | 287 if (ignore_display_configuration_updates_) |
288 return; | 288 return; |
289 if (!display::Display::HasInternalDisplay()) | 289 if (!display::Display::HasInternalDisplay()) |
290 return; | 290 return; |
291 display::Display::Rotation user_rotation = | 291 if (!Shell::Get()->display_manager()->IsActiveDisplayId( |
| 292 display::Display::InternalDisplayId())) { |
| 293 return; |
| 294 } |
| 295 |
| 296 // TODO(oshima): We should disable the orientation change in settings |
| 297 // because application may not work correctly. |
| 298 current_rotation_ = |
292 ShellPort::Get() | 299 ShellPort::Get() |
293 ->GetDisplayInfo(display::Display::InternalDisplayId()) | 300 ->GetDisplayInfo(display::Display::InternalDisplayId()) |
294 .GetActiveRotation(); | 301 .GetActiveRotation(); |
295 if (user_rotation != current_rotation_) { | |
296 // TODO(oshima): We should disable the orientation change in settings | |
297 // because application may not work correctly. | |
298 | |
299 // A user may change other display configuration settings. When the user | |
300 // does change the rotation setting, then lock rotation to prevent the | |
301 // accelerometer from erasing their change. | |
302 SetRotationLockedInternal(true); | |
303 user_rotation_ = current_rotation_ = user_rotation; | |
304 } | |
305 } | 302 } |
306 | 303 |
307 void ScreenOrientationController::OnMaximizeModeStarted() { | 304 void ScreenOrientationController::OnMaximizeModeStarted() { |
308 // Do not exit early, as the internal display can be determined after Maximize | 305 // Do not exit early, as the internal display can be determined after Maximize |
309 // Mode has started. (chrome-os-partner:38796) | 306 // Mode has started. (chrome-os-partner:38796) |
310 // Always start observing. | 307 // Always start observing. |
311 if (display::Display::HasInternalDisplay()) { | 308 if (display::Display::HasInternalDisplay()) { |
312 current_rotation_ = user_rotation_ = | 309 current_rotation_ = user_rotation_ = |
313 ShellPort::Get() | 310 ShellPort::Get() |
314 ->GetDisplayInfo(display::Display::InternalDisplayId()) | 311 ->GetDisplayInfo(display::Display::InternalDisplayId()) |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 } | 576 } |
580 | 577 |
581 bool ScreenOrientationController::CanRotateInLockedState() { | 578 bool ScreenOrientationController::CanRotateInLockedState() { |
582 return rotation_locked_orientation_ == | 579 return rotation_locked_orientation_ == |
583 blink::kWebScreenOrientationLockLandscape || | 580 blink::kWebScreenOrientationLockLandscape || |
584 rotation_locked_orientation_ == | 581 rotation_locked_orientation_ == |
585 blink::kWebScreenOrientationLockPortrait; | 582 blink::kWebScreenOrientationLockPortrait; |
586 } | 583 } |
587 | 584 |
588 } // namespace ash | 585 } // namespace ash |
OLD | NEW |