Chromium Code Reviews| Index: ash/mus/window_manager.cc |
| diff --git a/ash/mus/window_manager.cc b/ash/mus/window_manager.cc |
| index 43124a9d76f342be6111678c7dd0b8bd3b9e097c..cdcbeb5215db1d6451419c678f47a51145c13c73 100644 |
| --- a/ash/mus/window_manager.cc |
| +++ b/ash/mus/window_manager.cc |
| @@ -137,15 +137,20 @@ void WindowManager::RemoveObserver(WindowManagerObserver* observer) { |
| RootWindowController* WindowManager::CreateRootWindowController( |
| ui::Window* window, |
| const display::Display& display) { |
| - // TODO(sky): should be passed whether display is primary. |
| - |
| - // There needs to be at least one display before creating |
| - // RootWindowController, otherwise initializing the compositor fails. |
| + // CreateRootWindowController() means a new display is being added, so the |
| + // DisplayList needs to be updated. Calling AddDisplay() results in |
| + // 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.
|
| + // a valid RootWindowController for the new display. Suspend notifying |
| + // observers, add the Display, create the RootWindowController, and then |
| + // notify DisplayObservers. Classic ash does this by making sure |
| + // WindowTreeHostManager is added as a DisplayObserver early on. |
| + std::unique_ptr<display::DisplayListObserverLock> display_lock = |
| + screen_->display_list()->SuspendObserverUpdates(); |
| 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.
|
| - if (was_displays_empty) { |
| - screen_->display_list()->AddDisplay(display, |
| - display::DisplayList::Type::PRIMARY); |
| - } |
| + // 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
|
| + screen_->display_list()->AddDisplay( |
| + display, was_displays_empty ? display::DisplayList::Type::PRIMARY |
| + : display::DisplayList::Type::NOT_PRIMARY); |
| std::unique_ptr<RootWindowController> root_window_controller_ptr( |
| new RootWindowController(this, window, display)); |
| @@ -156,15 +161,6 @@ RootWindowController* WindowManager::CreateRootWindowController( |
| FOR_EACH_OBSERVER(WindowManagerObserver, observers_, |
| OnRootWindowControllerAdded(root_window_controller)); |
| - if (!was_displays_empty) { |
| - // If this isn't the initial display then add the display to Screen after |
| - // creating the RootWindowController. We need to do this after creating the |
| - // RootWindowController as adding the display triggers OnDisplayAdded(), |
| - // which triggers some overrides asking for the RootWindowController for the |
| - // new display. |
| - screen_->display_list()->AddDisplay( |
| - display, display::DisplayList::Type::NOT_PRIMARY); |
| - } |
| return root_window_controller; |
| } |