| 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" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 void WindowManagerApplication::OnAcceleratorRegistrarDestroyed( | 73 void WindowManagerApplication::OnAcceleratorRegistrarDestroyed( |
| 74 AcceleratorRegistrarImpl* registrar) { | 74 AcceleratorRegistrarImpl* registrar) { |
| 75 accelerator_registrars_.erase(registrar); | 75 accelerator_registrars_.erase(registrar); |
| 76 } | 76 } |
| 77 | 77 |
| 78 void WindowManagerApplication::Initialize(mojo::ApplicationImpl* app) { | 78 void WindowManagerApplication::Initialize(mojo::ApplicationImpl* app) { |
| 79 app_ = app; | 79 app_ = app; |
| 80 tracing_.Initialize(app); | 80 tracing_.Initialize(app); |
| 81 window_manager_.reset(new WindowManagerImpl()); | 81 window_manager_.reset(new WindowManagerImpl()); |
| 82 // Don't bind to the WindowManager immediately. Wait for OnEmbed() first. | 82 // Don't bind to the WindowManager immediately. Wait for OnEmbed() first. |
| 83 mus::mojom::WindowManagerPtr window_manager; | 83 mus::mojom::WindowManagerDeprecatedPtr window_manager; |
| 84 requests_.push_back( | 84 requests_.push_back(make_scoped_ptr( |
| 85 make_scoped_ptr(new mojo::InterfaceRequest<mus::mojom::WindowManager>( | 85 new mojo::InterfaceRequest<mus::mojom::WindowManagerDeprecated>( |
| 86 mojo::GetProxy(&window_manager)))); | 86 mojo::GetProxy(&window_manager)))); |
| 87 user_window_controller_.reset(new UserWindowControllerImpl()); | 87 user_window_controller_.reset(new UserWindowControllerImpl()); |
| 88 mus::CreateSingleWindowTreeHost( | 88 mus::CreateSingleWindowTreeHost( |
| 89 app, host_client_binding_.CreateInterfacePtrAndBind(), this, | 89 app, host_client_binding_.CreateInterfacePtrAndBind(), this, |
| 90 &window_tree_host_, std::move(window_manager), window_manager_.get()); | 90 &window_tree_host_, std::move(window_manager), window_manager_.get()); |
| 91 } | 91 } |
| 92 | 92 |
| 93 bool WindowManagerApplication::ConfigureIncomingConnection( | 93 bool WindowManagerApplication::ConfigureIncomingConnection( |
| 94 mojo::ApplicationConnection* connection) { | 94 mojo::ApplicationConnection* connection) { |
| 95 connection->AddService<mash::wm::mojom::UserWindowController>(this); | 95 connection->AddService<mash::wm::mojom::UserWindowController>(this); |
| 96 connection->AddService<mus::mojom::AcceleratorRegistrar>(this); | 96 connection->AddService<mus::mojom::AcceleratorRegistrar>(this); |
| 97 connection->AddService<mus::mojom::WindowManager>(this); | 97 connection->AddService<mus::mojom::WindowManagerDeprecated>(this); |
| 98 return true; | 98 return true; |
| 99 } | 99 } |
| 100 | 100 |
| 101 void WindowManagerApplication::OnAccelerator(uint32_t id, | 101 void WindowManagerApplication::OnAccelerator(uint32_t id, |
| 102 mus::mojom::EventPtr event) { | 102 mus::mojom::EventPtr event) { |
| 103 switch (id) { | 103 switch (id) { |
| 104 case kWindowSwitchCmd: | 104 case kWindowSwitchCmd: |
| 105 window_tree_host_->ActivateNextWindow(); | 105 window_tree_host_->ActivateNextWindow(); |
| 106 break; | 106 break; |
| 107 default: | 107 default: |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 } | 185 } |
| 186 accelerator_registrars_.insert(new AcceleratorRegistrarImpl( | 186 accelerator_registrars_.insert(new AcceleratorRegistrarImpl( |
| 187 window_tree_host_.get(), ++accelerator_registrar_count, | 187 window_tree_host_.get(), ++accelerator_registrar_count, |
| 188 std::move(request), | 188 std::move(request), |
| 189 base::Bind(&WindowManagerApplication::OnAcceleratorRegistrarDestroyed, | 189 base::Bind(&WindowManagerApplication::OnAcceleratorRegistrarDestroyed, |
| 190 base::Unretained(this)))); | 190 base::Unretained(this)))); |
| 191 } | 191 } |
| 192 | 192 |
| 193 void WindowManagerApplication::Create( | 193 void WindowManagerApplication::Create( |
| 194 mojo::ApplicationConnection* connection, | 194 mojo::ApplicationConnection* connection, |
| 195 mojo::InterfaceRequest<mus::mojom::WindowManager> request) { | 195 mojo::InterfaceRequest<mus::mojom::WindowManagerDeprecated> request) { |
| 196 if (root_) { | 196 if (root_) { |
| 197 window_manager_binding_.AddBinding(window_manager_.get(), | 197 window_manager_binding_.AddBinding(window_manager_.get(), |
| 198 std::move(request)); | 198 std::move(request)); |
| 199 } else { | 199 } else { |
| 200 requests_.push_back( | 200 requests_.push_back(make_scoped_ptr( |
| 201 make_scoped_ptr(new mojo::InterfaceRequest<mus::mojom::WindowManager>( | 201 new mojo::InterfaceRequest<mus::mojom::WindowManagerDeprecated>( |
| 202 std::move(request)))); | 202 std::move(request)))); |
| 203 } | 203 } |
| 204 } | 204 } |
| 205 | 205 |
| 206 void WindowManagerApplication::OnWindowDestroyed(mus::Window* window) { | 206 void WindowManagerApplication::OnWindowDestroyed(mus::Window* window) { |
| 207 DCHECK_EQ(window, root_); | 207 DCHECK_EQ(window, root_); |
| 208 root_->RemoveObserver(this); | 208 root_->RemoveObserver(this); |
| 209 // Delete the |window_manager_| here so that WindowManager doesn't have to | 209 // Delete the |window_manager_| here so that WindowManager doesn't have to |
| 210 // worry about the possibility of |root_| being null. | 210 // worry about the possibility of |root_| being null. |
| 211 window_manager_.reset(); | 211 window_manager_.reset(); |
| 212 root_ = nullptr; | 212 root_ = nullptr; |
| 213 } | 213 } |
| 214 | 214 |
| 215 void WindowManagerApplication::CreateContainers() { | 215 void WindowManagerApplication::CreateContainers() { |
| 216 for (uint16_t container = | 216 for (uint16_t container = |
| 217 static_cast<uint16_t>(mojom::Container::ALL_USER_BACKGROUND); | 217 static_cast<uint16_t>(mojom::Container::ALL_USER_BACKGROUND); |
| 218 container < static_cast<uint16_t>(mojom::Container::COUNT); | 218 container < static_cast<uint16_t>(mojom::Container::COUNT); |
| 219 ++container) { | 219 ++container) { |
| 220 mus::Window* window = root_->connection()->NewWindow(); | 220 mus::Window* window = root_->connection()->NewWindow(); |
| 221 DCHECK_EQ(mus::LoWord(window->id()), container) | 221 DCHECK_EQ(mus::LoWord(window->id()), container) |
| 222 << "Containers must be created before other windows!"; | 222 << "Containers must be created before other windows!"; |
| 223 window->SetBounds(root_->bounds()); | 223 window->SetBounds(root_->bounds()); |
| 224 window->SetVisible(true); | 224 window->SetVisible(true); |
| 225 root_->AddChild(window); | 225 root_->AddChild(window); |
| 226 } | 226 } |
| 227 } | 227 } |
| 228 | 228 |
| 229 } // namespace wm | 229 } // namespace wm |
| 230 } // namespace mash | 230 } // namespace mash |
| OLD | NEW |