| 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 "components/mus/example/wm/window_manager_application.h" | 5 #include "components/mus/example/wm/window_manager_application.h" |
| 6 | 6 |
| 7 #include "components/mus/example/wm/container.h" | 7 #include "components/mus/example/wm/container.h" |
| 8 #include "components/mus/example/wm/window_layout.h" | 8 #include "components/mus/example/wm/window_layout.h" |
| 9 #include "components/mus/example/wm/window_manager_impl.h" | 9 #include "components/mus/example/wm/window_manager_impl.h" |
| 10 #include "components/mus/public/cpp/util.h" | 10 #include "components/mus/public/cpp/util.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 const mus::Id window_id = root_->connection()->GetConnectionId() << 16 | | 22 const mus::Id window_id = root_->connection()->GetConnectionId() << 16 | |
| 23 static_cast<uint16_t>(container); | 23 static_cast<uint16_t>(container); |
| 24 return root_->GetChildById(window_id); | 24 return root_->GetChildById(window_id); |
| 25 } | 25 } |
| 26 | 26 |
| 27 mus::Window* WindowManagerApplication::GetWindowById(mus::Id id) { | 27 mus::Window* WindowManagerApplication::GetWindowById(mus::Id id) { |
| 28 return root_->GetChildById(id); | 28 return root_->GetChildById(id); |
| 29 } | 29 } |
| 30 | 30 |
| 31 void WindowManagerApplication::Initialize(mojo::ApplicationImpl* app) { | 31 void WindowManagerApplication::Initialize(mojo::ApplicationImpl* app) { |
| 32 mus::CreateSingleWindowTreeHost(app, this, &host_); | 32 mus::mojom::WindowManagerPtr window_manager; |
| 33 requests_.push_back(new mojo::InterfaceRequest<mus::mojom::WindowManager>( |
| 34 mojo::GetProxy(&window_manager))); |
| 35 mus::CreateSingleWindowTreeHost(app, this, &host_, window_manager.Pass()); |
| 33 } | 36 } |
| 34 | 37 |
| 35 bool WindowManagerApplication::ConfigureIncomingConnection( | 38 bool WindowManagerApplication::ConfigureIncomingConnection( |
| 36 mojo::ApplicationConnection* connection) { | 39 mojo::ApplicationConnection* connection) { |
| 37 connection->AddService(this); | 40 connection->AddService(this); |
| 38 return true; | 41 return true; |
| 39 } | 42 } |
| 40 | 43 |
| 41 void WindowManagerApplication::OnEmbed(mus::Window* root) { | 44 void WindowManagerApplication::OnEmbed(mus::Window* root) { |
| 42 root_ = root; | 45 root_ = root; |
| 43 CreateContainers(); | 46 CreateContainers(); |
| 44 layout_.reset( | 47 layout_.reset( |
| 45 new WindowLayout(GetWindowForContainer(Container::USER_WINDOWS))); | 48 new WindowLayout(GetWindowForContainer(Container::USER_WINDOWS))); |
| 46 | 49 |
| 47 host_->EnableWindowDraggingForChildren( | 50 host_->EnableWindowDraggingForChildren( |
| 48 GetWindowForContainer(Container::USER_WINDOWS)->id()); | 51 GetWindowForContainer(Container::USER_WINDOWS)->id()); |
| 49 | 52 |
| 53 window_manager_.reset(new WindowManagerImpl(this)); |
| 50 for (auto request : requests_) | 54 for (auto request : requests_) |
| 51 new WindowManagerImpl(this, request->Pass()); | 55 window_manager_binding_.AddBinding(window_manager_.get(), request->Pass()); |
| 56 requests_.clear(); |
| 52 } | 57 } |
| 53 | 58 |
| 54 void WindowManagerApplication::OnConnectionLost( | 59 void WindowManagerApplication::OnConnectionLost( |
| 55 mus::WindowTreeConnection* connection) { | 60 mus::WindowTreeConnection* connection) { |
| 56 // TODO(sky): shutdown. | 61 // TODO(sky): shutdown. |
| 57 NOTIMPLEMENTED(); | 62 NOTIMPLEMENTED(); |
| 58 } | 63 } |
| 59 | 64 |
| 60 void WindowManagerApplication::Create( | 65 void WindowManagerApplication::Create( |
| 61 mojo::ApplicationConnection* connection, | 66 mojo::ApplicationConnection* connection, |
| 62 mojo::InterfaceRequest<mus::mojom::WindowManager> request) { | 67 mojo::InterfaceRequest<mus::mojom::WindowManager> request) { |
| 63 if (root_) { | 68 if (root_) { |
| 64 new WindowManagerImpl(this, request.Pass()); | 69 window_manager_binding_.AddBinding(window_manager_.get(), request.Pass()); |
| 65 } else { | 70 } else { |
| 66 requests_.push_back( | 71 requests_.push_back( |
| 67 new mojo::InterfaceRequest<mus::mojom::WindowManager>(request.Pass())); | 72 new mojo::InterfaceRequest<mus::mojom::WindowManager>(request.Pass())); |
| 68 } | 73 } |
| 69 } | 74 } |
| 70 | 75 |
| 71 void WindowManagerApplication::CreateContainers() { | 76 void WindowManagerApplication::CreateContainers() { |
| 72 for (uint16_t container = | 77 for (uint16_t container = |
| 73 static_cast<uint16_t>(Container::ALL_USER_BACKGROUND); | 78 static_cast<uint16_t>(Container::ALL_USER_BACKGROUND); |
| 74 container < static_cast<uint16_t>(Container::COUNT); ++container) { | 79 container < static_cast<uint16_t>(Container::COUNT); ++container) { |
| 75 mus::Window* window = root_->connection()->NewWindow(); | 80 mus::Window* window = root_->connection()->NewWindow(); |
| 76 DCHECK_EQ(mus::LoWord(window->id()), container) | 81 DCHECK_EQ(mus::LoWord(window->id()), container) |
| 77 << "Containers must be created before other windows!"; | 82 << "Containers must be created before other windows!"; |
| 78 window->SetBounds(root_->bounds()); | 83 window->SetBounds(root_->bounds()); |
| 79 window->SetVisible(true); | 84 window->SetVisible(true); |
| 80 root_->AddChild(window); | 85 root_->AddChild(window); |
| 81 } | 86 } |
| 82 } | 87 } |
| 83 | 88 |
| OLD | NEW |