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

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

Issue 2537643008: Add IPCs for ash display shortcuts. (Closed)
Patch Set: 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 // This is the list of actions that are not ported from aura. The actions are
32 // replicated here to make sure we don't forget any. This list should 33 // replicated here to make sure we don't forget any. This list should
33 // eventually be empty. If there are any actions that don't make sense for 34 // eventually be empty. If there are any actions that don't make sense for
James Cook 2016/12/01 16:38:50 The documentation for this function needs to be re
kylechar 2016/12/01 18:43:31 Done.
34 // mus, then they should be removed from AcceleratorAction. 35 // mus, then they should be removed from AcceleratorAction.
35 // http://crbug.com/612331. 36 // http://crbug.com/612331.
36 switch (action) { 37 switch (action) {
38 case SCALE_UI_DOWN:
39 case SCALE_UI_RESET:
40 case SCALE_UI_UP:
41 case ROTATE_SCREEN:
42 return true;
37 case DEBUG_TOGGLE_DEVICE_SCALE_FACTOR: 43 case DEBUG_TOGGLE_DEVICE_SCALE_FACTOR:
38 case DEV_TOGGLE_ROOT_WINDOW_FULL_SCREEN: 44 case DEV_TOGGLE_ROOT_WINDOW_FULL_SCREEN:
39 case DEBUG_TOGGLE_SHOW_DEBUG_BORDERS: 45 case DEBUG_TOGGLE_SHOW_DEBUG_BORDERS:
40 case DEBUG_TOGGLE_SHOW_FPS_COUNTER: 46 case DEBUG_TOGGLE_SHOW_FPS_COUNTER:
41 case DEBUG_TOGGLE_SHOW_PAINT_RECTS: 47 case DEBUG_TOGGLE_SHOW_PAINT_RECTS:
42 case MAGNIFY_SCREEN_ZOOM_IN: 48 case MAGNIFY_SCREEN_ZOOM_IN:
43 case MAGNIFY_SCREEN_ZOOM_OUT: 49 case MAGNIFY_SCREEN_ZOOM_OUT:
44 case ROTATE_SCREEN:
45 case ROTATE_WINDOW: 50 case ROTATE_WINDOW:
46 case SCALE_UI_DOWN:
47 case SCALE_UI_RESET:
48 case SCALE_UI_UP:
49 case SHOW_SYSTEM_TRAY_BUBBLE: 51 case SHOW_SYSTEM_TRAY_BUBBLE:
50 case TAKE_PARTIAL_SCREENSHOT: 52 case TAKE_PARTIAL_SCREENSHOT:
51 case TAKE_SCREENSHOT: 53 case TAKE_SCREENSHOT:
52 case TAKE_WINDOW_SCREENSHOT: 54 case TAKE_WINDOW_SCREENSHOT:
53 case UNPIN: 55 case UNPIN:
54 NOTIMPLEMENTED(); 56 NOTIMPLEMENTED();
55 return false; 57 return false;
56 58
57 #if defined(OS_CHROMEOS) 59 #if defined(OS_CHROMEOS)
58 case DEV_ADD_REMOVE_DISPLAY: 60 case DEV_ADD_REMOVE_DISPLAY:
59 case DEV_TOGGLE_UNIFIED_DESKTOP: 61 case DEV_TOGGLE_UNIFIED_DESKTOP:
60 case SWAP_PRIMARY_DISPLAY: 62 case SWAP_PRIMARY_DISPLAY:
63 case TOGGLE_MIRROR_MODE:
61 case TOUCH_HUD_PROJECTION_TOGGLE: 64 case TOUCH_HUD_PROJECTION_TOGGLE:
62 return true; 65 return true;
63 case LOCK_PRESSED: 66 case LOCK_PRESSED:
64 case LOCK_RELEASED: 67 case LOCK_RELEASED:
65 case POWER_PRESSED: 68 case POWER_PRESSED:
66 case POWER_RELEASED: 69 case POWER_RELEASED:
67 case TOGGLE_MIRROR_MODE:
68 case TOUCH_HUD_CLEAR: 70 case TOUCH_HUD_CLEAR:
69 case TOUCH_HUD_MODE_CHANGE: 71 case TOUCH_HUD_MODE_CHANGE:
70 NOTIMPLEMENTED(); 72 NOTIMPLEMENTED();
71 return false; 73 return false;
72 #endif 74 #endif
73 75
74 default: 76 default:
75 break; 77 break;
76 } 78 }
77 return false; 79 return false;
78 } 80 }
79 81
80 bool AcceleratorControllerDelegateMus::CanPerformAction( 82 bool AcceleratorControllerDelegateMus::CanPerformAction(
81 AcceleratorAction action, 83 AcceleratorAction action,
82 const ui::Accelerator& accelerator, 84 const ui::Accelerator& accelerator,
83 const ui::Accelerator& previous_accelerator) { 85 const ui::Accelerator& previous_accelerator) {
86 switch (action) {
87 case ROTATE_SCREEN:
88 case SCALE_UI_DOWN:
89 case SCALE_UI_RESET:
90 case SCALE_UI_UP:
91 return true;
84 #if defined(OS_CHROMEOS) 92 #if defined(OS_CHROMEOS)
85 switch (action) {
86 case DEV_ADD_REMOVE_DISPLAY: 93 case DEV_ADD_REMOVE_DISPLAY:
87 case DEV_TOGGLE_UNIFIED_DESKTOP: 94 case DEV_TOGGLE_UNIFIED_DESKTOP:
95 return true;
88 case SWAP_PRIMARY_DISPLAY: 96 case SWAP_PRIMARY_DISPLAY:
97 return display::Screen::GetScreen()->GetNumDisplays() > 1;
98 case TOGGLE_MIRROR_MODE:
89 case TOUCH_HUD_PROJECTION_TOGGLE: 99 case TOUCH_HUD_PROJECTION_TOGGLE:
90 return true; 100 return true;
101 #endif
91 default: 102 default:
92 break; 103 break;
93 } 104 }
94 #endif
95 return false; 105 return false;
96 } 106 }
97 107
98 void AcceleratorControllerDelegateMus::PerformAction( 108 void AcceleratorControllerDelegateMus::PerformAction(
99 AcceleratorAction action, 109 AcceleratorAction action,
100 const ui::Accelerator& accelerator) { 110 const ui::Accelerator& accelerator) {
111 switch (action) {
112 case ROTATE_SCREEN: {
113 window_manager_->GetDisplayController()->RotateCurrentDisplay();
114 break;
115 }
116 case SCALE_UI_DOWN: {
James Cook 2016/12/01 16:38:50 optional: These constants could be renamed for con
117 window_manager_->GetDisplayController()->ZoomInternalDisplayDown();
118 break;
119 }
120 case SCALE_UI_RESET: {
121 window_manager_->GetDisplayController()->ResetInternalDisplayZoom();
122 break;
123 }
124 case SCALE_UI_UP: {
125 window_manager_->GetDisplayController()->ZoomInternalDisplayUp();
126 break;
127 }
101 #if defined(OS_CHROMEOS) 128 #if defined(OS_CHROMEOS)
102 switch (action) {
103 case DEV_ADD_REMOVE_DISPLAY: { 129 case DEV_ADD_REMOVE_DISPLAY: {
104 display::mojom::TestDisplayControllerPtr test_display_controller; 130 display::mojom::TestDisplayControllerPtr test_display_controller;
105 window_manager_->connector()->ConnectToInterface( 131 window_manager_->connector()->ConnectToInterface(
106 ui::mojom::kServiceName, &test_display_controller); 132 ui::mojom::kServiceName, &test_display_controller);
107 test_display_controller->ToggleAddRemoveDisplay(); 133 test_display_controller->ToggleAddRemoveDisplay();
108 break; 134 break;
109 } 135 }
110 case DEV_TOGGLE_UNIFIED_DESKTOP: { 136 case DEV_TOGGLE_UNIFIED_DESKTOP: {
111 // TODO(crbug.com/657816): This is hack. I'm just stealing the shortcut 137 // 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. 138 // key to toggle display size in mus. This should be removed by launch.
113 display::mojom::TestDisplayControllerPtr test_display_controller; 139 display::mojom::TestDisplayControllerPtr test_display_controller;
114 window_manager_->connector()->ConnectToInterface( 140 window_manager_->connector()->ConnectToInterface(
115 ui::mojom::kServiceName, &test_display_controller); 141 ui::mojom::kServiceName, &test_display_controller);
116 test_display_controller->ToggleDisplayResolution(); 142 test_display_controller->ToggleDisplayResolution();
117 break; 143 break;
118 } 144 }
119 case SWAP_PRIMARY_DISPLAY: { 145 case SWAP_PRIMARY_DISPLAY: {
120 window_manager_->GetDisplayController()->SwapPrimaryDisplay(); 146 window_manager_->GetDisplayController()->SwapPrimaryDisplay();
121 break; 147 break;
122 } 148 }
149 case TOGGLE_MIRROR_MODE: {
150 window_manager_->GetDisplayController()->ToggleMirrorMode();
151 break;
152 }
123 case TOUCH_HUD_PROJECTION_TOGGLE: { 153 case TOUCH_HUD_PROJECTION_TOGGLE: {
124 mash::mojom::LaunchablePtr launchable; 154 mash::mojom::LaunchablePtr launchable;
125 window_manager_->connector()->ConnectToInterface("touch_hud", 155 window_manager_->connector()->ConnectToInterface("touch_hud",
126 &launchable); 156 &launchable);
127 launchable->Launch(mash::mojom::kWindow, 157 launchable->Launch(mash::mojom::kWindow,
128 mash::mojom::LaunchMode::DEFAULT); 158 mash::mojom::LaunchMode::DEFAULT);
129 break; 159 break;
130 } 160 }
161 #endif
131 default: 162 default:
132 NOTREACHED(); 163 NOTREACHED();
133 } 164 }
134 #else
135 NOTREACHED();
136 #endif
137 } 165 }
138 166
139 void AcceleratorControllerDelegateMus::ShowDeprecatedAcceleratorNotification( 167 void AcceleratorControllerDelegateMus::ShowDeprecatedAcceleratorNotification(
140 const char* const notification_id, 168 const char* const notification_id,
141 int message_id, 169 int message_id,
142 int old_shortcut_id, 170 int old_shortcut_id,
143 int new_shortcut_id) { 171 int new_shortcut_id) {
144 // TODO: http://crbug.com/630316. 172 // TODO: http://crbug.com/630316.
145 NOTIMPLEMENTED(); 173 NOTIMPLEMENTED();
146 } 174 }
147 175
148 } // namespace mus 176 } // namespace mus
149 } // namespace ash 177 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698