Chromium Code Reviews| 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/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" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 148 } | 148 } |
| 149 | 149 |
| 150 // static | 150 // static |
| 151 WmShellMus* WmShellMus::Get() { | 151 WmShellMus* WmShellMus::Get() { |
| 152 return static_cast<WmShellMus*>(WmShell::Get()); | 152 return static_cast<WmShellMus*>(WmShell::Get()); |
| 153 } | 153 } |
| 154 | 154 |
| 155 void WmShellMus::AddRootWindowController( | 155 void WmShellMus::AddRootWindowController( |
| 156 WmRootWindowControllerMus* controller) { | 156 WmRootWindowControllerMus* controller) { |
| 157 root_window_controllers_.push_back(controller); | 157 root_window_controllers_.push_back(controller); |
| 158 // The first root window will be the initial root for new windows. | |
| 159 if (!root_window_for_new_windows()) | |
| 160 set_root_window_for_new_windows(controller->GetWindow()); | |
| 158 } | 161 } |
| 159 | 162 |
| 160 void WmShellMus::RemoveRootWindowController( | 163 void WmShellMus::RemoveRootWindowController( |
| 161 WmRootWindowControllerMus* controller) { | 164 WmRootWindowControllerMus* controller) { |
| 162 auto iter = std::find(root_window_controllers_.begin(), | 165 auto iter = std::find(root_window_controllers_.begin(), |
| 163 root_window_controllers_.end(), controller); | 166 root_window_controllers_.end(), controller); |
| 164 DCHECK(iter != root_window_controllers_.end()); | 167 DCHECK(iter != root_window_controllers_.end()); |
| 165 root_window_controllers_.erase(iter); | 168 root_window_controllers_.erase(iter); |
| 166 } | 169 } |
| 167 | 170 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 199 } | 202 } |
| 200 | 203 |
| 201 WmWindow* WmShellMus::GetPrimaryRootWindow() { | 204 WmWindow* WmShellMus::GetPrimaryRootWindow() { |
| 202 return root_window_controllers_[0]->GetWindow(); | 205 return root_window_controllers_[0]->GetWindow(); |
| 203 } | 206 } |
| 204 | 207 |
| 205 WmWindow* WmShellMus::GetRootWindowForDisplayId(int64_t display_id) { | 208 WmWindow* WmShellMus::GetRootWindowForDisplayId(int64_t display_id) { |
| 206 return GetRootWindowControllerWithDisplayId(display_id)->GetWindow(); | 209 return GetRootWindowControllerWithDisplayId(display_id)->GetWindow(); |
| 207 } | 210 } |
| 208 | 211 |
| 209 WmWindow* WmShellMus::GetRootWindowForNewWindows() { | |
| 210 NOTIMPLEMENTED(); | |
| 211 return root_window_controllers_[0]->GetWindow(); | |
| 212 } | |
| 213 | |
| 214 const DisplayInfo& WmShellMus::GetDisplayInfo(int64_t display_id) const { | 212 const DisplayInfo& WmShellMus::GetDisplayInfo(int64_t display_id) const { |
| 215 NOTIMPLEMENTED(); | 213 NOTIMPLEMENTED(); |
| 216 static DisplayInfo fake_info; | 214 static DisplayInfo fake_info; |
| 217 return fake_info; | 215 return fake_info; |
| 218 } | 216 } |
| 219 | 217 |
| 220 bool WmShellMus::IsActiveDisplayId(int64_t display_id) const { | 218 bool WmShellMus::IsActiveDisplayId(int64_t display_id) const { |
| 221 // TODO: implement http://crbug.com/622480. | 219 // TODO: implement http://crbug.com/622480. |
| 222 NOTIMPLEMENTED(); | 220 NOTIMPLEMENTED(); |
| 223 return true; | 221 return true; |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 351 // static | 349 // static |
| 352 bool WmShellMus::IsActivationParent(ui::Window* window) { | 350 bool WmShellMus::IsActivationParent(ui::Window* window) { |
| 353 return window && IsActivatableShellWindowId( | 351 return window && IsActivatableShellWindowId( |
| 354 WmWindowMus::Get(window)->GetShellWindowId()); | 352 WmWindowMus::Get(window)->GetShellWindowId()); |
| 355 } | 353 } |
| 356 | 354 |
| 357 // TODO: support OnAttemptToReactivateWindow, http://crbug.com/615114. | 355 // TODO: support OnAttemptToReactivateWindow, http://crbug.com/615114. |
| 358 void WmShellMus::OnWindowTreeFocusChanged(ui::Window* gained_focus, | 356 void WmShellMus::OnWindowTreeFocusChanged(ui::Window* gained_focus, |
| 359 ui::Window* lost_focus) { | 357 ui::Window* lost_focus) { |
| 360 WmWindowMus* gained_active = GetToplevelAncestor(gained_focus); | 358 WmWindowMus* gained_active = GetToplevelAncestor(gained_focus); |
| 359 if (gained_active) { | |
| 360 set_root_window_for_new_windows( | |
| 361 static_cast<WmWindow*>(gained_active)->GetRootWindow()); | |
|
msw
2016/08/02 01:04:50
q: why is this cast needed? WmWindowMus::GetRootWi
James Cook
2016/08/02 16:16:04
WmWindowMus::GetRootWindow calls the const version
| |
| 362 } | |
| 361 WmWindowMus* lost_active = GetToplevelAncestor(gained_focus); | 363 WmWindowMus* lost_active = GetToplevelAncestor(gained_focus); |
| 362 if (gained_active == lost_active) | 364 if (gained_active == lost_active) |
| 363 return; | 365 return; |
| 364 | 366 |
| 365 FOR_EACH_OBSERVER(WmActivationObserver, activation_observers_, | 367 FOR_EACH_OBSERVER(WmActivationObserver, activation_observers_, |
| 366 OnWindowActivated(gained_active, lost_active)); | 368 OnWindowActivated(gained_active, lost_active)); |
| 367 } | 369 } |
| 368 | 370 |
| 369 void WmShellMus::OnDidDestroyClient(ui::WindowTreeClient* client) { | 371 void WmShellMus::OnDidDestroyClient(ui::WindowTreeClient* client) { |
| 370 DCHECK_EQ(window_tree_client(), client); | 372 DCHECK_EQ(window_tree_client(), client); |
| 371 client->RemoveObserver(this); | 373 client->RemoveObserver(this); |
| 372 } | 374 } |
| 373 | 375 |
| 374 } // namespace mus | 376 } // namespace mus |
| 375 } // namespace ash | 377 } // namespace ash |
| OLD | NEW |