Index: ash/accelerators/accelerator_controller.cc |
diff --git a/ash/accelerators/accelerator_controller.cc b/ash/accelerators/accelerator_controller.cc |
index 62b33ba7be86fc164ade89b5eb0ae96de3906c55..b751a8a579f98fffaf9c077b7423c4235d79b38f 100644 |
--- a/ash/accelerators/accelerator_controller.cc |
+++ b/ash/accelerators/accelerator_controller.cc |
@@ -154,7 +154,7 @@ bool HandleRotateActiveWindow() { |
return true; |
} |
-const DisplayInfo::Rotation GetNextRotation(DisplayInfo::Rotation current) { |
+DisplayInfo::Rotation GetNextRotation(DisplayInfo::Rotation current) { |
switch (current) { |
case DisplayInfo::ROTATE_0: |
return DisplayInfo::ROTATE_90; |
@@ -169,13 +169,38 @@ const DisplayInfo::Rotation GetNextRotation(DisplayInfo::Rotation current) { |
return DisplayInfo::ROTATE_0; |
} |
+float GetNextScale(float scale, int next) { |
+ // 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 int size = arraysize(kScales); |
James Cook
2013/03/14 17:50:43
size -> kScalesSize, or inline the use of arraysiz
oshima
2013/03/14 19:56:15
Done.
|
+ int index = std::distance(kScales, std::find(kScales, kScales + size, scale)); |
+ // Fallback to 1.0f if the |scale| wasn't in the list. |
+ index = index == size ? 1 : index + next; |
+ return kScales[std::max(std::min(3, index), 0)]; |
James Cook
2013/03/14 17:50:43
Use size-1 instead of 3.
oshima
2013/03/14 19:56:15
Done.
|
+} |
+ |
+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 scaling 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 ? 1 : -1)); |
+ 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( |
@@ -756,6 +781,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: |
@@ -765,7 +794,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); |