Index: ash/accelerators/accelerator_controller.cc |
diff --git a/ash/accelerators/accelerator_controller.cc b/ash/accelerators/accelerator_controller.cc |
index ffae155f74d1f89bfab5778352a1f227cbaeea6c..9f07173e5e27c192667313b1c3b052e67e26293c 100644 |
--- a/ash/accelerators/accelerator_controller.cc |
+++ b/ash/accelerators/accelerator_controller.cc |
@@ -4,6 +4,8 @@ |
#include "ash/accelerators/accelerator_controller.h" |
+#include <cmath> |
+ |
#include "ash/accelerators/accelerator_table.h" |
#include "ash/ash_switches.h" |
#include "ash/caps_lock_delegate.h" |
@@ -13,6 +15,7 @@ |
#include "ash/launcher/launcher.h" |
#include "ash/launcher/launcher_delegate.h" |
#include "ash/launcher/launcher_model.h" |
+#include "ash/magnifier/magnification_controller.h" |
#include "ash/monitor/monitor_controller.h" |
#include "ash/monitor/multi_monitor_manager.h" |
#include "ash/root_window_controller.h" |
@@ -47,6 +50,11 @@ |
namespace ash { |
namespace { |
+// Factor of magnification scale. For example, when this value is 1.189, scale |
+// value will be changed x1.000, x1.189, x1.414, x1.681, x2.000, ... |
+// Note: this value is 2.0 ^ (1 / 4). |
+const float kMagnificationFactor = 1.18920712; |
+ |
bool HandleCycleWindowMRU(WindowCycleController::Direction direction, |
bool is_alt_down) { |
Shell::GetInstance()-> |
@@ -215,6 +223,22 @@ bool HandlePrintWindowHierarchy() { |
return true; |
} |
+// Magnify the screen |
+bool HandleMagnifyScreen(int delta_index) { |
+ float scale = |
+ ash::Shell::GetInstance()->magnification_controller()->GetScale(); |
+ // Calculate rounded logarithm (base kMagnificationFactor) of scale. |
+ int scale_index = |
+ std::floor(std::log(scale) / std::log(kMagnificationFactor) + 0.5); |
+ |
+ int new_scale_index = std::max(0, std::min(8, scale_index + delta_index)); |
+ |
+ ash::Shell::GetInstance()->magnification_controller()-> |
+ SetScale(std::pow(kMagnificationFactor, new_scale_index), true); |
+ |
+ return true; |
+} |
+ |
#endif // !defined(NDEBUG) |
} // namespace |
@@ -525,6 +549,10 @@ bool AcceleratorController::PerformAction(int action, |
case MONITOR_TOGGLE_SCALE: |
internal::MultiMonitorManager::ToggleMonitorScale(); |
return true; |
+ case MAGNIFY_SCREEN_ZOOM_IN: |
+ return HandleMagnifyScreen(1); |
+ case MAGNIFY_SCREEN_ZOOM_OUT: |
+ return HandleMagnifyScreen(-1); |
#endif |
default: |
NOTREACHED() << "Unhandled action " << action; |