| 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 DebugShortcutsEnabled() { | 58 bool DebugShortcutsEnabled() { |
| 51 #if defined(NDEBUG) | 59 #if defined(NDEBUG) |
| 52 return CommandLine::ForCurrentProcess()->HasSwitch( | 60 return CommandLine::ForCurrentProcess()->HasSwitch( |
| 53 switches::kAshDebugShortcuts); | 61 switches::kAshDebugShortcuts); |
| 54 #else | 62 #else |
| 55 return true; | 63 return true; |
| 56 #endif | 64 #endif |
| 57 } | 65 } |
| 58 | 66 |
| 59 bool HandleCycleWindowMRU(WindowCycleController::Direction direction, | 67 bool HandleCycleWindowMRU(WindowCycleController::Direction direction, |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 | 237 |
| 230 bool HandlePrintWindowHierarchy() { | 238 bool HandlePrintWindowHierarchy() { |
| 231 DLOG(INFO) << "Window hierarchy:"; | 239 DLOG(INFO) << "Window hierarchy:"; |
| 232 aura::Window* container = | 240 aura::Window* container = |
| 233 Shell::GetPrimaryRootWindowController()->GetContainer( | 241 Shell::GetPrimaryRootWindowController()->GetContainer( |
| 234 internal::kShellWindowId_DefaultContainer); | 242 internal::kShellWindowId_DefaultContainer); |
| 235 PrintWindowHierarchy(container, 0); | 243 PrintWindowHierarchy(container, 0); |
| 236 return true; | 244 return true; |
| 237 } | 245 } |
| 238 | 246 |
| 247 // Magnify the screen |
| 248 bool HandleMagnifyScreen(int delta_index) { |
| 249 float scale = |
| 250 ash::Shell::GetInstance()->magnification_controller()->GetScale(); |
| 251 // Calculate rounded logarithm (base kMagnificationFactor) of scale. |
| 252 int scale_index = |
| 253 std::floor(std::log(scale) / std::log(kMagnificationFactor) + 0.5); |
| 254 |
| 255 int new_scale_index = std::max(0, std::min(8, scale_index + delta_index)); |
| 256 |
| 257 ash::Shell::GetInstance()->magnification_controller()-> |
| 258 SetScale(std::pow(kMagnificationFactor, new_scale_index), true); |
| 259 |
| 260 return true; |
| 261 } |
| 262 |
| 239 #endif // !defined(NDEBUG) | 263 #endif // !defined(NDEBUG) |
| 240 | 264 |
| 241 } // namespace | 265 } // namespace |
| 242 | 266 |
| 243 //////////////////////////////////////////////////////////////////////////////// | 267 //////////////////////////////////////////////////////////////////////////////// |
| 244 // AcceleratorController, public: | 268 // AcceleratorController, public: |
| 245 | 269 |
| 246 AcceleratorController::AcceleratorController() | 270 AcceleratorController::AcceleratorController() |
| 247 : accelerator_manager_(new ui::AcceleratorManager) { | 271 : accelerator_manager_(new ui::AcceleratorManager) { |
| 248 Init(); | 272 Init(); |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 return true; | 581 return true; |
| 558 case MONITOR_CYCLE: | 582 case MONITOR_CYCLE: |
| 559 if (DebugShortcutsEnabled()) | 583 if (DebugShortcutsEnabled()) |
| 560 internal::MultiMonitorManager::CycleMonitor(); | 584 internal::MultiMonitorManager::CycleMonitor(); |
| 561 return true; | 585 return true; |
| 562 case MONITOR_TOGGLE_SCALE: | 586 case MONITOR_TOGGLE_SCALE: |
| 563 if (DebugShortcutsEnabled()) | 587 if (DebugShortcutsEnabled()) |
| 564 internal::MultiMonitorManager::ToggleMonitorScale(); | 588 internal::MultiMonitorManager::ToggleMonitorScale(); |
| 565 return true; | 589 return true; |
| 566 #if !defined(NDEBUG) | 590 #if !defined(NDEBUG) |
| 591 case MAGNIFY_SCREEN_ZOOM_IN: |
| 592 return HandleMagnifyScreen(1); |
| 593 case MAGNIFY_SCREEN_ZOOM_OUT: |
| 594 return HandleMagnifyScreen(-1); |
| 567 case PRINT_LAYER_HIERARCHY: | 595 case PRINT_LAYER_HIERARCHY: |
| 568 return HandlePrintLayerHierarchy(); | 596 return HandlePrintLayerHierarchy(); |
| 569 case PRINT_WINDOW_HIERARCHY: | 597 case PRINT_WINDOW_HIERARCHY: |
| 570 return HandlePrintWindowHierarchy(); | 598 return HandlePrintWindowHierarchy(); |
| 571 #endif | 599 #endif |
| 572 default: | 600 default: |
| 573 NOTREACHED() << "Unhandled action " << action; | 601 NOTREACHED() << "Unhandled action " << action; |
| 574 } | 602 } |
| 575 return false; | 603 return false; |
| 576 } | 604 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 // Then set this one as active. | 665 // Then set this one as active. |
| 638 Shell::GetInstance()->launcher()->ActivateLauncherItem(found_index); | 666 Shell::GetInstance()->launcher()->ActivateLauncherItem(found_index); |
| 639 } | 667 } |
| 640 } | 668 } |
| 641 | 669 |
| 642 bool AcceleratorController::CanHandleAccelerators() const { | 670 bool AcceleratorController::CanHandleAccelerators() const { |
| 643 return true; | 671 return true; |
| 644 } | 672 } |
| 645 | 673 |
| 646 } // namespace ash | 674 } // namespace ash |
| OLD | NEW |