Chromium Code Reviews| 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 observers_.AddObserver(observer); | 130 observers_.AddObserver(observer); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void WindowManager::RemoveObserver(WindowManagerObserver* observer) { | 133 void WindowManager::RemoveObserver(WindowManagerObserver* observer) { |
| 134 observers_.RemoveObserver(observer); | 134 observers_.RemoveObserver(observer); |
| 135 } | 135 } |
| 136 | 136 |
| 137 RootWindowController* WindowManager::CreateRootWindowController( | 137 RootWindowController* WindowManager::CreateRootWindowController( |
| 138 ui::Window* window, | 138 ui::Window* window, |
| 139 const display::Display& display) { | 139 const display::Display& display) { |
| 140 // CreateRootWindowController() means a new display is being added, so the | |
| 141 // DisplayList needs to be updated. Calling AddDisplay() results in | |
| 142 // notifying DisplayObservers. Ash code assumes when this happens their is | |
|
James Cook
2016/09/29 04:15:05
nit: their -> there
sky
2016/09/29 18:04:44
Done.
| |
| 143 // a valid RootWindowController for the new display. Suspend notifying | |
| 144 // observers, add the Display, create the RootWindowController, and then | |
| 145 // notify DisplayObservers. Classic ash does this by making sure | |
| 146 // WindowTreeHostManager is added as a DisplayObserver early on. | |
| 147 std::unique_ptr<display::DisplayListObserverLock> display_lock = | |
| 148 screen_->display_list()->SuspendObserverUpdates(); | |
| 149 const bool was_displays_empty = screen_->display_list()->displays().empty(); | |
|
James Cook
2016/09/29 04:15:05
optional: |is_first_display| ?
sky
2016/09/29 18:04:44
Done.
| |
| 140 // TODO(sky): should be passed whether display is primary. | 150 // TODO(sky): should be passed whether display is primary. |
|
James Cook
2016/09/29 04:15:05
Is this todo still relevant?
sky
2016/09/29 18:04:44
I *think* so, but I'm not 100% positive. I'm not s
| |
| 141 | 151 screen_->display_list()->AddDisplay( |
| 142 // There needs to be at least one display before creating | 152 display, was_displays_empty ? display::DisplayList::Type::PRIMARY |
| 143 // RootWindowController, otherwise initializing the compositor fails. | 153 : display::DisplayList::Type::NOT_PRIMARY); |
| 144 const bool was_displays_empty = screen_->display_list()->displays().empty(); | |
| 145 if (was_displays_empty) { | |
| 146 screen_->display_list()->AddDisplay(display, | |
| 147 display::DisplayList::Type::PRIMARY); | |
| 148 } | |
| 149 | 154 |
| 150 std::unique_ptr<RootWindowController> root_window_controller_ptr( | 155 std::unique_ptr<RootWindowController> root_window_controller_ptr( |
| 151 new RootWindowController(this, window, display)); | 156 new RootWindowController(this, window, display)); |
| 152 RootWindowController* root_window_controller = | 157 RootWindowController* root_window_controller = |
| 153 root_window_controller_ptr.get(); | 158 root_window_controller_ptr.get(); |
| 154 root_window_controllers_.insert(std::move(root_window_controller_ptr)); | 159 root_window_controllers_.insert(std::move(root_window_controller_ptr)); |
| 155 | 160 |
| 156 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, | 161 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, |
| 157 OnRootWindowControllerAdded(root_window_controller)); | 162 OnRootWindowControllerAdded(root_window_controller)); |
| 158 | 163 |
| 159 if (!was_displays_empty) { | |
| 160 // If this isn't the initial display then add the display to Screen after | |
| 161 // creating the RootWindowController. We need to do this after creating the | |
| 162 // RootWindowController as adding the display triggers OnDisplayAdded(), | |
| 163 // which triggers some overrides asking for the RootWindowController for the | |
| 164 // new display. | |
| 165 screen_->display_list()->AddDisplay( | |
| 166 display, display::DisplayList::Type::NOT_PRIMARY); | |
| 167 } | |
| 168 return root_window_controller; | 164 return root_window_controller; |
| 169 } | 165 } |
| 170 | 166 |
| 171 void WindowManager::DestroyRootWindowController( | 167 void WindowManager::DestroyRootWindowController( |
| 172 RootWindowController* root_window_controller) { | 168 RootWindowController* root_window_controller) { |
| 173 if (root_window_controllers_.size() > 1) { | 169 if (root_window_controllers_.size() > 1) { |
| 174 DCHECK_NE(root_window_controller, GetPrimaryRootWindowController()); | 170 DCHECK_NE(root_window_controller, GetPrimaryRootWindowController()); |
| 175 root_window_controller->wm_root_window_controller()->MoveWindowsTo( | 171 root_window_controller->wm_root_window_controller()->MoveWindowsTo( |
| 176 WmWindowMus::Get(GetPrimaryRootWindowController()->root())); | 172 WmWindowMus::Get(GetPrimaryRootWindowController()->root())); |
| 177 } | 173 } |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 328 const ui::Event& event) { | 324 const ui::Event& event) { |
| 329 auto iter = accelerator_handlers_.find(GetAcceleratorNamespaceId(id)); | 325 auto iter = accelerator_handlers_.find(GetAcceleratorNamespaceId(id)); |
| 330 if (iter == accelerator_handlers_.end()) | 326 if (iter == accelerator_handlers_.end()) |
| 331 return ui::mojom::EventResult::HANDLED; | 327 return ui::mojom::EventResult::HANDLED; |
| 332 | 328 |
| 333 return iter->second->OnAccelerator(id, event); | 329 return iter->second->OnAccelerator(id, event); |
| 334 } | 330 } |
| 335 | 331 |
| 336 } // namespace mus | 332 } // namespace mus |
| 337 } // namespace ash | 333 } // namespace ash |
| OLD | NEW |