OLD | NEW |
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 "base/logging.h" | 8 #include "base/logging.h" |
8 #include "mash/public/interfaces/launchable.mojom.h" | 9 #include "mash/public/interfaces/launchable.mojom.h" |
| 10 #include "services/service_manager/public/cpp/connector.h" |
9 #include "services/ui/public/interfaces/display/display_controller.mojom.h" | 11 #include "services/ui/public/interfaces/display/display_controller.mojom.h" |
10 #include "services/ui/public/interfaces/display/test_display_controller.mojom.h" | 12 #include "services/ui/public/interfaces/display/test_display_controller.mojom.h" |
11 | 13 |
12 namespace ash { | 14 namespace ash { |
13 namespace mus { | 15 namespace mus { |
14 | 16 |
15 AcceleratorControllerDelegateMus::AcceleratorControllerDelegateMus( | 17 AcceleratorControllerDelegateMus::AcceleratorControllerDelegateMus( |
16 service_manager::Connector* connector) | 18 WindowManager* window_manager) |
17 : connector_(connector) { | 19 : window_manager_(window_manager) { |
18 #if !defined(OS_CHROMEOS) | 20 #if !defined(OS_CHROMEOS) |
19 // To avoid trybot complaining that |connector_| is not being | 21 // To avoid trybot complaining that |window_manager_| is not being used in |
20 // used in non-ChromeOS. | 22 // non-ChromeOS. |
21 connector_ = nullptr; | 23 window_manager_ = nullptr; |
22 #endif | 24 #endif |
23 } | 25 } |
24 | 26 |
25 AcceleratorControllerDelegateMus::~AcceleratorControllerDelegateMus() {} | 27 AcceleratorControllerDelegateMus::~AcceleratorControllerDelegateMus() {} |
26 | 28 |
27 bool AcceleratorControllerDelegateMus::HandlesAction(AcceleratorAction action) { | 29 bool AcceleratorControllerDelegateMus::HandlesAction(AcceleratorAction action) { |
28 // This is the list of actions that are not ported from aura. The actions are | 30 // This is the list of actions that are not ported from aura. The actions are |
29 // replicated here to make sure we don't forget any. This list should | 31 // replicated here to make sure we don't forget any. This list should |
30 // eventually be empty. If there are any actions that don't make sense for | 32 // eventually be empty. If there are any actions that don't make sense for |
31 // mus, then they should be removed from AcceleratorAction. | 33 // mus, then they should be removed from AcceleratorAction. |
(...skipping 14 matching lines...) Expand all Loading... |
46 case SHOW_SYSTEM_TRAY_BUBBLE: | 48 case SHOW_SYSTEM_TRAY_BUBBLE: |
47 case TAKE_PARTIAL_SCREENSHOT: | 49 case TAKE_PARTIAL_SCREENSHOT: |
48 case TAKE_SCREENSHOT: | 50 case TAKE_SCREENSHOT: |
49 case TAKE_WINDOW_SCREENSHOT: | 51 case TAKE_WINDOW_SCREENSHOT: |
50 case UNPIN: | 52 case UNPIN: |
51 NOTIMPLEMENTED(); | 53 NOTIMPLEMENTED(); |
52 return false; | 54 return false; |
53 | 55 |
54 #if defined(OS_CHROMEOS) | 56 #if defined(OS_CHROMEOS) |
55 case DEV_ADD_REMOVE_DISPLAY: | 57 case DEV_ADD_REMOVE_DISPLAY: |
| 58 case DEV_TOGGLE_UNIFIED_DESKTOP: |
56 case SWAP_PRIMARY_DISPLAY: | 59 case SWAP_PRIMARY_DISPLAY: |
57 case TOUCH_HUD_PROJECTION_TOGGLE: | 60 case TOUCH_HUD_PROJECTION_TOGGLE: |
58 return true; | 61 return true; |
59 case DEV_TOGGLE_UNIFIED_DESKTOP: | |
60 case LOCK_PRESSED: | 62 case LOCK_PRESSED: |
61 case LOCK_RELEASED: | 63 case LOCK_RELEASED: |
62 case POWER_PRESSED: | 64 case POWER_PRESSED: |
63 case POWER_RELEASED: | 65 case POWER_RELEASED: |
64 case TOGGLE_MIRROR_MODE: | 66 case TOGGLE_MIRROR_MODE: |
65 case TOUCH_HUD_CLEAR: | 67 case TOUCH_HUD_CLEAR: |
66 case TOUCH_HUD_MODE_CHANGE: | 68 case TOUCH_HUD_MODE_CHANGE: |
67 NOTIMPLEMENTED(); | 69 NOTIMPLEMENTED(); |
68 return false; | 70 return false; |
69 #endif | 71 #endif |
70 | 72 |
71 default: | 73 default: |
72 break; | 74 break; |
73 } | 75 } |
74 return false; | 76 return false; |
75 } | 77 } |
76 | 78 |
77 bool AcceleratorControllerDelegateMus::CanPerformAction( | 79 bool AcceleratorControllerDelegateMus::CanPerformAction( |
78 AcceleratorAction action, | 80 AcceleratorAction action, |
79 const ui::Accelerator& accelerator, | 81 const ui::Accelerator& accelerator, |
80 const ui::Accelerator& previous_accelerator) { | 82 const ui::Accelerator& previous_accelerator) { |
81 #if defined(OS_CHROMEOS) | 83 #if defined(OS_CHROMEOS) |
82 switch (action) { | 84 switch (action) { |
83 case DEV_ADD_REMOVE_DISPLAY: | 85 case DEV_ADD_REMOVE_DISPLAY: |
| 86 case DEV_TOGGLE_UNIFIED_DESKTOP: |
84 case SWAP_PRIMARY_DISPLAY: | 87 case SWAP_PRIMARY_DISPLAY: |
85 case TOUCH_HUD_PROJECTION_TOGGLE: | 88 case TOUCH_HUD_PROJECTION_TOGGLE: |
86 return true; | 89 return true; |
87 default: | 90 default: |
88 break; | 91 break; |
89 } | 92 } |
90 #endif | 93 #endif |
91 return false; | 94 return false; |
92 } | 95 } |
93 | 96 |
94 void AcceleratorControllerDelegateMus::PerformAction( | 97 void AcceleratorControllerDelegateMus::PerformAction( |
95 AcceleratorAction action, | 98 AcceleratorAction action, |
96 const ui::Accelerator& accelerator) { | 99 const ui::Accelerator& accelerator) { |
97 #if defined(OS_CHROMEOS) | 100 #if defined(OS_CHROMEOS) |
98 switch (action) { | 101 switch (action) { |
99 case DEV_ADD_REMOVE_DISPLAY: { | 102 case DEV_ADD_REMOVE_DISPLAY: { |
100 display::mojom::TestDisplayControllerPtr test_display_controller; | 103 display::mojom::TestDisplayControllerPtr test_display_controller; |
101 connector_->ConnectToInterface("service:ui", &test_display_controller); | 104 window_manager_->connector()->ConnectToInterface( |
| 105 "service:ui", &test_display_controller); |
102 test_display_controller->ToggleAddRemoveDisplay(); | 106 test_display_controller->ToggleAddRemoveDisplay(); |
103 break; | 107 break; |
104 } | 108 } |
| 109 case DEV_TOGGLE_UNIFIED_DESKTOP: { |
| 110 // TODO(crbug.com/657816): This is hack. I'm just stealing the shortcut |
| 111 // key to toggle display size in mus. This should be removed by launch. |
| 112 display::mojom::TestDisplayControllerPtr test_display_controller; |
| 113 window_manager_->connector()->ConnectToInterface( |
| 114 "service:ui", &test_display_controller); |
| 115 test_display_controller->ToggleDisplayResolution(); |
| 116 break; |
| 117 } |
105 case SWAP_PRIMARY_DISPLAY: { | 118 case SWAP_PRIMARY_DISPLAY: { |
106 display::mojom::DisplayControllerPtr display_controller; | 119 window_manager_->GetDisplayController()->SwapPrimaryDisplay(); |
107 connector_->ConnectToInterface("service:ui", &display_controller); | |
108 display_controller->SwapPrimaryDisplay(); | |
109 break; | 120 break; |
110 } | 121 } |
111 case TOUCH_HUD_PROJECTION_TOGGLE: { | 122 case TOUCH_HUD_PROJECTION_TOGGLE: { |
112 mash::mojom::LaunchablePtr launchable; | 123 mash::mojom::LaunchablePtr launchable; |
113 connector_->ConnectToInterface("service:touch_hud", &launchable); | 124 window_manager_->connector()->ConnectToInterface("service:touch_hud", |
| 125 &launchable); |
114 launchable->Launch(mash::mojom::kWindow, | 126 launchable->Launch(mash::mojom::kWindow, |
115 mash::mojom::LaunchMode::DEFAULT); | 127 mash::mojom::LaunchMode::DEFAULT); |
116 break; | 128 break; |
117 } | 129 } |
118 default: | 130 default: |
119 NOTREACHED(); | 131 NOTREACHED(); |
120 } | 132 } |
121 #else | 133 #else |
122 NOTREACHED(); | 134 NOTREACHED(); |
123 #endif | 135 #endif |
124 } | 136 } |
125 | 137 |
126 void AcceleratorControllerDelegateMus::ShowDeprecatedAcceleratorNotification( | 138 void AcceleratorControllerDelegateMus::ShowDeprecatedAcceleratorNotification( |
127 const char* const notification_id, | 139 const char* const notification_id, |
128 int message_id, | 140 int message_id, |
129 int old_shortcut_id, | 141 int old_shortcut_id, |
130 int new_shortcut_id) { | 142 int new_shortcut_id) { |
131 // TODO: http://crbug.com/630316. | 143 // TODO: http://crbug.com/630316. |
132 NOTIMPLEMENTED(); | 144 NOTIMPLEMENTED(); |
133 } | 145 } |
134 | 146 |
135 } // namespace mus | 147 } // namespace mus |
136 } // namespace ash | 148 } // namespace ash |
OLD | NEW |