| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/window_manager.h" | 5 #include "ash/mus/window_manager.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 | 157 |
| 158 std::unique_ptr<RootWindowController> root_window_controller_ptr( | 158 std::unique_ptr<RootWindowController> root_window_controller_ptr( |
| 159 new RootWindowController(this, window, display)); | 159 new RootWindowController(this, window, display)); |
| 160 RootWindowController* root_window_controller = | 160 RootWindowController* root_window_controller = |
| 161 root_window_controller_ptr.get(); | 161 root_window_controller_ptr.get(); |
| 162 root_window_controllers_.insert(std::move(root_window_controller_ptr)); | 162 root_window_controllers_.insert(std::move(root_window_controller_ptr)); |
| 163 | 163 |
| 164 // TODO: this should be called when logged in. See http://crbug.com/654606. | 164 // TODO: this should be called when logged in. See http://crbug.com/654606. |
| 165 root_window_controller->wm_root_window_controller()->CreateShelf(); | 165 root_window_controller->wm_root_window_controller()->CreateShelf(); |
| 166 | 166 |
| 167 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, | 167 for (auto& observer : observers_) |
| 168 OnRootWindowControllerAdded(root_window_controller)); | 168 observer.OnRootWindowControllerAdded(root_window_controller); |
| 169 | 169 |
| 170 FOR_EACH_OBSERVER(display::DisplayObserver, | 170 for (auto& observer : *screen_->display_list()->observers()) |
| 171 *screen_->display_list()->observers(), | 171 observer.OnDisplayAdded(root_window_controller->display()); |
| 172 OnDisplayAdded(root_window_controller->display())); | |
| 173 | 172 |
| 174 return root_window_controller; | 173 return root_window_controller; |
| 175 } | 174 } |
| 176 | 175 |
| 177 void WindowManager::DestroyRootWindowController( | 176 void WindowManager::DestroyRootWindowController( |
| 178 RootWindowController* root_window_controller) { | 177 RootWindowController* root_window_controller) { |
| 179 if (root_window_controllers_.size() > 1) { | 178 if (root_window_controllers_.size() > 1) { |
| 180 DCHECK_NE(root_window_controller, GetPrimaryRootWindowController()); | 179 DCHECK_NE(root_window_controller, GetPrimaryRootWindowController()); |
| 181 root_window_controller->wm_root_window_controller()->MoveWindowsTo( | 180 root_window_controller->wm_root_window_controller()->MoveWindowsTo( |
| 182 WmWindowMus::Get(GetPrimaryRootWindowController()->root())); | 181 WmWindowMus::Get(GetPrimaryRootWindowController()->root())); |
| 183 } | 182 } |
| 184 | 183 |
| 185 ui::Window* root_window = root_window_controller->root(); | 184 ui::Window* root_window = root_window_controller->root(); |
| 186 auto it = FindRootWindowControllerByWindow(root_window); | 185 auto it = FindRootWindowControllerByWindow(root_window); |
| 187 DCHECK(it != root_window_controllers_.end()); | 186 DCHECK(it != root_window_controllers_.end()); |
| 188 | 187 |
| 189 (*it)->Shutdown(); | 188 (*it)->Shutdown(); |
| 190 | 189 |
| 191 // NOTE: classic ash deleted RootWindowController after a delay (DeleteSoon()) | 190 // NOTE: classic ash deleted RootWindowController after a delay (DeleteSoon()) |
| 192 // this may need to change to mirror that. | 191 // this may need to change to mirror that. |
| 193 root_window_controllers_.erase(it); | 192 root_window_controllers_.erase(it); |
| 194 } | 193 } |
| 195 | 194 |
| 196 void WindowManager::Shutdown() { | 195 void WindowManager::Shutdown() { |
| 197 if (!window_tree_client_) | 196 if (!window_tree_client_) |
| 198 return; | 197 return; |
| 199 | 198 |
| 200 // Observers can rely on WmShell from the callback. So notify the observers | 199 // Observers can rely on WmShell from the callback. So notify the observers |
| 201 // before destroying it. | 200 // before destroying it. |
| 202 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, | 201 for (auto& observer : observers_) |
| 203 OnWindowTreeClientDestroyed()); | 202 observer.OnWindowTreeClientDestroyed(); |
| 204 | 203 |
| 205 // Primary RootWindowController must be destroyed last. | 204 // Primary RootWindowController must be destroyed last. |
| 206 RootWindowController* primary_root_window_controller = | 205 RootWindowController* primary_root_window_controller = |
| 207 GetPrimaryRootWindowController(); | 206 GetPrimaryRootWindowController(); |
| 208 std::set<RootWindowController*> secondary_root_window_controllers; | 207 std::set<RootWindowController*> secondary_root_window_controllers; |
| 209 for (auto& root_window_controller_ptr : root_window_controllers_) { | 208 for (auto& root_window_controller_ptr : root_window_controllers_) { |
| 210 if (root_window_controller_ptr.get() != primary_root_window_controller) | 209 if (root_window_controller_ptr.get() != primary_root_window_controller) |
| 211 secondary_root_window_controllers.insert( | 210 secondary_root_window_controllers.insert( |
| 212 root_window_controller_ptr.get()); | 211 root_window_controller_ptr.get()); |
| 213 } | 212 } |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 const ui::Event& event) { | 365 const ui::Event& event) { |
| 367 auto iter = accelerator_handlers_.find(GetAcceleratorNamespaceId(id)); | 366 auto iter = accelerator_handlers_.find(GetAcceleratorNamespaceId(id)); |
| 368 if (iter == accelerator_handlers_.end()) | 367 if (iter == accelerator_handlers_.end()) |
| 369 return ui::mojom::EventResult::HANDLED; | 368 return ui::mojom::EventResult::HANDLED; |
| 370 | 369 |
| 371 return iter->second->OnAccelerator(id, event); | 370 return iter->second->OnAccelerator(id, event); |
| 372 } | 371 } |
| 373 | 372 |
| 374 } // namespace mus | 373 } // namespace mus |
| 375 } // namespace ash | 374 } // namespace ash |
| OLD | NEW |