| 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/background_layout.h" | 7 #include "components/mus/example/wm/background_layout.h" |
| 8 #include "components/mus/example/wm/shelf_layout.h" | 8 #include "components/mus/example/wm/shelf_layout.h" |
| 9 #include "components/mus/example/wm/window_layout.h" | 9 #include "components/mus/example/wm/window_layout.h" |
| 10 #include "components/mus/example/wm/window_manager_impl.h" | 10 #include "components/mus/example/wm/window_manager_impl.h" |
| 11 #include "components/mus/public/cpp/util.h" | 11 #include "components/mus/public/cpp/util.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 "mojo/application/public/cpp/application_connection.h" | 15 #include "mojo/application/public/cpp/application_connection.h" |
| 16 #include "ui/mojo/init/ui_init.h" |
| 17 #include "ui/views/mus/aura_init.h" |
| 18 #include "ui/views/mus/display_converter.h" |
| 16 | 19 |
| 17 WindowManagerApplication::WindowManagerApplication() | 20 WindowManagerApplication::WindowManagerApplication() |
| 18 : root_(nullptr), window_count_(0) {} | 21 : root_(nullptr), window_count_(0), app_(nullptr) {} |
| 19 WindowManagerApplication::~WindowManagerApplication() {} | 22 WindowManagerApplication::~WindowManagerApplication() {} |
| 20 | 23 |
| 21 mus::Window* WindowManagerApplication::GetWindowForContainer( | 24 mus::Window* WindowManagerApplication::GetWindowForContainer( |
| 22 ash::mojom::Container container) { | 25 ash::mojom::Container container) { |
| 23 const mus::Id window_id = root_->connection()->GetConnectionId() << 16 | | 26 const mus::Id window_id = root_->connection()->GetConnectionId() << 16 | |
| 24 static_cast<uint16_t>(container); | 27 static_cast<uint16_t>(container); |
| 25 return root_->GetChildById(window_id); | 28 return root_->GetChildById(window_id); |
| 26 } | 29 } |
| 27 | 30 |
| 28 mus::Window* WindowManagerApplication::GetWindowById(mus::Id id) { | 31 mus::Window* WindowManagerApplication::GetWindowById(mus::Id id) { |
| 29 return root_->GetChildById(id); | 32 return root_->GetChildById(id); |
| 30 } | 33 } |
| 31 | 34 |
| 32 void WindowManagerApplication::Initialize(mojo::ApplicationImpl* app) { | 35 void WindowManagerApplication::Initialize(mojo::ApplicationImpl* app) { |
| 36 app_ = app; |
| 33 mus::mojom::WindowManagerPtr window_manager; | 37 mus::mojom::WindowManagerPtr window_manager; |
| 34 requests_.push_back(new mojo::InterfaceRequest<mus::mojom::WindowManager>( | 38 requests_.push_back(new mojo::InterfaceRequest<mus::mojom::WindowManager>( |
| 35 mojo::GetProxy(&window_manager))); | 39 mojo::GetProxy(&window_manager))); |
| 36 mus::CreateSingleWindowTreeHost(app, this, &host_, window_manager.Pass()); | 40 mus::CreateSingleWindowTreeHost(app, this, &host_, window_manager.Pass()); |
| 37 } | 41 } |
| 38 | 42 |
| 39 bool WindowManagerApplication::ConfigureIncomingConnection( | 43 bool WindowManagerApplication::ConfigureIncomingConnection( |
| 40 mojo::ApplicationConnection* connection) { | 44 mojo::ApplicationConnection* connection) { |
| 41 connection->AddService(this); | 45 connection->AddService(this); |
| 42 return true; | 46 return true; |
| 43 } | 47 } |
| 44 | 48 |
| 45 void WindowManagerApplication::OnEmbed(mus::Window* root) { | 49 void WindowManagerApplication::OnEmbed(mus::Window* root) { |
| 46 root_ = root; | 50 root_ = root; |
| 47 root_->AddObserver(this); | 51 root_->AddObserver(this); |
| 48 CreateContainers(); | 52 CreateContainers(); |
| 49 background_layout_.reset(new BackgroundLayout( | 53 background_layout_.reset(new BackgroundLayout( |
| 50 GetWindowForContainer(ash::mojom::CONTAINER_USER_BACKGROUND))); | 54 GetWindowForContainer(ash::mojom::CONTAINER_USER_BACKGROUND))); |
| 51 shelf_layout_.reset(new ShelfLayout( | 55 shelf_layout_.reset(new ShelfLayout( |
| 52 GetWindowForContainer(ash::mojom::CONTAINER_USER_SHELF))); | 56 GetWindowForContainer(ash::mojom::CONTAINER_USER_SHELF))); |
| 53 window_layout_.reset(new WindowLayout( | 57 window_layout_.reset(new WindowLayout( |
| 54 GetWindowForContainer(ash::mojom::CONTAINER_USER_WINDOWS))); | 58 GetWindowForContainer(ash::mojom::CONTAINER_USER_WINDOWS))); |
| 55 | 59 |
| 56 window_manager_.reset(new WindowManagerImpl(this)); | 60 window_manager_.reset(new WindowManagerImpl(this)); |
| 61 |
| 62 ui_init_.reset(new ui::mojo::UIInit(views::GetDisplaysFromWindow(root))); |
| 63 aura_init_.reset(new views::AuraInit(app_, "views_mus_resources.pak")); |
| 64 |
| 57 for (auto request : requests_) | 65 for (auto request : requests_) |
| 58 window_manager_binding_.AddBinding(window_manager_.get(), request->Pass()); | 66 window_manager_binding_.AddBinding(window_manager_.get(), request->Pass()); |
| 59 requests_.clear(); | 67 requests_.clear(); |
| 60 } | 68 } |
| 61 | 69 |
| 62 void WindowManagerApplication::OnConnectionLost( | 70 void WindowManagerApplication::OnConnectionLost( |
| 63 mus::WindowTreeConnection* connection) { | 71 mus::WindowTreeConnection* connection) { |
| 64 // TODO(sky): shutdown. | 72 // TODO(sky): shutdown. |
| 65 NOTIMPLEMENTED(); | 73 NOTIMPLEMENTED(); |
| 66 } | 74 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 91 container < static_cast<uint16_t>(ash::mojom::CONTAINER_COUNT); | 99 container < static_cast<uint16_t>(ash::mojom::CONTAINER_COUNT); |
| 92 ++container) { | 100 ++container) { |
| 93 mus::Window* window = root_->connection()->NewWindow(); | 101 mus::Window* window = root_->connection()->NewWindow(); |
| 94 DCHECK_EQ(mus::LoWord(window->id()), container) | 102 DCHECK_EQ(mus::LoWord(window->id()), container) |
| 95 << "Containers must be created before other windows!"; | 103 << "Containers must be created before other windows!"; |
| 96 window->SetBounds(root_->bounds()); | 104 window->SetBounds(root_->bounds()); |
| 97 window->SetVisible(true); | 105 window->SetVisible(true); |
| 98 root_->AddChild(window); | 106 root_->AddChild(window); |
| 99 } | 107 } |
| 100 } | 108 } |
| OLD | NEW |