| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/accelerators/accelerator_commands_aura.h" | 5 #include "ash/accelerators/accelerator_commands_aura.h" |
| 6 | 6 |
| 7 #include "ash/common/wm/window_state.h" | 7 #include "ash/common/wm/window_state.h" |
| 8 #include "ash/common/wm_window.h" | 8 #include "ash/common/wm_window.h" |
| 9 #include "ash/display/display_manager.h" | 9 #include "ash/display/display_manager.h" |
| 10 #include "ash/display/display_util.h" | |
| 11 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 12 #include "ash/wm/screen_pinning_controller.h" | 11 #include "ash/wm/screen_pinning_controller.h" |
| 13 #include "base/metrics/user_metrics.h" | 12 #include "base/metrics/user_metrics.h" |
| 14 #include "ui/display/manager/managed_display_info.h" | 13 #include "ui/display/manager/managed_display_info.h" |
| 15 | 14 |
| 16 namespace ash { | 15 namespace ash { |
| 17 namespace accelerators { | 16 namespace accelerators { |
| 18 | 17 |
| 19 void ToggleTouchHudProjection() { | 18 void ToggleTouchHudProjection() { |
| 20 base::RecordAction(base::UserMetricsAction("Accel_Touch_Hud_Clear")); | 19 base::RecordAction(base::UserMetricsAction("Accel_Touch_Hud_Clear")); |
| 21 bool enabled = Shell::GetInstance()->is_touch_hud_projection_enabled(); | 20 bool enabled = Shell::GetInstance()->is_touch_hud_projection_enabled(); |
| 22 Shell::GetInstance()->SetTouchHudProjectionEnabled(!enabled); | 21 Shell::GetInstance()->SetTouchHudProjectionEnabled(!enabled); |
| 23 } | 22 } |
| 24 | 23 |
| 25 bool IsInternalDisplayZoomEnabled() { | 24 bool IsInternalDisplayZoomEnabled() { |
| 26 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 25 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 27 return display_manager->IsDisplayUIScalingEnabled() || | 26 return display_manager->IsDisplayUIScalingEnabled() || |
| 28 display_manager->IsInUnifiedMode(); | 27 display_manager->IsInUnifiedMode(); |
| 29 } | 28 } |
| 30 | 29 |
| 31 bool ZoomInternalDisplay(bool up) { | 30 bool ZoomInternalDisplay(bool up) { |
| 32 if (up) | 31 if (up) |
| 33 base::RecordAction(base::UserMetricsAction("Accel_Scale_Ui_Up")); | 32 base::RecordAction(base::UserMetricsAction("Accel_Scale_Ui_Up")); |
| 34 else | 33 else |
| 35 base::RecordAction(base::UserMetricsAction("Accel_Scale_Ui_Down")); | 34 base::RecordAction(base::UserMetricsAction("Accel_Scale_Ui_Down")); |
| 36 | 35 |
| 37 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 36 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 38 | 37 return display_manager->ZoomInternalDisplay(up); |
| 39 int64_t display_id = display_manager->IsInUnifiedMode() | |
| 40 ? DisplayManager::kUnifiedDisplayId | |
| 41 : display_manager->GetDisplayIdForUIScaling(); | |
| 42 const display::ManagedDisplayInfo& display_info = | |
| 43 display_manager->GetDisplayInfo(display_id); | |
| 44 | |
| 45 scoped_refptr<display::ManagedDisplayMode> mode; | |
| 46 if (display_manager->IsInUnifiedMode()) | |
| 47 mode = GetDisplayModeForNextResolution(display_info, up); | |
| 48 else | |
| 49 mode = GetDisplayModeForNextUIScale(display_info, up); | |
| 50 | |
| 51 if (!mode) | |
| 52 return false; | |
| 53 return display_manager->SetDisplayMode(display_id, mode); | |
| 54 } | 38 } |
| 55 | 39 |
| 56 void ResetInternalDisplayZoom() { | 40 void ResetInternalDisplayZoom() { |
| 57 base::RecordAction(base::UserMetricsAction("Accel_Scale_Ui_Reset")); | 41 base::RecordAction(base::UserMetricsAction("Accel_Scale_Ui_Reset")); |
| 58 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 42 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 59 | 43 display_manager->ResetInternalDisplayZoom(); |
| 60 if (display_manager->IsInUnifiedMode()) { | |
| 61 const display::ManagedDisplayInfo& display_info = | |
| 62 display_manager->GetDisplayInfo(DisplayManager::kUnifiedDisplayId); | |
| 63 const display::ManagedDisplayInfo::ManagedDisplayModeList& modes = | |
| 64 display_info.display_modes(); | |
| 65 auto iter = std::find_if( | |
| 66 modes.begin(), modes.end(), | |
| 67 [](const scoped_refptr<display::ManagedDisplayMode>& mode) { | |
| 68 return mode->native(); | |
| 69 }); | |
| 70 display_manager->SetDisplayMode(DisplayManager::kUnifiedDisplayId, *iter); | |
| 71 } else { | |
| 72 SetDisplayUIScale(display_manager->GetDisplayIdForUIScaling(), 1.0f); | |
| 73 } | |
| 74 } | 44 } |
| 75 | 45 |
| 76 void Unpin() { | 46 void Unpin() { |
| 77 WmWindow* pinned_window = | 47 WmWindow* pinned_window = |
| 78 Shell::GetInstance()->screen_pinning_controller()->pinned_window(); | 48 Shell::GetInstance()->screen_pinning_controller()->pinned_window(); |
| 79 if (pinned_window) | 49 if (pinned_window) |
| 80 pinned_window->GetWindowState()->Restore(); | 50 pinned_window->GetWindowState()->Restore(); |
| 81 } | 51 } |
| 82 | 52 |
| 83 } // namespace accelerators | 53 } // namespace accelerators |
| 84 } // namespace ash | 54 } // namespace ash |
| OLD | NEW |