| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_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/interfaces/window_manager_factory.mojom.h" | 13 #include "components/mus/public/interfaces/window_manager_factory.mojom.h" |
| 14 #include "mash/wm/accelerator_registrar_impl.h" | 14 #include "mash/wm/accelerator_registrar_impl.h" |
| 15 #include "mash/wm/root_window_controller.h" | 15 #include "mash/wm/root_window_controller.h" |
| 16 #include "mash/wm/root_windows_observer.h" | 16 #include "mash/wm/root_windows_observer.h" |
| 17 #include "mash/wm/shelf_layout.h" |
| 17 #include "mash/wm/user_window_controller_impl.h" | 18 #include "mash/wm/user_window_controller_impl.h" |
| 18 #include "mojo/converters/input_events/input_events_type_converters.h" | 19 #include "mojo/converters/input_events/input_events_type_converters.h" |
| 19 #include "services/shell/public/cpp/connection.h" | 20 #include "services/shell/public/cpp/connection.h" |
| 20 #include "services/shell/public/cpp/connector.h" | 21 #include "services/shell/public/cpp/connector.h" |
| 21 #include "services/tracing/public/cpp/tracing_impl.h" | 22 #include "services/tracing/public/cpp/tracing_impl.h" |
| 22 #include "ui/events/event.h" | 23 #include "ui/events/event.h" |
| 23 #include "ui/mojo/init/ui_init.h" | 24 #include "ui/mojo/init/ui_init.h" |
| 24 #include "ui/views/mus/aura_init.h" | 25 #include "ui/views/mus/aura_init.h" |
| 25 #include "ui/views/mus/display_converter.h" | 26 #include "ui/views/mus/display_converter.h" |
| 26 | 27 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 ui_init_.reset(new ui::mojo::UIInit( | 61 ui_init_.reset(new ui::mojo::UIInit( |
| 61 views::GetDisplaysFromWindow(root_controller->root()))); | 62 views::GetDisplaysFromWindow(root_controller->root()))); |
| 62 aura_init_.reset(new views::AuraInit(connector_, "mash_wm_resources.pak")); | 63 aura_init_.reset(new views::AuraInit(connector_, "mash_wm_resources.pak")); |
| 63 } | 64 } |
| 64 | 65 |
| 65 void WindowManagerApplication::OnRootWindowControllerDoneInit( | 66 void WindowManagerApplication::OnRootWindowControllerDoneInit( |
| 66 RootWindowController* root_controller) { | 67 RootWindowController* root_controller) { |
| 67 // TODO(msw): figure out if this should be per display, or global. | 68 // TODO(msw): figure out if this should be per display, or global. |
| 68 user_window_controller_->Initialize(root_controller); | 69 user_window_controller_->Initialize(root_controller); |
| 69 for (auto& request : user_window_controller_requests_) | 70 for (auto& request : user_window_controller_requests_) |
| 70 user_window_controller_binding_.AddBinding(user_window_controller_.get(), | 71 user_window_controller_bindings_.AddBinding(user_window_controller_.get(), |
| 71 std::move(*request)); | 72 std::move(*request)); |
| 72 user_window_controller_requests_.clear(); | 73 user_window_controller_requests_.clear(); |
| 73 | 74 |
| 75 // TODO(msw): figure out if this should be per display, or global. |
| 76 if (root_controller == (*root_controllers_.begin())) { |
| 77 ShelfLayout* shelf_layout = root_controller->GetShelfLayoutManager(); |
| 78 for (auto& request : shelf_layout_requests_) |
| 79 shelf_layout_bindings_.AddBinding(shelf_layout, std::move(*request)); |
| 80 shelf_layout_requests_.clear(); |
| 81 } |
| 82 |
| 74 FOR_EACH_OBSERVER(RootWindowsObserver, root_windows_observers_, | 83 FOR_EACH_OBSERVER(RootWindowsObserver, root_windows_observers_, |
| 75 OnRootWindowControllerAdded(root_controller)); | 84 OnRootWindowControllerAdded(root_controller)); |
| 76 } | 85 } |
| 77 | 86 |
| 78 void WindowManagerApplication::OnRootWindowDestroyed( | 87 void WindowManagerApplication::OnRootWindowDestroyed( |
| 79 RootWindowController* root_controller) { | 88 RootWindowController* root_controller) { |
| 80 root_controllers_.erase(root_controller); | 89 root_controllers_.erase(root_controller); |
| 81 user_window_controller_.reset(nullptr); | 90 user_window_controller_.reset(nullptr); |
| 82 } | 91 } |
| 83 | 92 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 114 | 123 |
| 115 mus::mojom::WindowManagerFactoryServicePtr wm_factory_service; | 124 mus::mojom::WindowManagerFactoryServicePtr wm_factory_service; |
| 116 connector_->ConnectToInterface("mojo:mus", &wm_factory_service); | 125 connector_->ConnectToInterface("mojo:mus", &wm_factory_service); |
| 117 wm_factory_service->SetWindowManagerFactory( | 126 wm_factory_service->SetWindowManagerFactory( |
| 118 window_manager_factory_binding_.CreateInterfacePtrAndBind()); | 127 window_manager_factory_binding_.CreateInterfacePtrAndBind()); |
| 119 | 128 |
| 120 user_window_controller_.reset(new UserWindowControllerImpl()); | 129 user_window_controller_.reset(new UserWindowControllerImpl()); |
| 121 } | 130 } |
| 122 | 131 |
| 123 bool WindowManagerApplication::AcceptConnection(shell::Connection* connection) { | 132 bool WindowManagerApplication::AcceptConnection(shell::Connection* connection) { |
| 124 connection->AddInterface<mash::wm::mojom::UserWindowController>(this); | 133 connection->AddInterface<mojom::ShelfLayout>(this); |
| 134 connection->AddInterface<mojom::UserWindowController>(this); |
| 125 connection->AddInterface<mus::mojom::AcceleratorRegistrar>(this); | 135 connection->AddInterface<mus::mojom::AcceleratorRegistrar>(this); |
| 126 if (connection->GetRemoteIdentity().name() == "mojo:mash_session") | 136 if (connection->GetRemoteIdentity().name() == "mojo:mash_session") |
| 127 connection->GetInterface(&session_); | 137 connection->GetInterface(&session_); |
| 128 return true; | 138 return true; |
| 129 } | 139 } |
| 130 | 140 |
| 131 void WindowManagerApplication::Create( | 141 void WindowManagerApplication::Create( |
| 132 shell::Connection* connection, | 142 shell::Connection* connection, |
| 133 mojo::InterfaceRequest<mash::wm::mojom::UserWindowController> request) { | 143 mojo::InterfaceRequest<mojom::ShelfLayout> request) { |
| 144 // TODO(msw): Handle multiple shelves (one per display). |
| 134 if (!root_controllers_.empty() && (*root_controllers_.begin())->root()) { | 145 if (!root_controllers_.empty() && (*root_controllers_.begin())->root()) { |
| 135 user_window_controller_binding_.AddBinding(user_window_controller_.get(), | 146 ShelfLayout* shelf_layout = |
| 136 std::move(request)); | 147 (*root_controllers_.begin())->GetShelfLayoutManager(); |
| 148 shelf_layout_bindings_.AddBinding(shelf_layout, std::move(request)); |
| 149 } else { |
| 150 shelf_layout_requests_.push_back(base::WrapUnique( |
| 151 new mojo::InterfaceRequest<mojom::ShelfLayout>(std::move(request)))); |
| 152 } |
| 153 } |
| 154 |
| 155 void WindowManagerApplication::Create( |
| 156 shell::Connection* connection, |
| 157 mojo::InterfaceRequest<mojom::UserWindowController> request) { |
| 158 if (!root_controllers_.empty() && (*root_controllers_.begin())->root()) { |
| 159 user_window_controller_bindings_.AddBinding(user_window_controller_.get(), |
| 160 std::move(request)); |
| 137 } else { | 161 } else { |
| 138 user_window_controller_requests_.push_back(base::WrapUnique( | 162 user_window_controller_requests_.push_back(base::WrapUnique( |
| 139 new mojo::InterfaceRequest<mash::wm::mojom::UserWindowController>( | 163 new mojo::InterfaceRequest<mojom::UserWindowController>( |
| 140 std::move(request)))); | 164 std::move(request)))); |
| 141 } | 165 } |
| 142 } | 166 } |
| 143 | 167 |
| 144 void WindowManagerApplication::Create( | 168 void WindowManagerApplication::Create( |
| 145 shell::Connection* connection, | 169 shell::Connection* connection, |
| 146 mojo::InterfaceRequest<mus::mojom::AcceleratorRegistrar> request) { | 170 mojo::InterfaceRequest<mus::mojom::AcceleratorRegistrar> request) { |
| 147 static int accelerator_registrar_count = 0; | 171 static int accelerator_registrar_count = 0; |
| 148 if (accelerator_registrar_count == std::numeric_limits<int>::max()) { | 172 if (accelerator_registrar_count == std::numeric_limits<int>::max()) { |
| 149 // Restart from zero if we have reached the limit. It is technically | 173 // Restart from zero if we have reached the limit. It is technically |
| (...skipping 11 matching lines...) Expand all Loading... |
| 161 | 185 |
| 162 void WindowManagerApplication::CreateWindowManager( | 186 void WindowManagerApplication::CreateWindowManager( |
| 163 mus::mojom::DisplayPtr display, | 187 mus::mojom::DisplayPtr display, |
| 164 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> client_request) { | 188 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> client_request) { |
| 165 root_controllers_.insert(RootWindowController::CreateFromDisplay( | 189 root_controllers_.insert(RootWindowController::CreateFromDisplay( |
| 166 this, std::move(display), std::move(client_request))); | 190 this, std::move(display), std::move(client_request))); |
| 167 } | 191 } |
| 168 | 192 |
| 169 } // namespace wm | 193 } // namespace wm |
| 170 } // namespace mash | 194 } // namespace mash |
| OLD | NEW |