Index: ash/accelerators/accelerator_commands.cc |
diff --git a/ash/accelerators/accelerator_commands.cc b/ash/accelerators/accelerator_commands.cc |
index c49ed5020ea6440971f5a1a62e0ba7c7664c1136..83e5d26da67e54cc64b71153a6a45342691c6b42 100644 |
--- a/ash/accelerators/accelerator_commands.cc |
+++ b/ash/accelerators/accelerator_commands.cc |
@@ -4,6 +4,8 @@ |
#include "ash/accelerators/accelerator_commands.h" |
+#include "ash/display/display_manager.h" |
+#include "ash/display/display_util.h" |
#include "ash/shell.h" |
#include "ash/shell_delegate.h" |
#include "ash/wm/mru_window_tracker.h" |
@@ -56,5 +58,52 @@ void ToggleTouchHudProjection() { |
Shell::GetInstance()->SetTouchHudProjectionEnabled(!enabled); |
} |
+bool IsInternalDisplayZoomEnabled() { |
+ DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
+ return display_manager->IsDisplayUIScalingEnabled() || |
+ display_manager->IsInUnifiedMode(); |
+} |
+ |
+bool ZoomInternalDisplay(bool up) { |
+ if (up) |
+ base::RecordAction(base::UserMetricsAction("Accel_Scale_Ui_Up")); |
+ else |
+ base::RecordAction(base::UserMetricsAction("Accel_Scale_Ui_Down")); |
+ |
+ DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
+ |
+ int64 display_id = display_manager->IsInUnifiedMode() |
+ ? DisplayManager::kUnifiedDisplayId |
+ : display_manager->GetDisplayIdForUIScaling(); |
+ const DisplayInfo& display_info = display_manager->GetDisplayInfo(display_id); |
+ DisplayMode mode; |
+ |
+ if (display_manager->IsInUnifiedMode()) { |
+ if (!GetDisplayModeForNextResolution(display_info, up, &mode)) |
+ return false; |
+ } else { |
+ if (!GetDisplayModeForNextUIScale(display_info, up, &mode)) |
+ return false; |
+ } |
+ return display_manager->SetDisplayMode(display_id, mode); |
+} |
+ |
+void ResetInternalDisplayZoom() { |
+ base::RecordAction(base::UserMetricsAction("Accel_Scale_Ui_Reset")); |
+ DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
+ |
+ if (display_manager->IsInUnifiedMode()) { |
+ const DisplayInfo& display_info = |
+ display_manager->GetDisplayInfo(DisplayManager::kUnifiedDisplayId); |
+ const std::vector<DisplayMode>& modes = display_info.display_modes(); |
+ auto iter = |
+ std::find_if(modes.begin(), modes.end(), |
+ [](const DisplayMode& mode) { return mode.native; }); |
+ display_manager->SetDisplayMode(DisplayManager::kUnifiedDisplayId, *iter); |
+ } else { |
+ SetDisplayUIScale(display_manager->GetDisplayIdForUIScaling(), 1.0f); |
+ } |
+} |
+ |
} // namespace accelerators |
} // namespace ash |