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 15 matching lines...) Expand all Loading... | |
26 #include "services/ui/common/types.h" | 26 #include "services/ui/common/types.h" |
27 #include "services/ui/public/cpp/property_type_converters.h" | 27 #include "services/ui/public/cpp/property_type_converters.h" |
28 #include "services/ui/public/cpp/window.h" | 28 #include "services/ui/public/cpp/window.h" |
29 #include "services/ui/public/cpp/window_property.h" | 29 #include "services/ui/public/cpp/window_property.h" |
30 #include "services/ui/public/cpp/window_tree_client.h" | 30 #include "services/ui/public/cpp/window_tree_client.h" |
31 #include "services/ui/public/interfaces/mus_constants.mojom.h" | 31 #include "services/ui/public/interfaces/mus_constants.mojom.h" |
32 #include "services/ui/public/interfaces/window_manager.mojom.h" | 32 #include "services/ui/public/interfaces/window_manager.mojom.h" |
33 #include "ui/app_list/presenter/app_list_presenter.h" | 33 #include "ui/app_list/presenter/app_list_presenter.h" |
34 #include "ui/base/hit_test.h" | 34 #include "ui/base/hit_test.h" |
35 #include "ui/events/mojo/event.mojom.h" | 35 #include "ui/events/mojo/event.mojom.h" |
36 #include "ui/views/mus/pointer_watcher_event_router.h" | |
36 #include "ui/views/mus/screen_mus.h" | 37 #include "ui/views/mus/screen_mus.h" |
37 | 38 |
38 namespace ash { | 39 namespace ash { |
39 namespace mus { | 40 namespace mus { |
40 | 41 |
41 void AssertTrue(bool success) { | 42 void AssertTrue(bool success) { |
42 DCHECK(success); | 43 DCHECK(success); |
43 } | 44 } |
44 | 45 |
45 // TODO(jamescook): Port ash::sysui::AppListPresenterMus and eliminate this. | 46 // TODO(jamescook): Port ash::sysui::AppListPresenterMus and eliminate this. |
(...skipping 24 matching lines...) Expand all Loading... | |
70 | 71 |
71 WindowManager::~WindowManager() { | 72 WindowManager::~WindowManager() { |
72 // NOTE: |window_tree_client_| may already be null. | 73 // NOTE: |window_tree_client_| may already be null. |
73 delete window_tree_client_; | 74 delete window_tree_client_; |
74 } | 75 } |
75 | 76 |
76 void WindowManager::Init(ui::WindowTreeClient* window_tree_client) { | 77 void WindowManager::Init(ui::WindowTreeClient* window_tree_client) { |
77 DCHECK(!window_tree_client_); | 78 DCHECK(!window_tree_client_); |
78 window_tree_client_ = window_tree_client; | 79 window_tree_client_ = window_tree_client; |
79 | 80 |
81 pointer_watcher_event_router_.reset( | |
James Cook
2016/08/12 16:08:53
optional: MakeUnique?
sky
2016/08/12 17:59:37
I tend to feel that having to create a temp just t
James Cook
2016/08/12 18:26:12
OK, makes sense.
| |
82 new views::PointerWatcherEventRouter(window_tree_client)); | |
83 | |
80 shadow_controller_.reset(new ShadowController(window_tree_client)); | 84 shadow_controller_.reset(new ShadowController(window_tree_client)); |
81 | 85 |
82 // The insets are roughly what is needed by CustomFrameView. The expectation | 86 // The insets are roughly what is needed by CustomFrameView. The expectation |
83 // is at some point we'll write our own NonClientFrameView and get the insets | 87 // is at some point we'll write our own NonClientFrameView and get the insets |
84 // from it. | 88 // from it. |
85 ui::mojom::FrameDecorationValuesPtr frame_decoration_values = | 89 ui::mojom::FrameDecorationValuesPtr frame_decoration_values = |
86 ui::mojom::FrameDecorationValues::New(); | 90 ui::mojom::FrameDecorationValues::New(); |
87 const gfx::Insets client_area_insets = | 91 const gfx::Insets client_area_insets = |
88 NonClientFrameController::GetPreferredClientAreaInsets(); | 92 NonClientFrameController::GetPreferredClientAreaInsets(); |
89 frame_decoration_values->normal_client_area_insets = client_area_insets; | 93 frame_decoration_values->normal_client_area_insets = client_area_insets; |
90 frame_decoration_values->maximized_client_area_insets = client_area_insets; | 94 frame_decoration_values->maximized_client_area_insets = client_area_insets; |
91 frame_decoration_values->max_title_bar_button_width = | 95 frame_decoration_values->max_title_bar_button_width = |
92 NonClientFrameController::GetMaxTitleBarButtonWidth(); | 96 NonClientFrameController::GetMaxTitleBarButtonWidth(); |
93 window_manager_client_->SetFrameDecorationValues( | 97 window_manager_client_->SetFrameDecorationValues( |
94 std::move(frame_decoration_values)); | 98 std::move(frame_decoration_values)); |
95 | 99 |
96 std::unique_ptr<ShellDelegate> shell_delegate(new ShellDelegateMus( | 100 std::unique_ptr<ShellDelegate> shell_delegate(new ShellDelegateMus( |
97 base::MakeUnique<AppListPresenterStub>(), connector_)); | 101 base::MakeUnique<AppListPresenterStub>(), connector_)); |
98 shell_.reset(new WmShellMus(std::move(shell_delegate), this)); | 102 shell_.reset(new WmShellMus(std::move(shell_delegate), this, |
103 pointer_watcher_event_router_.get())); | |
99 shell_->Initialize(); | 104 shell_->Initialize(); |
100 lookup_.reset(new WmLookupMus); | 105 lookup_.reset(new WmLookupMus); |
101 } | 106 } |
102 | 107 |
103 void WindowManager::SetScreenLocked(bool is_locked) { | 108 void WindowManager::SetScreenLocked(bool is_locked) { |
104 // TODO: screen locked state needs to be persisted for newly added displays. | 109 // TODO: screen locked state needs to be persisted for newly added displays. |
105 for (auto& root_window_controller : root_window_controllers_) { | 110 for (auto& root_window_controller : root_window_controllers_) { |
106 WmWindowMus* non_lock_screen_containers_container = | 111 WmWindowMus* non_lock_screen_containers_container = |
107 root_window_controller->GetWindowByShellWindowId( | 112 root_window_controller->GetWindowByShellWindowId( |
108 kShellWindowId_NonLockScreenContainersContainer); | 113 kShellWindowId_NonLockScreenContainersContainer); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
209 // |root_window_controllers_|. | 214 // |root_window_controllers_|. |
210 DCHECK(root_window_controllers_.empty()); | 215 DCHECK(root_window_controllers_.empty()); |
211 | 216 |
212 lookup_.reset(); | 217 lookup_.reset(); |
213 shell_.reset(); | 218 shell_.reset(); |
214 shadow_controller_.reset(); | 219 shadow_controller_.reset(); |
215 | 220 |
216 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, | 221 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, |
217 OnWindowTreeClientDestroyed()); | 222 OnWindowTreeClientDestroyed()); |
218 | 223 |
224 pointer_watcher_event_router_.reset(); | |
225 | |
219 window_tree_client_ = nullptr; | 226 window_tree_client_ = nullptr; |
220 window_manager_client_ = nullptr; | 227 window_manager_client_ = nullptr; |
221 } | 228 } |
222 | 229 |
223 void WindowManager::OnPointerEventObserved(const ui::PointerEvent& event, | 230 void WindowManager::OnPointerEventObserved(const ui::PointerEvent& event, |
224 ui::Window* target) { | 231 ui::Window* target) { |
225 // Does not use PointerWatchers. | 232 pointer_watcher_event_router_->OnPointerEventObserved(event, target); |
226 } | 233 } |
227 | 234 |
228 void WindowManager::SetWindowManagerClient(ui::WindowManagerClient* client) { | 235 void WindowManager::SetWindowManagerClient(ui::WindowManagerClient* client) { |
229 window_manager_client_ = client; | 236 window_manager_client_ = client; |
230 } | 237 } |
231 | 238 |
232 bool WindowManager::OnWmSetBounds(ui::Window* window, gfx::Rect* bounds) { | 239 bool WindowManager::OnWmSetBounds(ui::Window* window, gfx::Rect* bounds) { |
233 // TODO(sky): this indirectly sets bounds, which is against what | 240 // TODO(sky): this indirectly sets bounds, which is against what |
234 // OnWmSetBounds() recommends doing. Remove that restriction, or fix this. | 241 // OnWmSetBounds() recommends doing. Remove that restriction, or fix this. |
235 WmWindowMus::Get(window)->SetBounds(*bounds); | 242 WmWindowMus::Get(window)->SetBounds(*bounds); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
298 const ui::Event& event) { | 305 const ui::Event& event) { |
299 auto iter = accelerator_handlers_.find(GetAcceleratorNamespaceId(id)); | 306 auto iter = accelerator_handlers_.find(GetAcceleratorNamespaceId(id)); |
300 if (iter == accelerator_handlers_.end()) | 307 if (iter == accelerator_handlers_.end()) |
301 return ui::mojom::EventResult::HANDLED; | 308 return ui::mojom::EventResult::HANDLED; |
302 | 309 |
303 return iter->second->OnAccelerator(id, event); | 310 return iter->second->OnAccelerator(id, event); |
304 } | 311 } |
305 | 312 |
306 } // namespace mus | 313 } // namespace mus |
307 } // namespace ash | 314 } // namespace ash |
OLD | NEW |