Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1014)

Unified Diff: ash/accelerators/accelerator_controller.cc

Issue 10388141: Full-screen Magnifier: Support warping the cursor on the edge (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: sync Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ash/accelerators/accelerator_table.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/accelerators/accelerator_controller.cc
diff --git a/ash/accelerators/accelerator_controller.cc b/ash/accelerators/accelerator_controller.cc
index 6690675fab0c945df213a187567aa87c3ec757a1..37ffbb6eed841c3f810bfbfa76613ccd0d998974 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 DebugShortcutsEnabled() {
#if defined(NDEBUG)
return CommandLine::ForCurrentProcess()->HasSwitch(
@@ -236,6 +244,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
@@ -564,6 +588,10 @@ bool AcceleratorController::PerformAction(int action,
internal::MultiMonitorManager::ToggleMonitorScale();
return true;
#if !defined(NDEBUG)
+ case MAGNIFY_SCREEN_ZOOM_IN:
+ return HandleMagnifyScreen(1);
+ case MAGNIFY_SCREEN_ZOOM_OUT:
+ return HandleMagnifyScreen(-1);
case PRINT_LAYER_HIERARCHY:
return HandlePrintLayerHierarchy();
case PRINT_WINDOW_HIERARCHY:
« no previous file with comments | « no previous file | ash/accelerators/accelerator_table.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698