| 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 16 matching lines...) Expand all Loading... |
| 27 #include "base/memory/ptr_util.h" | 27 #include "base/memory/ptr_util.h" |
| 28 #include "services/ui/common/event_matcher_util.h" | 28 #include "services/ui/common/event_matcher_util.h" |
| 29 #include "services/ui/common/types.h" | 29 #include "services/ui/common/types.h" |
| 30 #include "services/ui/public/cpp/property_type_converters.h" | 30 #include "services/ui/public/cpp/property_type_converters.h" |
| 31 #include "services/ui/public/cpp/window.h" | 31 #include "services/ui/public/cpp/window.h" |
| 32 #include "services/ui/public/cpp/window_property.h" | 32 #include "services/ui/public/cpp/window_property.h" |
| 33 #include "services/ui/public/cpp/window_tree_client.h" | 33 #include "services/ui/public/cpp/window_tree_client.h" |
| 34 #include "services/ui/public/interfaces/mus_constants.mojom.h" | 34 #include "services/ui/public/interfaces/mus_constants.mojom.h" |
| 35 #include "services/ui/public/interfaces/window_manager.mojom.h" | 35 #include "services/ui/public/interfaces/window_manager.mojom.h" |
| 36 #include "ui/base/hit_test.h" | 36 #include "ui/base/hit_test.h" |
| 37 #include "ui/display/display_observer.h" |
| 37 #include "ui/events/mojo/event.mojom.h" | 38 #include "ui/events/mojo/event.mojom.h" |
| 38 #include "ui/views/mus/pointer_watcher_event_router.h" | 39 #include "ui/views/mus/pointer_watcher_event_router.h" |
| 39 #include "ui/views/mus/screen_mus.h" | 40 #include "ui/views/mus/screen_mus.h" |
| 40 | 41 |
| 41 namespace ash { | 42 namespace ash { |
| 42 namespace mus { | 43 namespace mus { |
| 43 | 44 |
| 44 WindowManager::WindowManager(shell::Connector* connector) | 45 WindowManager::WindowManager(shell::Connector* connector) |
| 45 : connector_(connector) {} | 46 : connector_(connector) {} |
| 46 | 47 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 observers_.AddObserver(observer); | 131 observers_.AddObserver(observer); |
| 131 } | 132 } |
| 132 | 133 |
| 133 void WindowManager::RemoveObserver(WindowManagerObserver* observer) { | 134 void WindowManager::RemoveObserver(WindowManagerObserver* observer) { |
| 134 observers_.RemoveObserver(observer); | 135 observers_.RemoveObserver(observer); |
| 135 } | 136 } |
| 136 | 137 |
| 137 RootWindowController* WindowManager::CreateRootWindowController( | 138 RootWindowController* WindowManager::CreateRootWindowController( |
| 138 ui::Window* window, | 139 ui::Window* window, |
| 139 const display::Display& display) { | 140 const display::Display& display) { |
| 141 // CreateRootWindowController() means a new display is being added, so the |
| 142 // DisplayList needs to be updated. Calling AddDisplay() results in |
| 143 // notifying DisplayObservers. Ash code assumes when this happens there is |
| 144 // a valid RootWindowController for the new display. Suspend notifying |
| 145 // observers, add the Display, create the RootWindowController, and then |
| 146 // notify DisplayObservers. Classic ash does this by making sure |
| 147 // WindowTreeHostManager is added as a DisplayObserver early on. |
| 148 std::unique_ptr<display::DisplayListObserverLock> display_lock = |
| 149 screen_->display_list()->SuspendObserverUpdates(); |
| 150 const bool is_first_display = screen_->display_list()->displays().empty(); |
| 140 // TODO(sky): should be passed whether display is primary. | 151 // TODO(sky): should be passed whether display is primary. |
| 141 | 152 screen_->display_list()->AddDisplay( |
| 142 // There needs to be at least one display before creating | 153 display, is_first_display ? display::DisplayList::Type::PRIMARY |
| 143 // RootWindowController, otherwise initializing the compositor fails. | 154 : 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 | 155 |
| 150 std::unique_ptr<RootWindowController> root_window_controller_ptr( | 156 std::unique_ptr<RootWindowController> root_window_controller_ptr( |
| 151 new RootWindowController(this, window, display)); | 157 new RootWindowController(this, window, display)); |
| 152 RootWindowController* root_window_controller = | 158 RootWindowController* root_window_controller = |
| 153 root_window_controller_ptr.get(); | 159 root_window_controller_ptr.get(); |
| 154 root_window_controllers_.insert(std::move(root_window_controller_ptr)); | 160 root_window_controllers_.insert(std::move(root_window_controller_ptr)); |
| 155 | 161 |
| 156 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, | 162 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, |
| 157 OnRootWindowControllerAdded(root_window_controller)); | 163 OnRootWindowControllerAdded(root_window_controller)); |
| 158 | 164 |
| 159 if (!was_displays_empty) { | 165 FOR_EACH_OBSERVER(display::DisplayObserver, |
| 160 // If this isn't the initial display then add the display to Screen after | 166 *screen_->display_list()->observers(), |
| 161 // creating the RootWindowController. We need to do this after creating the | 167 OnDisplayAdded(root_window_controller->display())); |
| 162 // RootWindowController as adding the display triggers OnDisplayAdded(), | 168 |
| 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; | 169 return root_window_controller; |
| 169 } | 170 } |
| 170 | 171 |
| 171 void WindowManager::DestroyRootWindowController( | 172 void WindowManager::DestroyRootWindowController( |
| 172 RootWindowController* root_window_controller) { | 173 RootWindowController* root_window_controller) { |
| 173 if (root_window_controllers_.size() > 1) { | 174 if (root_window_controllers_.size() > 1) { |
| 174 DCHECK_NE(root_window_controller, GetPrimaryRootWindowController()); | 175 DCHECK_NE(root_window_controller, GetPrimaryRootWindowController()); |
| 175 root_window_controller->wm_root_window_controller()->MoveWindowsTo( | 176 root_window_controller->wm_root_window_controller()->MoveWindowsTo( |
| 176 WmWindowMus::Get(GetPrimaryRootWindowController()->root())); | 177 WmWindowMus::Get(GetPrimaryRootWindowController()->root())); |
| 177 } | 178 } |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 const ui::Event& event) { | 329 const ui::Event& event) { |
| 329 auto iter = accelerator_handlers_.find(GetAcceleratorNamespaceId(id)); | 330 auto iter = accelerator_handlers_.find(GetAcceleratorNamespaceId(id)); |
| 330 if (iter == accelerator_handlers_.end()) | 331 if (iter == accelerator_handlers_.end()) |
| 331 return ui::mojom::EventResult::HANDLED; | 332 return ui::mojom::EventResult::HANDLED; |
| 332 | 333 |
| 333 return iter->second->OnAccelerator(id, event); | 334 return iter->second->OnAccelerator(id, event); |
| 334 } | 335 } |
| 335 | 336 |
| 336 } // namespace mus | 337 } // namespace mus |
| 337 } // namespace ash | 338 } // namespace ash |
| OLD | NEW |