Chromium Code Reviews| Index: ash/accelerators/accelerator_controller.cc |
| diff --git a/ash/accelerators/accelerator_controller.cc b/ash/accelerators/accelerator_controller.cc |
| index 943e75f361366d17aa43690ac8fadd8f75baf8f0..ec913642af033b5e62ebe9bbbe68c40f24fcc441 100644 |
| --- a/ash/accelerators/accelerator_controller.cc |
| +++ b/ash/accelerators/accelerator_controller.cc |
| @@ -152,39 +152,34 @@ bool HandleRotateActiveWindow() { |
| return true; |
| } |
| +using internal::DisplayInfo; |
|
Jun Mukai
2013/03/11 02:02:35
using-directive would be better at the top of the
|
| + |
| +const DisplayInfo::Rotation GetNextRotation(DisplayInfo::Rotation current) { |
| + switch (current) { |
| + case DisplayInfo::Rotate0: |
| + return DisplayInfo::Rotate90; |
| + case DisplayInfo::Rotate90: |
| + return DisplayInfo::Rotate180; |
| + case DisplayInfo::Rotate180: |
| + return DisplayInfo::Rotate270; |
| + case DisplayInfo::Rotate270: |
| + return DisplayInfo::Rotate0; |
| + } |
| + NOTREACHED() << "Unknown rotation:" << current; |
| + return DisplayInfo::Rotate0; |
| +} |
| + |
| // Rotates the screen. |
| bool HandleRotateScreen() { |
| - static int i = 0; |
| - int delta = 0; |
| - switch (i) { |
| - case 0: delta = 90; break; |
| - case 1: delta = 90; break; |
| - case 2: delta = 90; break; |
| - case 3: delta = 90; break; |
| - case 4: delta = -90; break; |
| - case 5: delta = -90; break; |
| - case 6: delta = -90; break; |
| - case 7: delta = -90; break; |
| - case 8: delta = -90; break; |
| - case 9: delta = 180; break; |
| - case 10: delta = 180; break; |
| - case 11: delta = 90; break; |
| - case 12: delta = 180; break; |
| - case 13: delta = 180; break; |
| - } |
| - i = (i + 1) % 14; |
| - Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| - for (size_t i = 0; i < root_windows.size(); ++i) { |
| - aura::RootWindow* root_window = root_windows[i]; |
| - root_window->layer()->GetAnimator()-> |
| - set_preemption_strategy(ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); |
| - scoped_ptr<ui::LayerAnimationSequence> screen_rotation( |
| - new ui::LayerAnimationSequence( |
| - new ash::ScreenRotation(delta, root_window->layer()))); |
| - screen_rotation->AddObserver(root_window); |
| - root_window->layer()->GetAnimator()-> |
| - StartAnimation(screen_rotation.release()); |
| - } |
| + aura::Window* active_window = wm::GetActiveWindow(); |
| + if (!active_window) |
| + return false; |
| + const gfx::Display& display = |
| + gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(active_window); |
| + const DisplayInfo& display_info = |
| + Shell::GetInstance()->display_manager()->GetDisplayInfo(display); |
| + Shell::GetInstance()->display_manager()->SetDisplayRotation( |
| + display.id(), GetNextRotation(display_info.rotation())); |
| return true; |
| } |