OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "mash/wm/root_window_controller.h" | 5 #include "mash/wm/root_window_controller.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "components/mus/common/util.h" | 10 #include "components/mus/common/util.h" |
11 #include "components/mus/public/cpp/event_matcher.h" | 11 #include "components/mus/public/cpp/event_matcher.h" |
12 #include "components/mus/public/cpp/window.h" | 12 #include "components/mus/public/cpp/window.h" |
13 #include "components/mus/public/cpp/window_tree_connection.h" | 13 #include "components/mus/public/cpp/window_tree_connection.h" |
14 #include "components/mus/public/cpp/window_tree_host_factory.h" | 14 #include "components/mus/public/cpp/window_tree_host_factory.h" |
15 #include "mash/shell/public/interfaces/shell.mojom.h" | 15 #include "mash/shell/public/interfaces/shell.mojom.h" |
16 #include "mash/wm/background_layout.h" | 16 #include "mash/wm/background_layout.h" |
17 #include "mash/wm/screenlock_layout.h" | 17 #include "mash/wm/screenlock_layout.h" |
18 #include "mash/wm/shadow_controller.h" | 18 #include "mash/wm/shadow_controller.h" |
19 #include "mash/wm/shelf_layout.h" | 19 #include "mash/wm/shelf_layout.h" |
20 #include "mash/wm/window_layout.h" | 20 #include "mash/wm/window_layout.h" |
21 #include "mash/wm/window_manager.h" | 21 #include "mash/wm/window_manager.h" |
22 #include "mash/wm/window_manager_application.h" | 22 #include "mash/wm/window_manager_application.h" |
23 #include "mojo/shell/public/cpp/application_impl.h" | 23 #include "mojo/shell/public/cpp/shell.h" |
24 | 24 |
25 namespace mash { | 25 namespace mash { |
26 namespace wm { | 26 namespace wm { |
27 namespace { | 27 namespace { |
28 | 28 |
29 const uint32_t kWindowSwitchAccelerator = 1; | 29 const uint32_t kWindowSwitchAccelerator = 1; |
30 | 30 |
31 void AssertTrue(bool success) { | 31 void AssertTrue(bool success) { |
32 DCHECK(success); | 32 DCHECK(success); |
33 } | 33 } |
34 | 34 |
35 } // namespace | 35 } // namespace |
36 | 36 |
37 // static | 37 // static |
38 RootWindowController* RootWindowController::CreateUsingWindowTreeHost( | 38 RootWindowController* RootWindowController::CreateUsingWindowTreeHost( |
39 WindowManagerApplication* app) { | 39 WindowManagerApplication* app) { |
40 RootWindowController* controller = new RootWindowController(app); | 40 RootWindowController* controller = new RootWindowController(app); |
41 mus::CreateWindowTreeHost(app->app(), controller, | 41 mus::CreateWindowTreeHost(app->shell(), controller, |
42 &controller->window_tree_host_, | 42 &controller->window_tree_host_, |
43 controller->window_manager_.get()); | 43 controller->window_manager_.get()); |
44 return controller; | 44 return controller; |
45 } | 45 } |
46 | 46 |
47 // static | 47 // static |
48 RootWindowController* RootWindowController::CreateFromDisplay( | 48 RootWindowController* RootWindowController::CreateFromDisplay( |
49 WindowManagerApplication* app, | 49 WindowManagerApplication* app, |
50 mus::mojom::DisplayPtr display, | 50 mus::mojom::DisplayPtr display, |
51 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> client_request) { | 51 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> client_request) { |
52 RootWindowController* controller = new RootWindowController(app); | 52 RootWindowController* controller = new RootWindowController(app); |
53 controller->display_ = std::move(display); | 53 controller->display_ = std::move(display); |
54 mus::WindowTreeConnection::CreateForWindowManager( | 54 mus::WindowTreeConnection::CreateForWindowManager( |
55 controller, std::move(client_request), | 55 controller, std::move(client_request), |
56 mus::WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED, | 56 mus::WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED, |
57 controller->window_manager_.get()); | 57 controller->window_manager_.get()); |
58 return controller; | 58 return controller; |
59 } | 59 } |
60 | 60 |
61 void RootWindowController::Destroy() { | 61 void RootWindowController::Destroy() { |
62 // See class description for details on lifetime. | 62 // See class description for details on lifetime. |
63 if (root_) { | 63 if (root_) { |
64 delete root_->connection(); | 64 delete root_->connection(); |
65 } else { | 65 } else { |
66 // This case only happens if we're destroyed before OnEmbed(). | 66 // This case only happens if we're destroyed before OnEmbed(). |
67 delete this; | 67 delete this; |
68 } | 68 } |
69 } | 69 } |
70 | 70 |
71 mojo::shell::mojom::Shell* RootWindowController::GetShell() { | 71 mojo::Shell* RootWindowController::GetShell() { |
72 return app_->app()->shell(); | 72 return app_->shell(); |
73 } | 73 } |
74 | 74 |
75 mus::Window* RootWindowController::GetWindowForContainer( | 75 mus::Window* RootWindowController::GetWindowForContainer( |
76 mojom::Container container) { | 76 mojom::Container container) { |
77 const mus::Id window_id = root_->connection()->GetConnectionId() << 16 | | 77 const mus::Id window_id = root_->connection()->GetConnectionId() << 16 | |
78 static_cast<uint16_t>(container); | 78 static_cast<uint16_t>(container); |
79 return root_->GetChildById(window_id); | 79 return root_->GetChildById(window_id); |
80 } | 80 } |
81 | 81 |
82 mus::Window* RootWindowController::GetWindowById(mus::Id id) { | 82 mus::Window* RootWindowController::GetWindowById(mus::Id id) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 134 |
135 mus::Window* window = GetWindowForContainer(mojom::Container::USER_WINDOWS); | 135 mus::Window* window = GetWindowForContainer(mojom::Container::USER_WINDOWS); |
136 window_layout_.reset( | 136 window_layout_.reset( |
137 new WindowLayout(GetWindowForContainer(mojom::Container::USER_WINDOWS))); | 137 new WindowLayout(GetWindowForContainer(mojom::Container::USER_WINDOWS))); |
138 window_manager_client()->AddActivationParent(window); | 138 window_manager_client()->AddActivationParent(window); |
139 window_tree_host_->SetTitle("Mash"); | 139 window_tree_host_->SetTitle("Mash"); |
140 | 140 |
141 AddAccelerators(); | 141 AddAccelerators(); |
142 | 142 |
143 mash::shell::mojom::ShellPtr shell; | 143 mash::shell::mojom::ShellPtr shell; |
144 app_->app()->ConnectToService("mojo:mash_shell", &shell); | 144 app_->shell()->ConnectToService("mojo:mash_shell", &shell); |
145 window_manager_->Initialize(this, std::move(shell)); | 145 window_manager_->Initialize(this, std::move(shell)); |
146 | 146 |
147 shadow_controller_.reset(new ShadowController(root->connection())); | 147 shadow_controller_.reset(new ShadowController(root->connection())); |
148 | 148 |
149 app_->OnRootWindowControllerDoneInit(this); | 149 app_->OnRootWindowControllerDoneInit(this); |
150 } | 150 } |
151 | 151 |
152 void RootWindowController::OnConnectionLost( | 152 void RootWindowController::OnConnectionLost( |
153 mus::WindowTreeConnection* connection) { | 153 mus::WindowTreeConnection* connection) { |
154 shadow_controller_.reset(); | 154 shadow_controller_.reset(); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 mojom::Container::LOGIN_WINDOWS); | 204 mojom::Container::LOGIN_WINDOWS); |
205 CreateContainer(mojom::Container::SYSTEM_MODAL_WINDOWS, | 205 CreateContainer(mojom::Container::SYSTEM_MODAL_WINDOWS, |
206 mojom::Container::ROOT); | 206 mojom::Container::ROOT); |
207 CreateContainer(mojom::Container::KEYBOARD, mojom::Container::ROOT); | 207 CreateContainer(mojom::Container::KEYBOARD, mojom::Container::ROOT); |
208 CreateContainer(mojom::Container::MENUS, mojom::Container::ROOT); | 208 CreateContainer(mojom::Container::MENUS, mojom::Container::ROOT); |
209 CreateContainer(mojom::Container::TOOLTIPS, mojom::Container::ROOT); | 209 CreateContainer(mojom::Container::TOOLTIPS, mojom::Container::ROOT); |
210 } | 210 } |
211 | 211 |
212 } // namespace wm | 212 } // namespace wm |
213 } // namespace mash | 213 } // namespace mash |
OLD | NEW |