| 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 "mash/wm/window_manager_application.h" | 5 #include "mash/wm/window_manager_application.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "components/mus/common/util.h" | 11 #include "components/mus/common/util.h" |
| 12 #include "components/mus/public/cpp/event_matcher.h" | 12 #include "components/mus/public/cpp/event_matcher.h" |
| 13 #include "components/mus/public/cpp/window.h" | 13 #include "components/mus/public/cpp/window.h" |
| 14 #include "components/mus/public/cpp/window_tree_connection.h" | 14 #include "components/mus/public/cpp/window_tree_connection.h" |
| 15 #include "components/mus/public/cpp/window_tree_host_factory.h" | 15 #include "components/mus/public/cpp/window_tree_host_factory.h" |
| 16 #include "mash/wm/accelerator_registrar_impl.h" | 16 #include "mash/wm/accelerator_registrar_impl.h" |
| 17 #include "mash/wm/background_layout.h" | 17 #include "mash/wm/background_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/user_window_controller_impl.h" |
| 20 #include "mash/wm/window_layout.h" | 21 #include "mash/wm/window_layout.h" |
| 21 #include "mash/wm/window_manager_impl.h" | 22 #include "mash/wm/window_manager_impl.h" |
| 22 #include "mojo/services/tracing/public/cpp/tracing_impl.h" | 23 #include "mojo/services/tracing/public/cpp/tracing_impl.h" |
| 23 #include "mojo/shell/public/cpp/application_connection.h" | 24 #include "mojo/shell/public/cpp/application_connection.h" |
| 24 #include "ui/mojo/init/ui_init.h" | 25 #include "ui/mojo/init/ui_init.h" |
| 25 #include "ui/views/mus/aura_init.h" | 26 #include "ui/views/mus/aura_init.h" |
| 26 #include "ui/views/mus/display_converter.h" | 27 #include "ui/views/mus/display_converter.h" |
| 27 | 28 |
| 28 namespace mash { | 29 namespace mash { |
| 29 namespace wm { | 30 namespace wm { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 } | 75 } |
| 75 | 76 |
| 76 void WindowManagerApplication::Initialize(mojo::ApplicationImpl* app) { | 77 void WindowManagerApplication::Initialize(mojo::ApplicationImpl* app) { |
| 77 app_ = app; | 78 app_ = app; |
| 78 tracing_.Initialize(app); | 79 tracing_.Initialize(app); |
| 79 window_manager_.reset(new WindowManagerImpl()); | 80 window_manager_.reset(new WindowManagerImpl()); |
| 80 // Don't bind to the WindowManager immediately. Wait for OnEmbed() first. | 81 // Don't bind to the WindowManager immediately. Wait for OnEmbed() first. |
| 81 mus::mojom::WindowManagerPtr window_manager; | 82 mus::mojom::WindowManagerPtr window_manager; |
| 82 requests_.push_back(new mojo::InterfaceRequest<mus::mojom::WindowManager>( | 83 requests_.push_back(new mojo::InterfaceRequest<mus::mojom::WindowManager>( |
| 83 mojo::GetProxy(&window_manager))); | 84 mojo::GetProxy(&window_manager))); |
| 85 user_window_controller_.reset(new UserWindowControllerImpl()); |
| 84 mus::mojom::WindowTreeHostClientPtr host_client; | 86 mus::mojom::WindowTreeHostClientPtr host_client; |
| 85 host_client_binding_.Bind(GetProxy(&host_client)); | 87 host_client_binding_.Bind(GetProxy(&host_client)); |
| 86 mus::CreateSingleWindowTreeHost(app, std::move(host_client), this, | 88 mus::CreateSingleWindowTreeHost(app, std::move(host_client), this, |
| 87 &window_tree_host_, std::move(window_manager), | 89 &window_tree_host_, std::move(window_manager), |
| 88 window_manager_.get()); | 90 window_manager_.get()); |
| 89 } | 91 } |
| 90 | 92 |
| 91 bool WindowManagerApplication::ConfigureIncomingConnection( | 93 bool WindowManagerApplication::ConfigureIncomingConnection( |
| 92 mojo::ApplicationConnection* connection) { | 94 mojo::ApplicationConnection* connection) { |
| 95 connection->AddService<mash::wm::mojom::UserWindowController>(this); |
| 93 connection->AddService<mus::mojom::AcceleratorRegistrar>(this); | 96 connection->AddService<mus::mojom::AcceleratorRegistrar>(this); |
| 94 connection->AddService<mus::mojom::WindowManager>(this); | 97 connection->AddService<mus::mojom::WindowManager>(this); |
| 95 return true; | 98 return true; |
| 96 } | 99 } |
| 97 | 100 |
| 98 void WindowManagerApplication::OnAccelerator(uint32_t id, | 101 void WindowManagerApplication::OnAccelerator(uint32_t id, |
| 99 mus::mojom::EventPtr event) { | 102 mus::mojom::EventPtr event) { |
| 100 switch (id) { | 103 switch (id) { |
| 101 case kWindowSwitchCmd: | 104 case kWindowSwitchCmd: |
| 102 window_tree_host_->ActivateNextWindow(); | 105 window_tree_host_->ActivateNextWindow(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 130 | 133 |
| 131 ui_init_.reset(new ui::mojo::UIInit(views::GetDisplaysFromWindow(root))); | 134 ui_init_.reset(new ui::mojo::UIInit(views::GetDisplaysFromWindow(root))); |
| 132 aura_init_.reset(new views::AuraInit(app_, "mash_wm_resources.pak")); | 135 aura_init_.reset(new views::AuraInit(app_, "mash_wm_resources.pak")); |
| 133 window_manager_->Initialize(this); | 136 window_manager_->Initialize(this); |
| 134 | 137 |
| 135 for (auto request : requests_) | 138 for (auto request : requests_) |
| 136 window_manager_binding_.AddBinding(window_manager_.get(), | 139 window_manager_binding_.AddBinding(window_manager_.get(), |
| 137 std::move(*request)); | 140 std::move(*request)); |
| 138 requests_.clear(); | 141 requests_.clear(); |
| 139 | 142 |
| 143 user_window_controller_->Initialize(this); |
| 144 for (auto request : user_window_controller_requests_) |
| 145 user_window_controller_binding_.AddBinding(user_window_controller_.get(), |
| 146 std::move(*request)); |
| 147 user_window_controller_requests_.clear(); |
| 148 |
| 140 shadow_controller_.reset(new ShadowController(root->connection())); | 149 shadow_controller_.reset(new ShadowController(root->connection())); |
| 141 } | 150 } |
| 142 | 151 |
| 143 void WindowManagerApplication::OnConnectionLost( | 152 void WindowManagerApplication::OnConnectionLost( |
| 144 mus::WindowTreeConnection* connection) { | 153 mus::WindowTreeConnection* connection) { |
| 145 // TODO(sky): shutdown. | 154 // TODO(sky): shutdown. |
| 146 NOTIMPLEMENTED(); | 155 NOTIMPLEMENTED(); |
| 147 shadow_controller_.reset(); | 156 shadow_controller_.reset(); |
| 148 } | 157 } |
| 149 | 158 |
| 150 void WindowManagerApplication::Create( | 159 void WindowManagerApplication::Create( |
| 151 mojo::ApplicationConnection* connection, | 160 mojo::ApplicationConnection* connection, |
| 161 mojo::InterfaceRequest<mash::wm::mojom::UserWindowController> request) { |
| 162 if (root_) { |
| 163 user_window_controller_binding_.AddBinding(user_window_controller_.get(), |
| 164 std::move(request)); |
| 165 } else { |
| 166 user_window_controller_requests_.push_back( |
| 167 new mojo::InterfaceRequest<mash::wm::mojom::UserWindowController>( |
| 168 std::move(request))); |
| 169 } |
| 170 } |
| 171 |
| 172 void WindowManagerApplication::Create( |
| 173 mojo::ApplicationConnection* connection, |
| 152 mojo::InterfaceRequest<mus::mojom::AcceleratorRegistrar> request) { | 174 mojo::InterfaceRequest<mus::mojom::AcceleratorRegistrar> request) { |
| 153 static int accelerator_registrar_count = 0; | 175 static int accelerator_registrar_count = 0; |
| 154 if (accelerator_registrar_count == std::numeric_limits<int>::max()) { | 176 if (accelerator_registrar_count == std::numeric_limits<int>::max()) { |
| 155 // Restart from zero if we have reached the limit. It is technically | 177 // Restart from zero if we have reached the limit. It is technically |
| 156 // possible to end up with multiple active registrars with the same | 178 // possible to end up with multiple active registrars with the same |
| 157 // namespace, but it is highly unlikely. In the event that multiple | 179 // namespace, but it is highly unlikely. In the event that multiple |
| 158 // registrars have the same namespace, this new registrar will be unable to | 180 // registrars have the same namespace, this new registrar will be unable to |
| 159 // install accelerators. | 181 // install accelerators. |
| 160 accelerator_registrar_count = 0; | 182 accelerator_registrar_count = 0; |
| 161 } | 183 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 DCHECK_EQ(mus::LoWord(window->id()), container) | 217 DCHECK_EQ(mus::LoWord(window->id()), container) |
| 196 << "Containers must be created before other windows!"; | 218 << "Containers must be created before other windows!"; |
| 197 window->SetBounds(root_->bounds()); | 219 window->SetBounds(root_->bounds()); |
| 198 window->SetVisible(true); | 220 window->SetVisible(true); |
| 199 root_->AddChild(window); | 221 root_->AddChild(window); |
| 200 } | 222 } |
| 201 } | 223 } |
| 202 | 224 |
| 203 } // namespace wm | 225 } // namespace wm |
| 204 } // namespace mash | 226 } // namespace mash |
| OLD | NEW |