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/wm/maximize_mode/maximize_mode_controller.h" | 8 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
9 #include "ash/common/wm/mru_window_tracker.h" | 9 #include "ash/common/wm/mru_window_tracker.h" |
10 #include "ash/common/wm/window_state.h" | 10 #include "ash/common/wm/window_state.h" |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
225 | 225 |
226 if (user_rotation_locked()) { | 226 if (user_rotation_locked()) { |
227 user_locked_orientation_ = blink::WebScreenOrientationLockAny; | 227 user_locked_orientation_ = blink::WebScreenOrientationLockAny; |
228 } else { | 228 } else { |
229 display::Display::Rotation current_rotation = | 229 display::Display::Rotation current_rotation = |
230 WmShell::Get() | 230 WmShell::Get() |
231 ->GetDisplayInfo(display::Display::InternalDisplayId()) | 231 ->GetDisplayInfo(display::Display::InternalDisplayId()) |
232 .GetActiveRotation(); | 232 .GetActiveRotation(); |
233 user_locked_orientation_ = RotationToOrientation(current_rotation); | 233 user_locked_orientation_ = RotationToOrientation(current_rotation); |
234 } | 234 } |
235 base::AutoReset<bool> auto_ignore_display_configuration_updates( | 235 SetLockToOrientation(user_locked_orientation_); |
236 &ignore_display_configuration_updates_, true); | 236 } |
237 Shell::GetInstance()->display_manager()->RegisterDisplayRotationProperties( | |
238 user_rotation_locked(), OrientationToRotation(user_locked_orientation_)); | |
239 | 237 |
240 ApplyLockForActiveWindow(); | 238 void ScreenOrientationController::SetLockToRotation( |
241 for (auto& observer : observers_) | 239 display::Display::Rotation rotation) { |
242 observer.OnUserRotationLockChanged(); | 240 user_locked_orientation_ = RotationToOrientation(rotation); |
241 SetLockToOrientation(user_locked_orientation_); | |
243 } | 242 } |
244 | 243 |
245 void ScreenOrientationController::OnWindowActivated(ActivationReason reason, | 244 void ScreenOrientationController::OnWindowActivated(ActivationReason reason, |
246 aura::Window* gained_active, | 245 aura::Window* gained_active, |
247 aura::Window* lost_active) { | 246 aura::Window* lost_active) { |
248 ApplyLockForActiveWindow(); | 247 ApplyLockForActiveWindow(); |
249 } | 248 } |
250 | 249 |
251 void ScreenOrientationController::OnWindowDestroying(aura::Window* window) { | 250 void ScreenOrientationController::OnWindowDestroying(aura::Window* window) { |
252 UnlockOrientationForWindow(WmWindow::Get(window)); | 251 UnlockOrientationForWindow(WmWindow::Get(window)); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
350 | 349 |
351 void ScreenOrientationController::SetRotationLockedInternal( | 350 void ScreenOrientationController::SetRotationLockedInternal( |
352 bool rotation_locked) { | 351 bool rotation_locked) { |
353 if (rotation_locked_ == rotation_locked) | 352 if (rotation_locked_ == rotation_locked) |
354 return; | 353 return; |
355 rotation_locked_ = rotation_locked; | 354 rotation_locked_ = rotation_locked; |
356 if (!rotation_locked_) | 355 if (!rotation_locked_) |
357 rotation_locked_orientation_ = blink::WebScreenOrientationLockAny; | 356 rotation_locked_orientation_ = blink::WebScreenOrientationLockAny; |
358 } | 357 } |
359 | 358 |
359 void ScreenOrientationController::SetLockToOrientation( | |
360 blink::WebScreenOrientationLockType orientation) { | |
oshima
2017/03/30 04:46:00
this should be either
SetLockToOrientation(orient
| |
361 if (!display::Display::HasInternalDisplay()) | |
362 return; | |
oshima
2017/03/30 04:46:00
you need to do this in SetLockToRotation if you up
| |
363 | |
364 base::AutoReset<bool> auto_ignore_display_configuration_updates( | |
365 &ignore_display_configuration_updates_, true); | |
366 Shell::GetInstance()->display_manager()->RegisterDisplayRotationProperties( | |
367 user_rotation_locked(), OrientationToRotation(user_locked_orientation_)); | |
368 | |
369 ApplyLockForActiveWindow(); | |
370 for (auto& observer : observers_) | |
371 observer.OnUserRotationLockChanged(); | |
372 } | |
373 | |
360 void ScreenOrientationController::LockRotation( | 374 void ScreenOrientationController::LockRotation( |
361 display::Display::Rotation rotation, | 375 display::Display::Rotation rotation, |
362 display::Display::RotationSource source) { | 376 display::Display::RotationSource source) { |
363 SetRotationLockedInternal(true); | 377 SetRotationLockedInternal(true); |
364 SetDisplayRotation(rotation, source); | 378 SetDisplayRotation(rotation, source); |
365 } | 379 } |
366 | 380 |
367 void ScreenOrientationController::LockRotationToOrientation( | 381 void ScreenOrientationController::LockRotationToOrientation( |
368 blink::WebScreenOrientationLockType lock_orientation) { | 382 blink::WebScreenOrientationLockType lock_orientation) { |
369 rotation_locked_orientation_ = lock_orientation; | 383 rotation_locked_orientation_ = lock_orientation; |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
552 } | 566 } |
553 | 567 |
554 bool ScreenOrientationController::CanRotateInLockedState() { | 568 bool ScreenOrientationController::CanRotateInLockedState() { |
555 return rotation_locked_orientation_ == | 569 return rotation_locked_orientation_ == |
556 blink::WebScreenOrientationLockLandscape || | 570 blink::WebScreenOrientationLockLandscape || |
557 rotation_locked_orientation_ == | 571 rotation_locked_orientation_ == |
558 blink::WebScreenOrientationLockPortrait; | 572 blink::WebScreenOrientationLockPortrait; |
559 } | 573 } |
560 | 574 |
561 } // namespace ash | 575 } // namespace ash |
OLD | NEW |