Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/accelerators/accelerator_controller.h" | 5 #include "ash/accelerators/accelerator_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 // rotation and position. Use replace so we only enqueue one at a time. | 145 // rotation and position. Use replace so we only enqueue one at a time. |
| 146 active_window->layer()->GetAnimator()-> | 146 active_window->layer()->GetAnimator()-> |
| 147 set_preemption_strategy(ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); | 147 set_preemption_strategy(ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); |
| 148 active_window->layer()->GetAnimator()->StartAnimation( | 148 active_window->layer()->GetAnimator()->StartAnimation( |
| 149 new ui::LayerAnimationSequence( | 149 new ui::LayerAnimationSequence( |
| 150 new ash::ScreenRotation(360, active_window->layer()))); | 150 new ash::ScreenRotation(360, active_window->layer()))); |
| 151 } | 151 } |
| 152 return true; | 152 return true; |
| 153 } | 153 } |
| 154 | 154 |
| 155 using internal::DisplayInfo; | |
|
Jun Mukai
2013/03/11 02:02:35
using-directive would be better at the top of the
| |
| 156 | |
| 157 const DisplayInfo::Rotation GetNextRotation(DisplayInfo::Rotation current) { | |
| 158 switch (current) { | |
| 159 case DisplayInfo::Rotate0: | |
| 160 return DisplayInfo::Rotate90; | |
| 161 case DisplayInfo::Rotate90: | |
| 162 return DisplayInfo::Rotate180; | |
| 163 case DisplayInfo::Rotate180: | |
| 164 return DisplayInfo::Rotate270; | |
| 165 case DisplayInfo::Rotate270: | |
| 166 return DisplayInfo::Rotate0; | |
| 167 } | |
| 168 NOTREACHED() << "Unknown rotation:" << current; | |
| 169 return DisplayInfo::Rotate0; | |
| 170 } | |
| 171 | |
| 155 // Rotates the screen. | 172 // Rotates the screen. |
| 156 bool HandleRotateScreen() { | 173 bool HandleRotateScreen() { |
| 157 static int i = 0; | 174 aura::Window* active_window = wm::GetActiveWindow(); |
| 158 int delta = 0; | 175 if (!active_window) |
| 159 switch (i) { | 176 return false; |
| 160 case 0: delta = 90; break; | 177 const gfx::Display& display = |
| 161 case 1: delta = 90; break; | 178 gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(active_window); |
| 162 case 2: delta = 90; break; | 179 const DisplayInfo& display_info = |
| 163 case 3: delta = 90; break; | 180 Shell::GetInstance()->display_manager()->GetDisplayInfo(display); |
| 164 case 4: delta = -90; break; | 181 Shell::GetInstance()->display_manager()->SetDisplayRotation( |
| 165 case 5: delta = -90; break; | 182 display.id(), GetNextRotation(display_info.rotation())); |
| 166 case 6: delta = -90; break; | |
| 167 case 7: delta = -90; break; | |
| 168 case 8: delta = -90; break; | |
| 169 case 9: delta = 180; break; | |
| 170 case 10: delta = 180; break; | |
| 171 case 11: delta = 90; break; | |
| 172 case 12: delta = 180; break; | |
| 173 case 13: delta = 180; break; | |
| 174 } | |
| 175 i = (i + 1) % 14; | |
| 176 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | |
| 177 for (size_t i = 0; i < root_windows.size(); ++i) { | |
| 178 aura::RootWindow* root_window = root_windows[i]; | |
| 179 root_window->layer()->GetAnimator()-> | |
| 180 set_preemption_strategy(ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); | |
| 181 scoped_ptr<ui::LayerAnimationSequence> screen_rotation( | |
| 182 new ui::LayerAnimationSequence( | |
| 183 new ash::ScreenRotation(delta, root_window->layer()))); | |
| 184 screen_rotation->AddObserver(root_window); | |
| 185 root_window->layer()->GetAnimator()-> | |
| 186 StartAnimation(screen_rotation.release()); | |
| 187 } | |
| 188 return true; | 183 return true; |
| 189 } | 184 } |
| 190 | 185 |
| 191 bool HandleToggleDesktopBackgroundMode() { | 186 bool HandleToggleDesktopBackgroundMode() { |
| 192 DesktopBackgroundController* desktop_background_controller = | 187 DesktopBackgroundController* desktop_background_controller = |
| 193 Shell::GetInstance()->desktop_background_controller(); | 188 Shell::GetInstance()->desktop_background_controller(); |
| 194 if (desktop_background_controller->desktop_background_mode() == | 189 if (desktop_background_controller->desktop_background_mode() == |
| 195 DesktopBackgroundController::BACKGROUND_IMAGE) { | 190 DesktopBackgroundController::BACKGROUND_IMAGE) { |
| 196 desktop_background_controller->SetDesktopBackgroundSolidColorMode( | 191 desktop_background_controller->SetDesktopBackgroundSolidColorMode( |
| 197 SK_ColorBLACK); | 192 SK_ColorBLACK); |
| (...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 867 keyboard_brightness_control_delegate) { | 862 keyboard_brightness_control_delegate) { |
| 868 keyboard_brightness_control_delegate_ = | 863 keyboard_brightness_control_delegate_ = |
| 869 keyboard_brightness_control_delegate.Pass(); | 864 keyboard_brightness_control_delegate.Pass(); |
| 870 } | 865 } |
| 871 | 866 |
| 872 bool AcceleratorController::CanHandleAccelerators() const { | 867 bool AcceleratorController::CanHandleAccelerators() const { |
| 873 return true; | 868 return true; |
| 874 } | 869 } |
| 875 | 870 |
| 876 } // namespace ash | 871 } // namespace ash |
| OLD | NEW |