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

Side by Side Diff: ash/accelerators/accelerator_commands_aura.cc

Issue 2270553002: Move ash::DisplayInfo to ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | ash/accelerators/accelerator_controller_delegate_aura.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/display/display_info.h"
8 #include "ash/common/wm/window_state.h" 7 #include "ash/common/wm/window_state.h"
9 #include "ash/common/wm_window.h" 8 #include "ash/common/wm_window.h"
10 #include "ash/display/display_manager.h" 9 #include "ash/display/display_manager.h"
11 #include "ash/display/display_util.h" 10 #include "ash/display/display_util.h"
12 #include "ash/shell.h" 11 #include "ash/shell.h"
13 #include "ash/wm/screen_pinning_controller.h" 12 #include "ash/wm/screen_pinning_controller.h"
14 #include "base/metrics/user_metrics.h" 13 #include "base/metrics/user_metrics.h"
14 #include "ui/display/manager/managed_display_info.h"
15 15
16 namespace ash { 16 namespace ash {
17 namespace accelerators { 17 namespace accelerators {
18 18
19 void ToggleTouchHudProjection() { 19 void ToggleTouchHudProjection() {
20 base::RecordAction(base::UserMetricsAction("Accel_Touch_Hud_Clear")); 20 base::RecordAction(base::UserMetricsAction("Accel_Touch_Hud_Clear"));
21 bool enabled = Shell::GetInstance()->is_touch_hud_projection_enabled(); 21 bool enabled = Shell::GetInstance()->is_touch_hud_projection_enabled();
22 Shell::GetInstance()->SetTouchHudProjectionEnabled(!enabled); 22 Shell::GetInstance()->SetTouchHudProjectionEnabled(!enabled);
23 } 23 }
24 24
25 bool IsInternalDisplayZoomEnabled() { 25 bool IsInternalDisplayZoomEnabled() {
26 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 26 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
27 return display_manager->IsDisplayUIScalingEnabled() || 27 return display_manager->IsDisplayUIScalingEnabled() ||
28 display_manager->IsInUnifiedMode(); 28 display_manager->IsInUnifiedMode();
29 } 29 }
30 30
31 bool ZoomInternalDisplay(bool up) { 31 bool ZoomInternalDisplay(bool up) {
32 if (up) 32 if (up)
33 base::RecordAction(base::UserMetricsAction("Accel_Scale_Ui_Up")); 33 base::RecordAction(base::UserMetricsAction("Accel_Scale_Ui_Up"));
34 else 34 else
35 base::RecordAction(base::UserMetricsAction("Accel_Scale_Ui_Down")); 35 base::RecordAction(base::UserMetricsAction("Accel_Scale_Ui_Down"));
36 36
37 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 37 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
38 38
39 int64_t display_id = display_manager->IsInUnifiedMode() 39 int64_t display_id = display_manager->IsInUnifiedMode()
40 ? DisplayManager::kUnifiedDisplayId 40 ? DisplayManager::kUnifiedDisplayId
41 : display_manager->GetDisplayIdForUIScaling(); 41 : display_manager->GetDisplayIdForUIScaling();
42 const DisplayInfo& display_info = display_manager->GetDisplayInfo(display_id); 42 const display::ManagedDisplayInfo& display_info =
43 display_manager->GetDisplayInfo(display_id);
43 44
44 scoped_refptr<ManagedDisplayMode> mode; 45 scoped_refptr<display::ManagedDisplayMode> mode;
45 if (display_manager->IsInUnifiedMode()) 46 if (display_manager->IsInUnifiedMode())
46 mode = GetDisplayModeForNextResolution(display_info, up); 47 mode = GetDisplayModeForNextResolution(display_info, up);
47 else 48 else
48 mode = GetDisplayModeForNextUIScale(display_info, up); 49 mode = GetDisplayModeForNextUIScale(display_info, up);
49 50
50 if (!mode) 51 if (!mode)
51 return false; 52 return false;
52 return display_manager->SetDisplayMode(display_id, mode); 53 return display_manager->SetDisplayMode(display_id, mode);
53 } 54 }
54 55
55 void ResetInternalDisplayZoom() { 56 void ResetInternalDisplayZoom() {
56 base::RecordAction(base::UserMetricsAction("Accel_Scale_Ui_Reset")); 57 base::RecordAction(base::UserMetricsAction("Accel_Scale_Ui_Reset"));
57 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 58 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
58 59
59 if (display_manager->IsInUnifiedMode()) { 60 if (display_manager->IsInUnifiedMode()) {
60 const DisplayInfo& display_info = 61 const display::ManagedDisplayInfo& display_info =
61 display_manager->GetDisplayInfo(DisplayManager::kUnifiedDisplayId); 62 display_manager->GetDisplayInfo(DisplayManager::kUnifiedDisplayId);
62 const DisplayInfo::ManagedDisplayModeList& modes = 63 const display::ManagedDisplayInfo::ManagedDisplayModeList& modes =
63 display_info.display_modes(); 64 display_info.display_modes();
64 auto iter = std::find_if(modes.begin(), modes.end(), 65 auto iter = std::find_if(
65 [](const scoped_refptr<ManagedDisplayMode>& mode) { 66 modes.begin(), modes.end(),
66 return mode->native(); 67 [](const scoped_refptr<display::ManagedDisplayMode>& mode) {
67 }); 68 return mode->native();
69 });
68 display_manager->SetDisplayMode(DisplayManager::kUnifiedDisplayId, *iter); 70 display_manager->SetDisplayMode(DisplayManager::kUnifiedDisplayId, *iter);
69 } else { 71 } else {
70 SetDisplayUIScale(display_manager->GetDisplayIdForUIScaling(), 1.0f); 72 SetDisplayUIScale(display_manager->GetDisplayIdForUIScaling(), 1.0f);
71 } 73 }
72 } 74 }
73 75
74 void Unpin() { 76 void Unpin() {
75 WmWindow* pinned_window = 77 WmWindow* pinned_window =
76 Shell::GetInstance()->screen_pinning_controller()->pinned_window(); 78 Shell::GetInstance()->screen_pinning_controller()->pinned_window();
77 if (pinned_window) 79 if (pinned_window)
78 pinned_window->GetWindowState()->Restore(); 80 pinned_window->GetWindowState()->Restore();
79 } 81 }
80 82
81 } // namespace accelerators 83 } // namespace accelerators
82 } // namespace ash 84 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/accelerators/accelerator_controller_delegate_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698