Index: ash/accelerators/accelerator_controller.cc |
diff --git a/ash/accelerators/accelerator_controller.cc b/ash/accelerators/accelerator_controller.cc |
index 8194d90d71fb5136a4eb9bf1f3871b2139e249cb..9bcf23318c5ec3949a5bd6c252948b3b756ca02c 100644 |
--- a/ash/accelerators/accelerator_controller.cc |
+++ b/ash/accelerators/accelerator_controller.cc |
@@ -154,7 +154,7 @@ bool HandleRotateActiveWindow() { |
return true; |
} |
-const gfx::Display::Rotation GetNextRotation(gfx::Display::Rotation current) { |
+gfx::Display::Rotation GetNextRotation(gfx::Display::Rotation current) { |
switch (current) { |
case gfx::Display::ROTATE_0: |
return gfx::Display::ROTATE_90; |
@@ -169,13 +169,45 @@ const gfx::Display::Rotation GetNextRotation(gfx::Display::Rotation current) { |
return gfx::Display::ROTATE_0; |
} |
+float GetNextScale(float scale, bool up) { |
+ // These scales are equivalent to 1024, 1280, 1600 and 1920 pixel width |
+ // respectively on 2560 pixel width 2x density display. |
+ static const float kScales[] = {0.8f, 1.0f, 1.25f, 1.5f}; |
+ static const size_t kScaleTableSize = arraysize(kScales); |
+ for (size_t i = 0; i < kScaleTableSize; ++i) { |
+ if (kScales[i] == scale) { |
+ if (up && i != kScaleTableSize -1) |
James Cook
2013/03/15 17:09:38
nit: "kScaleTableSize - 1"
|
+ return kScales[i + 1]; |
+ if (!up && i != 0) |
+ return kScales[i - 1]; |
+ return kScales[i]; |
+ } |
+ } |
+ // Fallback to 1.0f if the |scale| wasn't in the list. |
+ return 1.0f; |
+} |
+ |
+bool HandleScaleUI(bool up) { |
+ // UI Scaling is effective only on internal display. |
+ int64 display_id = gfx::Display::InternalDisplayId(); |
+#if defined(OS_CHROMEOS) |
+ // On linux desktop, allow ui scalacing on the first dislpay. |
+ if (!base::chromeos::IsRunningOnChromeOS()) |
+ display_id = Shell::GetInstance()->display_manager()->first_display_id(); |
+#endif |
+ const gfx::Display& display = Shell::GetInstance()->display_manager()-> |
+ GetDisplayForId(display_id); |
+ const DisplayInfo& display_info = Shell::GetInstance()->display_manager()-> |
+ GetDisplayInfo(display); |
+ Shell::GetInstance()->display_manager()->SetDisplayUIScale( |
+ display.id(), GetNextScale(display_info.ui_scale(), up)); |
+ return true; |
+} |
+ |
// Rotates the screen. |
bool HandleRotateScreen() { |
- aura::Window* active_window = wm::GetActiveWindow(); |
- if (!active_window) |
- return false; |
- const gfx::Display& display = |
- Shell::GetScreen()->GetDisplayNearestWindow(active_window); |
+ gfx::Point point = Shell::GetScreen()->GetCursorScreenPoint(); |
+ gfx::Display display = Shell::GetScreen()->GetDisplayNearestPoint(point); |
const DisplayInfo& display_info = |
Shell::GetInstance()->display_manager()->GetDisplayInfo(display); |
Shell::GetInstance()->display_manager()->SetDisplayRotation( |
@@ -758,6 +790,10 @@ bool AcceleratorController::PerformAction(int action, |
} |
break; |
} |
+ case SCALE_UI_UP: |
+ return HandleScaleUI(true /* up */); |
+ case SCALE_UI_DOWN: |
+ return HandleScaleUI(false /* down */); |
case ROTATE_WINDOW: |
return HandleRotateActiveWindow(); |
case ROTATE_SCREEN: |
@@ -767,7 +803,7 @@ bool AcceleratorController::PerformAction(int action, |
case TOGGLE_ROOT_WINDOW_FULL_SCREEN: |
return HandleToggleRootWindowFullScreen(); |
case DISPLAY_TOGGLE_SCALE: |
- internal::DisplayManager::ToggleDisplayScale(); |
+ internal::DisplayManager::ToggleDisplayScaleFactor(); |
return true; |
case MAGNIFY_SCREEN_ZOOM_IN: |
return HandleMagnifyScreen(1); |