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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 #include "ui/views/widget/widget.h" | 62 #include "ui/views/widget/widget.h" |
63 | 63 |
64 #if defined(OS_CHROMEOS) | 64 #if defined(OS_CHROMEOS) |
65 #include "ash/system/chromeos/keyboard_brightness_controller.h" | 65 #include "ash/system/chromeos/keyboard_brightness_controller.h" |
66 #include "base/chromeos/chromeos_version.h" | 66 #include "base/chromeos/chromeos_version.h" |
67 #endif // defined(OS_CHROMEOS) | 67 #endif // defined(OS_CHROMEOS) |
68 | 68 |
69 namespace ash { | 69 namespace ash { |
70 namespace { | 70 namespace { |
71 | 71 |
| 72 using internal::DisplayInfo; |
| 73 |
72 // Factor of magnification scale. For example, when this value is 1.189, scale | 74 // Factor of magnification scale. For example, when this value is 1.189, scale |
73 // value will be changed x1.000, x1.189, x1.414, x1.681, x2.000, ... | 75 // value will be changed x1.000, x1.189, x1.414, x1.681, x2.000, ... |
74 // Note: this value is 2.0 ^ (1 / 4). | 76 // Note: this value is 2.0 ^ (1 / 4). |
75 const float kMagnificationFactor = 1.18920712f; | 77 const float kMagnificationFactor = 1.18920712f; |
76 | 78 |
77 bool DebugShortcutsEnabled() { | 79 bool DebugShortcutsEnabled() { |
78 #if defined(NDEBUG) | 80 #if defined(NDEBUG) |
79 return CommandLine::ForCurrentProcess()->HasSwitch( | 81 return CommandLine::ForCurrentProcess()->HasSwitch( |
80 switches::kAshDebugShortcuts); | 82 switches::kAshDebugShortcuts); |
81 #else | 83 #else |
(...skipping 63 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. | 147 // rotation and position. Use replace so we only enqueue one at a time. |
146 active_window->layer()->GetAnimator()-> | 148 active_window->layer()->GetAnimator()-> |
147 set_preemption_strategy(ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); | 149 set_preemption_strategy(ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); |
148 active_window->layer()->GetAnimator()->StartAnimation( | 150 active_window->layer()->GetAnimator()->StartAnimation( |
149 new ui::LayerAnimationSequence( | 151 new ui::LayerAnimationSequence( |
150 new ash::ScreenRotation(360, active_window->layer()))); | 152 new ash::ScreenRotation(360, active_window->layer()))); |
151 } | 153 } |
152 return true; | 154 return true; |
153 } | 155 } |
154 | 156 |
| 157 const DisplayInfo::Rotation GetNextRotation(DisplayInfo::Rotation current) { |
| 158 switch (current) { |
| 159 case DisplayInfo::ROTATE_0: |
| 160 return DisplayInfo::ROTATE_90; |
| 161 case DisplayInfo::ROTATE_90: |
| 162 return DisplayInfo::ROTATE_180; |
| 163 case DisplayInfo::ROTATE_180: |
| 164 return DisplayInfo::ROTATE_270; |
| 165 case DisplayInfo::ROTATE_270: |
| 166 return DisplayInfo::ROTATE_0; |
| 167 } |
| 168 NOTREACHED() << "Unknown rotation:" << current; |
| 169 return DisplayInfo::ROTATE_0; |
| 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 Shell::GetScreen()->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 |