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

Side by Side Diff: ash/mus/accelerators/accelerator_controller_delegate_mus.cc

Issue 2537643008: Add IPCs for ash display shortcuts. (Closed)
Patch Set: Rebase. Created 4 years 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/mus/accelerators/accelerator_controller_delegate_mus.h" 5 #include "ash/mus/accelerators/accelerator_controller_delegate_mus.h"
6 6
7 #include "ash/mus/window_manager.h" 7 #include "ash/mus/window_manager.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "mash/public/interfaces/launchable.mojom.h" 9 #include "mash/public/interfaces/launchable.mojom.h"
10 #include "services/service_manager/public/cpp/connector.h" 10 #include "services/service_manager/public/cpp/connector.h"
11 #include "services/ui/public/interfaces/constants.mojom.h" 11 #include "services/ui/public/interfaces/constants.mojom.h"
12 #include "services/ui/public/interfaces/display/display_controller.mojom.h" 12 #include "services/ui/public/interfaces/display/display_controller.mojom.h"
13 #include "services/ui/public/interfaces/display/test_display_controller.mojom.h" 13 #include "services/ui/public/interfaces/display/test_display_controller.mojom.h"
14 #include "ui/display/screen.h"
14 15
15 namespace ash { 16 namespace ash {
16 namespace mus { 17 namespace mus {
17 18
18 AcceleratorControllerDelegateMus::AcceleratorControllerDelegateMus( 19 AcceleratorControllerDelegateMus::AcceleratorControllerDelegateMus(
19 WindowManager* window_manager) 20 WindowManager* window_manager)
20 : window_manager_(window_manager) { 21 : window_manager_(window_manager) {
21 #if !defined(OS_CHROMEOS) 22 #if !defined(OS_CHROMEOS)
22 // To avoid trybot complaining that |window_manager_| is not being used in 23 // To avoid trybot complaining that |window_manager_| is not being used in
23 // non-ChromeOS. 24 // non-ChromeOS.
24 window_manager_ = nullptr; 25 window_manager_ = nullptr;
25 #endif 26 #endif
26 } 27 }
27 28
28 AcceleratorControllerDelegateMus::~AcceleratorControllerDelegateMus() {} 29 AcceleratorControllerDelegateMus::~AcceleratorControllerDelegateMus() {}
29 30
30 bool AcceleratorControllerDelegateMus::HandlesAction(AcceleratorAction action) { 31 bool AcceleratorControllerDelegateMus::HandlesAction(AcceleratorAction action) {
31 // This is the list of actions that are not ported from aura. The actions are 32 // Accelerators that return true need to work differently in mash. These
32 // replicated here to make sure we don't forget any. This list should 33 // should have implementations in CanPerformAction() and PerformAction().
33 // eventually be empty. If there are any actions that don't make sense for 34 // Accelerators that return false have not been ported to work with mash yet.
34 // mus, then they should be removed from AcceleratorAction. 35 // If the behavior between cash and mash can be unified then the accelerator
36 // should be moved to accelerator_controller.cc/h. See
35 // http://crbug.com/612331. 37 // http://crbug.com/612331.
36 switch (action) { 38 switch (action) {
39 case SCALE_UI_DOWN:
40 case SCALE_UI_RESET:
41 case SCALE_UI_UP:
42 case ROTATE_SCREEN:
43 return true;
37 case DEBUG_TOGGLE_DEVICE_SCALE_FACTOR: 44 case DEBUG_TOGGLE_DEVICE_SCALE_FACTOR:
38 case DEV_TOGGLE_ROOT_WINDOW_FULL_SCREEN: 45 case DEV_TOGGLE_ROOT_WINDOW_FULL_SCREEN:
39 case DEBUG_TOGGLE_SHOW_DEBUG_BORDERS: 46 case DEBUG_TOGGLE_SHOW_DEBUG_BORDERS:
40 case DEBUG_TOGGLE_SHOW_FPS_COUNTER: 47 case DEBUG_TOGGLE_SHOW_FPS_COUNTER:
41 case DEBUG_TOGGLE_SHOW_PAINT_RECTS: 48 case DEBUG_TOGGLE_SHOW_PAINT_RECTS:
42 case MAGNIFY_SCREEN_ZOOM_IN: 49 case MAGNIFY_SCREEN_ZOOM_IN:
43 case MAGNIFY_SCREEN_ZOOM_OUT: 50 case MAGNIFY_SCREEN_ZOOM_OUT:
44 case ROTATE_SCREEN:
45 case ROTATE_WINDOW: 51 case ROTATE_WINDOW:
46 case SCALE_UI_DOWN:
47 case SCALE_UI_RESET:
48 case SCALE_UI_UP:
49 case SHOW_SYSTEM_TRAY_BUBBLE: 52 case SHOW_SYSTEM_TRAY_BUBBLE:
50 case TAKE_PARTIAL_SCREENSHOT: 53 case TAKE_PARTIAL_SCREENSHOT:
51 case TAKE_SCREENSHOT: 54 case TAKE_SCREENSHOT:
52 case TAKE_WINDOW_SCREENSHOT: 55 case TAKE_WINDOW_SCREENSHOT:
53 case UNPIN: 56 case UNPIN:
54 NOTIMPLEMENTED(); 57 NOTIMPLEMENTED();
55 return false; 58 return false;
56 59
57 #if defined(OS_CHROMEOS) 60 #if defined(OS_CHROMEOS)
58 case DEV_ADD_REMOVE_DISPLAY: 61 case DEV_ADD_REMOVE_DISPLAY:
59 case DEV_TOGGLE_UNIFIED_DESKTOP: 62 case DEV_TOGGLE_UNIFIED_DESKTOP:
60 case SWAP_PRIMARY_DISPLAY: 63 case SWAP_PRIMARY_DISPLAY:
64 case TOGGLE_MIRROR_MODE:
61 case TOUCH_HUD_PROJECTION_TOGGLE: 65 case TOUCH_HUD_PROJECTION_TOGGLE:
62 return true; 66 return true;
63 case LOCK_PRESSED: 67 case LOCK_PRESSED:
64 case LOCK_RELEASED: 68 case LOCK_RELEASED:
65 case POWER_PRESSED: 69 case POWER_PRESSED:
66 case POWER_RELEASED: 70 case POWER_RELEASED:
67 case TOGGLE_MIRROR_MODE:
68 case TOUCH_HUD_CLEAR: 71 case TOUCH_HUD_CLEAR:
69 case TOUCH_HUD_MODE_CHANGE: 72 case TOUCH_HUD_MODE_CHANGE:
70 NOTIMPLEMENTED(); 73 NOTIMPLEMENTED();
71 return false; 74 return false;
72 #endif 75 #endif
73 76
74 default: 77 default:
75 break; 78 break;
76 } 79 }
77 return false; 80 return false;
78 } 81 }
79 82
80 bool AcceleratorControllerDelegateMus::CanPerformAction( 83 bool AcceleratorControllerDelegateMus::CanPerformAction(
81 AcceleratorAction action, 84 AcceleratorAction action,
82 const ui::Accelerator& accelerator, 85 const ui::Accelerator& accelerator,
83 const ui::Accelerator& previous_accelerator) { 86 const ui::Accelerator& previous_accelerator) {
87 switch (action) {
88 case ROTATE_SCREEN:
89 case SCALE_UI_DOWN:
90 case SCALE_UI_RESET:
91 case SCALE_UI_UP:
92 return true;
84 #if defined(OS_CHROMEOS) 93 #if defined(OS_CHROMEOS)
85 switch (action) {
86 case DEV_ADD_REMOVE_DISPLAY: 94 case DEV_ADD_REMOVE_DISPLAY:
87 case DEV_TOGGLE_UNIFIED_DESKTOP: 95 case DEV_TOGGLE_UNIFIED_DESKTOP:
96 return true;
88 case SWAP_PRIMARY_DISPLAY: 97 case SWAP_PRIMARY_DISPLAY:
98 return display::Screen::GetScreen()->GetNumDisplays() > 1;
99 case TOGGLE_MIRROR_MODE:
89 case TOUCH_HUD_PROJECTION_TOGGLE: 100 case TOUCH_HUD_PROJECTION_TOGGLE:
90 return true; 101 return true;
102 #endif
91 default: 103 default:
92 break; 104 break;
93 } 105 }
94 #endif
95 return false; 106 return false;
96 } 107 }
97 108
98 void AcceleratorControllerDelegateMus::PerformAction( 109 void AcceleratorControllerDelegateMus::PerformAction(
99 AcceleratorAction action, 110 AcceleratorAction action,
100 const ui::Accelerator& accelerator) { 111 const ui::Accelerator& accelerator) {
112 switch (action) {
113 case ROTATE_SCREEN: {
114 window_manager_->GetDisplayController()->RotateCurrentDisplayCW();
115 break;
116 }
117 case SCALE_UI_DOWN: {
118 window_manager_->GetDisplayController()->DecreaseInternalDisplayZoom();
119 break;
120 }
121 case SCALE_UI_RESET: {
122 window_manager_->GetDisplayController()->ResetInternalDisplayZoom();
123 break;
124 }
125 case SCALE_UI_UP: {
126 window_manager_->GetDisplayController()->IncreaseInternalDisplayZoom();
127 break;
128 }
101 #if defined(OS_CHROMEOS) 129 #if defined(OS_CHROMEOS)
102 switch (action) {
103 case DEV_ADD_REMOVE_DISPLAY: { 130 case DEV_ADD_REMOVE_DISPLAY: {
104 display::mojom::TestDisplayControllerPtr test_display_controller; 131 display::mojom::TestDisplayControllerPtr test_display_controller;
105 window_manager_->connector()->ConnectToInterface( 132 window_manager_->connector()->ConnectToInterface(
106 ui::mojom::kServiceName, &test_display_controller); 133 ui::mojom::kServiceName, &test_display_controller);
107 test_display_controller->ToggleAddRemoveDisplay(); 134 test_display_controller->ToggleAddRemoveDisplay();
108 break; 135 break;
109 } 136 }
110 case DEV_TOGGLE_UNIFIED_DESKTOP: { 137 case DEV_TOGGLE_UNIFIED_DESKTOP: {
111 // TODO(crbug.com/657816): This is hack. I'm just stealing the shortcut 138 // TODO(crbug.com/657816): This is hack. I'm just stealing the shortcut
112 // key to toggle display size in mus. This should be removed by launch. 139 // key to toggle display size in mus. This should be removed by launch.
113 display::mojom::TestDisplayControllerPtr test_display_controller; 140 display::mojom::TestDisplayControllerPtr test_display_controller;
114 window_manager_->connector()->ConnectToInterface( 141 window_manager_->connector()->ConnectToInterface(
115 ui::mojom::kServiceName, &test_display_controller); 142 ui::mojom::kServiceName, &test_display_controller);
116 test_display_controller->ToggleDisplayResolution(); 143 test_display_controller->ToggleDisplayResolution();
117 break; 144 break;
118 } 145 }
119 case SWAP_PRIMARY_DISPLAY: { 146 case SWAP_PRIMARY_DISPLAY: {
120 window_manager_->GetDisplayController()->SwapPrimaryDisplay(); 147 window_manager_->GetDisplayController()->SwapPrimaryDisplay();
121 break; 148 break;
122 } 149 }
150 case TOGGLE_MIRROR_MODE: {
151 window_manager_->GetDisplayController()->ToggleMirrorMode();
152 break;
153 }
123 case TOUCH_HUD_PROJECTION_TOGGLE: { 154 case TOUCH_HUD_PROJECTION_TOGGLE: {
124 mash::mojom::LaunchablePtr launchable; 155 mash::mojom::LaunchablePtr launchable;
125 window_manager_->connector()->ConnectToInterface("touch_hud", 156 window_manager_->connector()->ConnectToInterface("touch_hud",
126 &launchable); 157 &launchable);
127 launchable->Launch(mash::mojom::kWindow, 158 launchable->Launch(mash::mojom::kWindow,
128 mash::mojom::LaunchMode::DEFAULT); 159 mash::mojom::LaunchMode::DEFAULT);
129 break; 160 break;
130 } 161 }
162 #endif
131 default: 163 default:
132 NOTREACHED(); 164 NOTREACHED();
133 } 165 }
134 #else
135 NOTREACHED();
136 #endif
137 } 166 }
138 167
139 void AcceleratorControllerDelegateMus::ShowDeprecatedAcceleratorNotification( 168 void AcceleratorControllerDelegateMus::ShowDeprecatedAcceleratorNotification(
140 const char* const notification_id, 169 const char* const notification_id,
141 int message_id, 170 int message_id,
142 int old_shortcut_id, 171 int old_shortcut_id,
143 int new_shortcut_id) { 172 int new_shortcut_id) {
144 // TODO: http://crbug.com/630316. 173 // TODO: http://crbug.com/630316.
145 NOTIMPLEMENTED(); 174 NOTIMPLEMENTED();
146 } 175 }
147 176
148 } // namespace mus 177 } // namespace mus
149 } // namespace ash 178 } // namespace ash
OLDNEW
« no previous file with comments | « ash/mus/accelerators/accelerator_controller_delegate_mus.h ('k') | services/ui/display/screen_manager_ozone.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698