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 <cmath> |
| 8 |
7 #include "ash/accelerators/accelerator_table.h" | 9 #include "ash/accelerators/accelerator_table.h" |
8 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
9 #include "ash/caps_lock_delegate.h" | 11 #include "ash/caps_lock_delegate.h" |
10 #include "ash/desktop_background/desktop_background_controller.h" | 12 #include "ash/desktop_background/desktop_background_controller.h" |
11 #include "ash/focus_cycler.h" | 13 #include "ash/focus_cycler.h" |
12 #include "ash/ime_control_delegate.h" | 14 #include "ash/ime_control_delegate.h" |
13 #include "ash/launcher/launcher.h" | 15 #include "ash/launcher/launcher.h" |
14 #include "ash/launcher/launcher_delegate.h" | 16 #include "ash/launcher/launcher_delegate.h" |
15 #include "ash/launcher/launcher_model.h" | 17 #include "ash/launcher/launcher_model.h" |
| 18 #include "ash/magnifier/magnification_controller.h" |
16 #include "ash/monitor/monitor_controller.h" | 19 #include "ash/monitor/monitor_controller.h" |
17 #include "ash/monitor/multi_monitor_manager.h" | 20 #include "ash/monitor/multi_monitor_manager.h" |
18 #include "ash/root_window_controller.h" | 21 #include "ash/root_window_controller.h" |
19 #include "ash/screenshot_delegate.h" | 22 #include "ash/screenshot_delegate.h" |
20 #include "ash/shell.h" | 23 #include "ash/shell.h" |
21 #include "ash/shell_delegate.h" | 24 #include "ash/shell_delegate.h" |
22 #include "ash/shell_window_ids.h" | 25 #include "ash/shell_window_ids.h" |
23 #include "ash/system/brightness/brightness_control_delegate.h" | 26 #include "ash/system/brightness/brightness_control_delegate.h" |
24 #include "ash/system/tray/system_tray.h" | 27 #include "ash/system/tray/system_tray.h" |
25 #include "ash/volume_control_delegate.h" | 28 #include "ash/volume_control_delegate.h" |
(...skipping 14 matching lines...) Expand all Loading... |
40 #include "ui/compositor/screen_rotation.h" | 43 #include "ui/compositor/screen_rotation.h" |
41 #include "ui/oak/oak.h" | 44 #include "ui/oak/oak.h" |
42 | 45 |
43 #if defined(OS_CHROMEOS) | 46 #if defined(OS_CHROMEOS) |
44 #include "chromeos/monitor/output_configurator.h" | 47 #include "chromeos/monitor/output_configurator.h" |
45 #endif // defined(OS_CHROMEOS) | 48 #endif // defined(OS_CHROMEOS) |
46 | 49 |
47 namespace ash { | 50 namespace ash { |
48 namespace { | 51 namespace { |
49 | 52 |
| 53 // Factor of magnification scale. For example, when this value is 1.189, scale |
| 54 // value will be changed x1.000, x1.189, x1.414, x1.681, x2.000, ... |
| 55 // Note: this value is 2.0 ^ (1 / 4). |
| 56 const float kMagnificationFactor = 1.18920712; |
| 57 |
50 bool HandleCycleWindowMRU(WindowCycleController::Direction direction, | 58 bool HandleCycleWindowMRU(WindowCycleController::Direction direction, |
51 bool is_alt_down) { | 59 bool is_alt_down) { |
52 Shell::GetInstance()-> | 60 Shell::GetInstance()-> |
53 window_cycle_controller()->HandleCycleWindow(direction, is_alt_down); | 61 window_cycle_controller()->HandleCycleWindow(direction, is_alt_down); |
54 // Always report we handled the key, even if the window didn't change. | 62 // Always report we handled the key, even if the window didn't change. |
55 return true; | 63 return true; |
56 } | 64 } |
57 | 65 |
58 void HandleCycleWindowLinear(CycleDirection direction) { | 66 void HandleCycleWindowLinear(CycleDirection direction) { |
59 Shell::GetInstance()->launcher()->CycleWindowLinear(direction); | 67 Shell::GetInstance()->launcher()->CycleWindowLinear(direction); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 | 216 |
209 bool HandlePrintWindowHierarchy() { | 217 bool HandlePrintWindowHierarchy() { |
210 DLOG(INFO) << "Window hierarchy:"; | 218 DLOG(INFO) << "Window hierarchy:"; |
211 aura::Window* container = | 219 aura::Window* container = |
212 Shell::GetPrimaryRootWindowController()->GetContainer( | 220 Shell::GetPrimaryRootWindowController()->GetContainer( |
213 internal::kShellWindowId_DefaultContainer); | 221 internal::kShellWindowId_DefaultContainer); |
214 PrintWindowHierarchy(container, 0); | 222 PrintWindowHierarchy(container, 0); |
215 return true; | 223 return true; |
216 } | 224 } |
217 | 225 |
| 226 // Magnify the screen |
| 227 bool HandleMagnifyScreen(int delta_index) { |
| 228 float scale = |
| 229 ash::Shell::GetInstance()->magnification_controller()->GetScale(); |
| 230 // Calculate rounded logarithm (base kMagnificationFactor) of scale. |
| 231 int scale_index = |
| 232 std::floor(std::log(scale) / std::log(kMagnificationFactor) + 0.5); |
| 233 |
| 234 int new_scale_index = std::max(0, std::min(8, scale_index + delta_index)); |
| 235 |
| 236 ash::Shell::GetInstance()->magnification_controller()-> |
| 237 SetScale(std::pow(kMagnificationFactor, new_scale_index), true); |
| 238 |
| 239 return true; |
| 240 } |
| 241 |
218 #endif // !defined(NDEBUG) | 242 #endif // !defined(NDEBUG) |
219 | 243 |
220 } // namespace | 244 } // namespace |
221 | 245 |
222 //////////////////////////////////////////////////////////////////////////////// | 246 //////////////////////////////////////////////////////////////////////////////// |
223 // AcceleratorController, public: | 247 // AcceleratorController, public: |
224 | 248 |
225 AcceleratorController::AcceleratorController() | 249 AcceleratorController::AcceleratorController() |
226 : accelerator_manager_(new ui::AcceleratorManager) { | 250 : accelerator_manager_(new ui::AcceleratorManager) { |
227 Init(); | 251 Init(); |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 return HandlePrintWindowHierarchy(); | 542 return HandlePrintWindowHierarchy(); |
519 case MONITOR_ADD_REMOVE: | 543 case MONITOR_ADD_REMOVE: |
520 internal::MultiMonitorManager::AddRemoveMonitor(); | 544 internal::MultiMonitorManager::AddRemoveMonitor(); |
521 return true; | 545 return true; |
522 case MONITOR_CYCLE: | 546 case MONITOR_CYCLE: |
523 internal::MultiMonitorManager::CycleMonitor(); | 547 internal::MultiMonitorManager::CycleMonitor(); |
524 return true; | 548 return true; |
525 case MONITOR_TOGGLE_SCALE: | 549 case MONITOR_TOGGLE_SCALE: |
526 internal::MultiMonitorManager::ToggleMonitorScale(); | 550 internal::MultiMonitorManager::ToggleMonitorScale(); |
527 return true; | 551 return true; |
| 552 case MAGNIFY_SCREEN_ZOOM_IN: |
| 553 return HandleMagnifyScreen(1); |
| 554 case MAGNIFY_SCREEN_ZOOM_OUT: |
| 555 return HandleMagnifyScreen(-1); |
528 #endif | 556 #endif |
529 default: | 557 default: |
530 NOTREACHED() << "Unhandled action " << action; | 558 NOTREACHED() << "Unhandled action " << action; |
531 } | 559 } |
532 return false; | 560 return false; |
533 } | 561 } |
534 | 562 |
535 void AcceleratorController::SetBrightnessControlDelegate( | 563 void AcceleratorController::SetBrightnessControlDelegate( |
536 scoped_ptr<BrightnessControlDelegate> brightness_control_delegate) { | 564 scoped_ptr<BrightnessControlDelegate> brightness_control_delegate) { |
537 brightness_control_delegate_.swap(brightness_control_delegate); | 565 brightness_control_delegate_.swap(brightness_control_delegate); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 // Then set this one as active. | 622 // Then set this one as active. |
595 Shell::GetInstance()->launcher()->ActivateLauncherItem(found_index); | 623 Shell::GetInstance()->launcher()->ActivateLauncherItem(found_index); |
596 } | 624 } |
597 } | 625 } |
598 | 626 |
599 bool AcceleratorController::CanHandleAccelerators() const { | 627 bool AcceleratorController::CanHandleAccelerators() const { |
600 return true; | 628 return true; |
601 } | 629 } |
602 | 630 |
603 } // namespace ash | 631 } // namespace ash |
OLD | NEW |