| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 #include "ui/views/widget/widget.h" | 61 #include "ui/views/widget/widget.h" |
| 62 | 62 |
| 63 #if defined(OS_CHROMEOS) | 63 #if defined(OS_CHROMEOS) |
| 64 #include "ash/system/chromeos/keyboard_brightness_controller.h" | 64 #include "ash/system/chromeos/keyboard_brightness_controller.h" |
| 65 #include "base/chromeos/chromeos_version.h" | 65 #include "base/chromeos/chromeos_version.h" |
| 66 #endif // defined(OS_CHROMEOS) | 66 #endif // defined(OS_CHROMEOS) |
| 67 | 67 |
| 68 namespace ash { | 68 namespace ash { |
| 69 namespace { | 69 namespace { |
| 70 | 70 |
| 71 using internal::DisplayInfo; |
| 72 |
| 71 // Factor of magnification scale. For example, when this value is 1.189, scale | 73 // Factor of magnification scale. For example, when this value is 1.189, scale |
| 72 // value will be changed x1.000, x1.189, x1.414, x1.681, x2.000, ... | 74 // value will be changed x1.000, x1.189, x1.414, x1.681, x2.000, ... |
| 73 // Note: this value is 2.0 ^ (1 / 4). | 75 // Note: this value is 2.0 ^ (1 / 4). |
| 74 const float kMagnificationFactor = 1.18920712f; | 76 const float kMagnificationFactor = 1.18920712f; |
| 75 | 77 |
| 76 bool DebugShortcutsEnabled() { | 78 bool DebugShortcutsEnabled() { |
| 77 #if defined(NDEBUG) | 79 #if defined(NDEBUG) |
| 78 return CommandLine::ForCurrentProcess()->HasSwitch( | 80 return CommandLine::ForCurrentProcess()->HasSwitch( |
| 79 switches::kAshDebugShortcuts); | 81 switches::kAshDebugShortcuts); |
| 80 #else | 82 #else |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 // rotation and position. Use replace so we only enqueue one at a time. | 146 // rotation and position. Use replace so we only enqueue one at a time. |
| 145 active_window->layer()->GetAnimator()-> | 147 active_window->layer()->GetAnimator()-> |
| 146 set_preemption_strategy(ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); | 148 set_preemption_strategy(ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); |
| 147 active_window->layer()->GetAnimator()->StartAnimation( | 149 active_window->layer()->GetAnimator()->StartAnimation( |
| 148 new ui::LayerAnimationSequence( | 150 new ui::LayerAnimationSequence( |
| 149 new ash::ScreenRotation(360, active_window->layer()))); | 151 new ash::ScreenRotation(360, active_window->layer()))); |
| 150 } | 152 } |
| 151 return true; | 153 return true; |
| 152 } | 154 } |
| 153 | 155 |
| 156 const DisplayInfo::Rotation GetNextRotation(DisplayInfo::Rotation current) { |
| 157 switch (current) { |
| 158 case DisplayInfo::Rotate0: |
| 159 return DisplayInfo::Rotate90; |
| 160 case DisplayInfo::Rotate90: |
| 161 return DisplayInfo::Rotate180; |
| 162 case DisplayInfo::Rotate180: |
| 163 return DisplayInfo::Rotate270; |
| 164 case DisplayInfo::Rotate270: |
| 165 return DisplayInfo::Rotate0; |
| 166 } |
| 167 NOTREACHED() << "Unknown rotation:" << current; |
| 168 return DisplayInfo::Rotate0; |
| 169 } |
| 170 |
| 154 // Rotates the screen. | 171 // Rotates the screen. |
| 155 bool HandleRotateScreen() { | 172 bool HandleRotateScreen() { |
| 156 static int i = 0; | 173 aura::Window* active_window = wm::GetActiveWindow(); |
| 157 int delta = 0; | 174 if (!active_window) |
| 158 switch (i) { | 175 return false; |
| 159 case 0: delta = 90; break; | 176 const gfx::Display& display = |
| 160 case 1: delta = 90; break; | 177 Shell::GetScreen()->GetDisplayNearestWindow(active_window); |
| 161 case 2: delta = 90; break; | 178 const DisplayInfo& display_info = |
| 162 case 3: delta = 90; break; | 179 Shell::GetInstance()->display_manager()->GetDisplayInfo(display); |
| 163 case 4: delta = -90; break; | 180 Shell::GetInstance()->display_manager()->SetDisplayRotation( |
| 164 case 5: delta = -90; break; | 181 display.id(), GetNextRotation(display_info.rotation())); |
| 165 case 6: delta = -90; break; | |
| 166 case 7: delta = -90; break; | |
| 167 case 8: delta = -90; break; | |
| 168 case 9: delta = 180; break; | |
| 169 case 10: delta = 180; break; | |
| 170 case 11: delta = 90; break; | |
| 171 case 12: delta = 180; break; | |
| 172 case 13: delta = 180; break; | |
| 173 } | |
| 174 i = (i + 1) % 14; | |
| 175 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | |
| 176 for (size_t i = 0; i < root_windows.size(); ++i) { | |
| 177 aura::RootWindow* root_window = root_windows[i]; | |
| 178 root_window->layer()->GetAnimator()-> | |
| 179 set_preemption_strategy(ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); | |
| 180 scoped_ptr<ui::LayerAnimationSequence> screen_rotation( | |
| 181 new ui::LayerAnimationSequence( | |
| 182 new ash::ScreenRotation(delta, root_window->layer()))); | |
| 183 screen_rotation->AddObserver(root_window); | |
| 184 root_window->layer()->GetAnimator()-> | |
| 185 StartAnimation(screen_rotation.release()); | |
| 186 } | |
| 187 return true; | 182 return true; |
| 188 } | 183 } |
| 189 | 184 |
| 190 bool HandleToggleDesktopBackgroundMode() { | 185 bool HandleToggleDesktopBackgroundMode() { |
| 191 DesktopBackgroundController* desktop_background_controller = | 186 DesktopBackgroundController* desktop_background_controller = |
| 192 Shell::GetInstance()->desktop_background_controller(); | 187 Shell::GetInstance()->desktop_background_controller(); |
| 193 if (desktop_background_controller->desktop_background_mode() == | 188 if (desktop_background_controller->desktop_background_mode() == |
| 194 DesktopBackgroundController::BACKGROUND_IMAGE) { | 189 DesktopBackgroundController::BACKGROUND_IMAGE) { |
| 195 desktop_background_controller->SetDesktopBackgroundSolidColorMode( | 190 desktop_background_controller->SetDesktopBackgroundSolidColorMode( |
| 196 SK_ColorBLACK); | 191 SK_ColorBLACK); |
| (...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 866 keyboard_brightness_control_delegate) { | 861 keyboard_brightness_control_delegate) { |
| 867 keyboard_brightness_control_delegate_ = | 862 keyboard_brightness_control_delegate_ = |
| 868 keyboard_brightness_control_delegate.Pass(); | 863 keyboard_brightness_control_delegate.Pass(); |
| 869 } | 864 } |
| 870 | 865 |
| 871 bool AcceleratorController::CanHandleAccelerators() const { | 866 bool AcceleratorController::CanHandleAccelerators() const { |
| 872 return true; | 867 return true; |
| 873 } | 868 } |
| 874 | 869 |
| 875 } // namespace ash | 870 } // namespace ash |
| OLD | NEW |