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 |
11 #include "ash/mus/accelerators/accelerator_handler.h" | 11 #include "ash/mus/accelerators/accelerator_handler.h" |
12 #include "ash/mus/accelerators/accelerator_ids.h" | 12 #include "ash/mus/accelerators/accelerator_ids.h" |
13 #include "ash/mus/app_list_presenter_mus.h" | 13 #include "ash/mus/app_list_presenter_mus.h" |
14 #include "ash/mus/bridge/wm_lookup_mus.h" | 14 #include "ash/mus/bridge/wm_lookup_mus.h" |
15 #include "ash/mus/bridge/wm_root_window_controller_mus.h" | 15 #include "ash/mus/bridge/wm_root_window_controller_mus.h" |
16 #include "ash/mus/bridge/wm_shell_mus.h" | 16 #include "ash/mus/bridge/wm_shell_mus.h" |
17 #include "ash/mus/bridge/wm_window_mus.h" | 17 #include "ash/mus/bridge/wm_window_mus.h" |
18 #include "ash/mus/move_event_handler.h" | 18 #include "ash/mus/move_event_handler.h" |
19 #include "ash/mus/non_client_frame_controller.h" | 19 #include "ash/mus/non_client_frame_controller.h" |
20 #include "ash/mus/property_util.h" | 20 #include "ash/mus/property_util.h" |
21 #include "ash/mus/root_window_controller.h" | 21 #include "ash/mus/root_window_controller.h" |
22 #include "ash/mus/shadow_controller.h" | 22 #include "ash/mus/shadow_controller.h" |
23 #include "ash/mus/shell_delegate_mus.h" | 23 #include "ash/mus/shell_delegate_mus.h" |
24 #include "ash/mus/window_manager_observer.h" | 24 #include "ash/mus/window_manager_observer.h" |
25 #include "ash/public/cpp/shell_window_ids.h" | 25 #include "ash/public/cpp/shell_window_ids.h" |
26 #include "base/memory/ptr_util.h" | 26 #include "base/memory/ptr_util.h" |
| 27 #include "services/service_manager/public/cpp/connector.h" |
27 #include "services/ui/common/event_matcher_util.h" | 28 #include "services/ui/common/event_matcher_util.h" |
28 #include "services/ui/common/types.h" | 29 #include "services/ui/common/types.h" |
29 #include "services/ui/public/cpp/property_type_converters.h" | 30 #include "services/ui/public/cpp/property_type_converters.h" |
30 #include "services/ui/public/cpp/window.h" | 31 #include "services/ui/public/cpp/window.h" |
31 #include "services/ui/public/cpp/window_property.h" | 32 #include "services/ui/public/cpp/window_property.h" |
32 #include "services/ui/public/cpp/window_tree_client.h" | 33 #include "services/ui/public/cpp/window_tree_client.h" |
33 #include "services/ui/public/interfaces/mus_constants.mojom.h" | 34 #include "services/ui/public/interfaces/mus_constants.mojom.h" |
34 #include "services/ui/public/interfaces/window_manager.mojom.h" | 35 #include "services/ui/public/interfaces/window_manager.mojom.h" |
35 #include "ui/base/hit_test.h" | 36 #include "ui/base/hit_test.h" |
36 #include "ui/display/display_observer.h" | 37 #include "ui/display/display_observer.h" |
(...skipping 10 matching lines...) Expand all Loading... |
47 WindowManager::~WindowManager() { | 48 WindowManager::~WindowManager() { |
48 Shutdown(); | 49 Shutdown(); |
49 } | 50 } |
50 | 51 |
51 void WindowManager::Init( | 52 void WindowManager::Init( |
52 std::unique_ptr<ui::WindowTreeClient> window_tree_client, | 53 std::unique_ptr<ui::WindowTreeClient> window_tree_client, |
53 const scoped_refptr<base::SequencedWorkerPool>& blocking_pool) { | 54 const scoped_refptr<base::SequencedWorkerPool>& blocking_pool) { |
54 DCHECK(!window_tree_client_); | 55 DCHECK(!window_tree_client_); |
55 window_tree_client_ = std::move(window_tree_client); | 56 window_tree_client_ = std::move(window_tree_client); |
56 | 57 |
| 58 // |connector_| will be null in some tests. |
| 59 if (connector_) |
| 60 connector_->ConnectToInterface("service:ui", &display_controller_); |
| 61 |
57 screen_ = base::MakeUnique<display::ScreenBase>(); | 62 screen_ = base::MakeUnique<display::ScreenBase>(); |
58 | 63 |
59 pointer_watcher_event_router_.reset( | 64 pointer_watcher_event_router_.reset( |
60 new views::PointerWatcherEventRouter(window_tree_client_.get())); | 65 new views::PointerWatcherEventRouter(window_tree_client_.get())); |
61 | 66 |
62 shadow_controller_.reset(new ShadowController(window_tree_client_.get())); | 67 shadow_controller_.reset(new ShadowController(window_tree_client_.get())); |
63 | 68 |
64 // The insets are roughly what is needed by CustomFrameView. The expectation | 69 // The insets are roughly what is needed by CustomFrameView. The expectation |
65 // is at some point we'll write our own NonClientFrameView and get the insets | 70 // is at some point we'll write our own NonClientFrameView and get the insets |
66 // from it. | 71 // from it. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 } | 134 } |
130 | 135 |
131 void WindowManager::AddObserver(WindowManagerObserver* observer) { | 136 void WindowManager::AddObserver(WindowManagerObserver* observer) { |
132 observers_.AddObserver(observer); | 137 observers_.AddObserver(observer); |
133 } | 138 } |
134 | 139 |
135 void WindowManager::RemoveObserver(WindowManagerObserver* observer) { | 140 void WindowManager::RemoveObserver(WindowManagerObserver* observer) { |
136 observers_.RemoveObserver(observer); | 141 observers_.RemoveObserver(observer); |
137 } | 142 } |
138 | 143 |
| 144 display::mojom::DisplayController* WindowManager::GetDisplayController() { |
| 145 return display_controller_ ? display_controller_.get() : nullptr; |
| 146 } |
| 147 |
139 RootWindowController* WindowManager::CreateRootWindowController( | 148 RootWindowController* WindowManager::CreateRootWindowController( |
140 ui::Window* window, | 149 ui::Window* window, |
141 const display::Display& display) { | 150 const display::Display& display) { |
142 // CreateRootWindowController() means a new display is being added, so the | 151 // CreateRootWindowController() means a new display is being added, so the |
143 // DisplayList needs to be updated. Calling AddDisplay() results in | 152 // DisplayList needs to be updated. Calling AddDisplay() results in |
144 // notifying DisplayObservers. Ash code assumes when this happens there is | 153 // notifying DisplayObservers. Ash code assumes when this happens there is |
145 // a valid RootWindowController for the new display. Suspend notifying | 154 // a valid RootWindowController for the new display. Suspend notifying |
146 // observers, add the Display, create the RootWindowController, and then | 155 // observers, add the Display, create the RootWindowController, and then |
147 // notify DisplayObservers. Classic ash does this by making sure | 156 // notify DisplayObservers. Classic ash does this by making sure |
148 // WindowTreeHostManager is added as a DisplayObserver early on. | 157 // WindowTreeHostManager is added as a DisplayObserver early on. |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 const display::Display& display) { | 335 const display::Display& display) { |
327 CreateRootWindowController(window, display); | 336 CreateRootWindowController(window, display); |
328 } | 337 } |
329 | 338 |
330 void WindowManager::OnWmDisplayRemoved(ui::Window* window) { | 339 void WindowManager::OnWmDisplayRemoved(ui::Window* window) { |
331 auto iter = FindRootWindowControllerByWindow(window); | 340 auto iter = FindRootWindowControllerByWindow(window); |
332 DCHECK(iter != root_window_controllers_.end()); | 341 DCHECK(iter != root_window_controllers_.end()); |
333 DestroyRootWindowController(iter->get()); | 342 DestroyRootWindowController(iter->get()); |
334 } | 343 } |
335 | 344 |
| 345 void WindowManager::OnWmDisplayModified(const display::Display& display) { |
| 346 for (auto& controller : root_window_controllers_) { |
| 347 if (controller->display().id() == display.id()) { |
| 348 controller->SetDisplay(display); |
| 349 // The root window will be resized by the window server. |
| 350 return; |
| 351 } |
| 352 } |
| 353 |
| 354 NOTREACHED(); |
| 355 } |
| 356 |
336 void WindowManager::OnWmPerformMoveLoop( | 357 void WindowManager::OnWmPerformMoveLoop( |
337 ui::Window* window, | 358 ui::Window* window, |
338 ui::mojom::MoveLoopSource source, | 359 ui::mojom::MoveLoopSource source, |
339 const gfx::Point& cursor_location, | 360 const gfx::Point& cursor_location, |
340 const base::Callback<void(bool)>& on_done) { | 361 const base::Callback<void(bool)>& on_done) { |
341 WmWindowMus* child_window = WmWindowMus::Get(window); | 362 WmWindowMus* child_window = WmWindowMus::Get(window); |
342 MoveEventHandler* handler = MoveEventHandler::GetForWindow(child_window); | 363 MoveEventHandler* handler = MoveEventHandler::GetForWindow(child_window); |
343 if (!handler) { | 364 if (!handler) { |
344 on_done.Run(false); | 365 on_done.Run(false); |
345 return; | 366 return; |
(...skipping 18 matching lines...) Expand all Loading... |
364 const ui::Event& event) { | 385 const ui::Event& event) { |
365 auto iter = accelerator_handlers_.find(GetAcceleratorNamespaceId(id)); | 386 auto iter = accelerator_handlers_.find(GetAcceleratorNamespaceId(id)); |
366 if (iter == accelerator_handlers_.end()) | 387 if (iter == accelerator_handlers_.end()) |
367 return ui::mojom::EventResult::HANDLED; | 388 return ui::mojom::EventResult::HANDLED; |
368 | 389 |
369 return iter->second->OnAccelerator(id, event); | 390 return iter->second->OnAccelerator(id, event); |
370 } | 391 } |
371 | 392 |
372 } // namespace mus | 393 } // namespace mus |
373 } // namespace ash | 394 } // namespace ash |
OLD | NEW |