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

Side by Side Diff: ash/mus/bridge/wm_shell_mus.cc

Issue 2187703003: Wires up registering accelerators from mash with the wm (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 4 years, 4 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 | « ash/mus/bridge/wm_shell_mus.h ('k') | ash/mus/window_manager.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 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/bridge/wm_shell_mus.h" 5 #include "ash/mus/bridge/wm_shell_mus.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "ash/common/accelerators/accelerator_controller.h" 9 #include "ash/common/accelerators/accelerator_controller.h"
10 #include "ash/common/display/display_info.h" 10 #include "ash/common/display/display_info.h"
11 #include "ash/common/keyboard/keyboard_ui.h" 11 #include "ash/common/keyboard/keyboard_ui.h"
12 #include "ash/common/session/session_state_delegate.h" 12 #include "ash/common/session/session_state_delegate.h"
13 #include "ash/common/shell_delegate.h" 13 #include "ash/common/shell_delegate.h"
14 #include "ash/common/shell_observer.h" 14 #include "ash/common/shell_observer.h"
15 #include "ash/common/shell_window_ids.h" 15 #include "ash/common/shell_window_ids.h"
16 #include "ash/common/system/tray/default_system_tray_delegate.h" 16 #include "ash/common/system/tray/default_system_tray_delegate.h"
17 #include "ash/common/wm/maximize_mode/maximize_mode_event_handler.h" 17 #include "ash/common/wm/maximize_mode/maximize_mode_event_handler.h"
18 #include "ash/common/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard .h" 18 #include "ash/common/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard .h"
19 #include "ash/common/wm/mru_window_tracker.h" 19 #include "ash/common/wm/mru_window_tracker.h"
20 #include "ash/common/wm/window_cycle_event_filter.h" 20 #include "ash/common/wm/window_cycle_event_filter.h"
21 #include "ash/common/wm/window_resizer.h" 21 #include "ash/common/wm/window_resizer.h"
22 #include "ash/common/wm_activation_observer.h" 22 #include "ash/common/wm_activation_observer.h"
23 #include "ash/mus/accelerators/accelerator_controller_delegate_mus.h" 23 #include "ash/mus/accelerators/accelerator_controller_delegate_mus.h"
24 #include "ash/mus/accelerators/accelerator_controller_registrar.h"
24 #include "ash/mus/bridge/wm_root_window_controller_mus.h" 25 #include "ash/mus/bridge/wm_root_window_controller_mus.h"
25 #include "ash/mus/bridge/wm_window_mus.h" 26 #include "ash/mus/bridge/wm_window_mus.h"
26 #include "ash/mus/container_ids.h" 27 #include "ash/mus/container_ids.h"
27 #include "ash/mus/drag_window_resizer.h" 28 #include "ash/mus/drag_window_resizer.h"
28 #include "ash/mus/root_window_controller.h" 29 #include "ash/mus/root_window_controller.h"
30 #include "ash/mus/window_manager.h"
29 #include "base/memory/ptr_util.h" 31 #include "base/memory/ptr_util.h"
30 #include "components/user_manager/user_info_impl.h" 32 #include "components/user_manager/user_info_impl.h"
31 #include "services/ui/common/util.h" 33 #include "services/ui/common/util.h"
32 #include "services/ui/public/cpp/window.h" 34 #include "services/ui/public/cpp/window.h"
33 #include "services/ui/public/cpp/window_tree_client.h" 35 #include "services/ui/public/cpp/window_tree_client.h"
34 36
35 namespace ash { 37 namespace ash {
36 namespace mus { 38 namespace mus {
37 39
38 namespace { 40 namespace {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 94
93 // A pseudo user info. 95 // A pseudo user info.
94 std::unique_ptr<user_manager::UserInfo> user_info_; 96 std::unique_ptr<user_manager::UserInfo> user_info_;
95 97
96 DISALLOW_COPY_AND_ASSIGN(SessionStateDelegateStub); 98 DISALLOW_COPY_AND_ASSIGN(SessionStateDelegateStub);
97 }; 99 };
98 100
99 } // namespace 101 } // namespace
100 102
101 WmShellMus::WmShellMus(std::unique_ptr<ShellDelegate> shell_delegate, 103 WmShellMus::WmShellMus(std::unique_ptr<ShellDelegate> shell_delegate,
102 ::ui::WindowTreeClient* client) 104 WindowManager* window_manager)
103 : WmShell(std::move(shell_delegate)), 105 : WmShell(std::move(shell_delegate)),
104 client_(client), 106 window_manager_(window_manager),
105 session_state_delegate_(new SessionStateDelegateStub) { 107 session_state_delegate_(new SessionStateDelegateStub) {
106 client_->AddObserver(this); 108 window_tree_client()->AddObserver(this);
107 WmShell::Set(this); 109 WmShell::Set(this);
108 110
111 uint16_t accelerator_namespace_id = 0u;
112 const bool add_result =
113 window_manager->GetNextAcceleratorNamespaceId(&accelerator_namespace_id);
114 // WmShellMus is created early on, so that this should always succeed.
115 DCHECK(add_result);
109 accelerator_controller_delegate_.reset(new AcceleratorControllerDelegateMus); 116 accelerator_controller_delegate_.reset(new AcceleratorControllerDelegateMus);
117 accelerator_controller_registrar_.reset(new AcceleratorControllerRegistrar(
118 window_manager_, accelerator_namespace_id));
110 SetAcceleratorController(base::MakeUnique<AcceleratorController>( 119 SetAcceleratorController(base::MakeUnique<AcceleratorController>(
111 accelerator_controller_delegate_.get())); 120 accelerator_controller_delegate_.get(),
121 accelerator_controller_registrar_.get()));
112 122
113 CreateMaximizeModeController(); 123 CreateMaximizeModeController();
114 124
115 CreateMruWindowTracker(); 125 CreateMruWindowTracker();
116 126
117 SetSystemTrayDelegate(base::WrapUnique(new DefaultSystemTrayDelegate)); 127 SetSystemTrayDelegate(base::WrapUnique(new DefaultSystemTrayDelegate));
118 128
119 // TODO(jamescook): Port ash::sysui::KeyboardUIMus and use it here. 129 // TODO(jamescook): Port ash::sysui::KeyboardUIMus and use it here.
120 SetKeyboardUI(KeyboardUI::Create()); 130 SetKeyboardUI(KeyboardUI::Create());
121 } 131 }
122 132
123 WmShellMus::~WmShellMus() { 133 WmShellMus::~WmShellMus() {
124 // This order mirrors that of Shell. 134 // This order mirrors that of Shell.
125 135
126 // Destroy maximize mode controller early on since it has some observers which 136 // Destroy maximize mode controller early on since it has some observers which
127 // need to be removed. 137 // need to be removed.
128 DeleteMaximizeModeController(); 138 DeleteMaximizeModeController();
129 DeleteToastManager(); 139 DeleteToastManager();
130 DeleteSystemTrayDelegate(); 140 DeleteSystemTrayDelegate();
131 // Has to happen before ~MruWindowTracker. 141 // Has to happen before ~MruWindowTracker.
132 DeleteWindowCycleController(); 142 DeleteWindowCycleController();
133 DeleteWindowSelectorController(); 143 DeleteWindowSelectorController();
134 DeleteMruWindowTracker(); 144 DeleteMruWindowTracker();
135 RemoveClientObserver(); 145 if (window_tree_client())
146 window_tree_client()->RemoveObserver(this);
136 WmShell::Set(nullptr); 147 WmShell::Set(nullptr);
137 } 148 }
138 149
139 // static 150 // static
140 WmShellMus* WmShellMus::Get() { 151 WmShellMus* WmShellMus::Get() {
141 return static_cast<WmShellMus*>(WmShell::Get()); 152 return static_cast<WmShellMus*>(WmShell::Get());
142 } 153 }
143 154
144 void WmShellMus::AddRootWindowController( 155 void WmShellMus::AddRootWindowController(
145 WmRootWindowControllerMus* controller) { 156 WmRootWindowControllerMus* controller) {
(...skipping 23 matching lines...) Expand all
169 for (WmRootWindowControllerMus* root_window_controller : 180 for (WmRootWindowControllerMus* root_window_controller :
170 root_window_controllers_) { 181 root_window_controllers_) {
171 if (root_window_controller->GetDisplay().id() == id) 182 if (root_window_controller->GetDisplay().id() == id)
172 return root_window_controller; 183 return root_window_controller;
173 } 184 }
174 NOTREACHED(); 185 NOTREACHED();
175 return nullptr; 186 return nullptr;
176 } 187 }
177 188
178 WmWindow* WmShellMus::NewContainerWindow() { 189 WmWindow* WmShellMus::NewContainerWindow() {
179 return WmWindowMus::Get(client_->NewWindow()); 190 return WmWindowMus::Get(window_tree_client()->NewWindow());
180 } 191 }
181 192
182 WmWindow* WmShellMus::GetFocusedWindow() { 193 WmWindow* WmShellMus::GetFocusedWindow() {
183 return WmWindowMus::Get(client_->GetFocusedWindow()); 194 return WmWindowMus::Get(window_tree_client()->GetFocusedWindow());
184 } 195 }
185 196
186 WmWindow* WmShellMus::GetActiveWindow() { 197 WmWindow* WmShellMus::GetActiveWindow() {
187 return GetToplevelAncestor(client_->GetFocusedWindow()); 198 return GetToplevelAncestor(window_tree_client()->GetFocusedWindow());
188 } 199 }
189 200
190 WmWindow* WmShellMus::GetPrimaryRootWindow() { 201 WmWindow* WmShellMus::GetPrimaryRootWindow() {
191 return root_window_controllers_[0]->GetWindow(); 202 return root_window_controllers_[0]->GetWindow();
192 } 203 }
193 204
194 WmWindow* WmShellMus::GetRootWindowForDisplayId(int64_t display_id) { 205 WmWindow* WmShellMus::GetRootWindowForDisplayId(int64_t display_id) {
195 return GetRootWindowControllerWithDisplayId(display_id)->GetWindow(); 206 return GetRootWindowControllerWithDisplayId(display_id)->GetWindow();
196 } 207 }
197 208
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 void WmShellMus::RemovePointerWatcher(views::PointerWatcher* watcher) { 332 void WmShellMus::RemovePointerWatcher(views::PointerWatcher* watcher) {
322 NOTIMPLEMENTED(); 333 NOTIMPLEMENTED();
323 } 334 }
324 335
325 #if defined(OS_CHROMEOS) 336 #if defined(OS_CHROMEOS)
326 void WmShellMus::ToggleIgnoreExternalKeyboard() { 337 void WmShellMus::ToggleIgnoreExternalKeyboard() {
327 NOTIMPLEMENTED(); 338 NOTIMPLEMENTED();
328 } 339 }
329 #endif // defined(OS_CHROMEOS) 340 #endif // defined(OS_CHROMEOS)
330 341
342 ::ui::WindowTreeClient* WmShellMus::window_tree_client() {
343 return window_manager_->window_tree_client();
344 }
345
331 // static 346 // static
332 bool WmShellMus::IsActivationParent(::ui::Window* window) { 347 bool WmShellMus::IsActivationParent(::ui::Window* window) {
333 return window && IsActivatableShellWindowId( 348 return window && IsActivatableShellWindowId(
334 WmWindowMus::Get(window)->GetShellWindowId()); 349 WmWindowMus::Get(window)->GetShellWindowId());
335 } 350 }
336 351
337 void WmShellMus::RemoveClientObserver() {
338 if (!client_)
339 return;
340
341 client_->RemoveObserver(this);
342 client_ = nullptr;
343 }
344
345 // TODO: support OnAttemptToReactivateWindow, http://crbug.com/615114. 352 // TODO: support OnAttemptToReactivateWindow, http://crbug.com/615114.
346 void WmShellMus::OnWindowTreeFocusChanged(::ui::Window* gained_focus, 353 void WmShellMus::OnWindowTreeFocusChanged(::ui::Window* gained_focus,
347 ::ui::Window* lost_focus) { 354 ::ui::Window* lost_focus) {
348 WmWindowMus* gained_active = GetToplevelAncestor(gained_focus); 355 WmWindowMus* gained_active = GetToplevelAncestor(gained_focus);
349 WmWindowMus* lost_active = GetToplevelAncestor(gained_focus); 356 WmWindowMus* lost_active = GetToplevelAncestor(gained_focus);
350 if (gained_active == lost_active) 357 if (gained_active == lost_active)
351 return; 358 return;
352 359
353 FOR_EACH_OBSERVER(WmActivationObserver, activation_observers_, 360 FOR_EACH_OBSERVER(WmActivationObserver, activation_observers_,
354 OnWindowActivated(gained_active, lost_active)); 361 OnWindowActivated(gained_active, lost_active));
355 } 362 }
356 363
357 void WmShellMus::OnDidDestroyClient(::ui::WindowTreeClient* client) { 364 void WmShellMus::OnDidDestroyClient(::ui::WindowTreeClient* client) {
358 DCHECK_EQ(client, client_); 365 DCHECK_EQ(window_tree_client(), client);
359 RemoveClientObserver(); 366 client->RemoveObserver(this);
360 } 367 }
361 368
362 } // namespace mus 369 } // namespace mus
363 } // namespace ash 370 } // namespace ash
OLDNEW
« no previous file with comments | « ash/mus/bridge/wm_shell_mus.h ('k') | ash/mus/window_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698