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 "components/mus/public/cpp/event_matcher.h" | 10 #include "components/mus/public/cpp/event_matcher.h" |
11 #include "components/mus/public/cpp/window.h" | 11 #include "components/mus/public/cpp/window.h" |
12 #include "components/mus/public/interfaces/window_manager_factory.mojom.h" | 12 #include "components/mus/public/interfaces/window_manager_factory.mojom.h" |
13 #include "mash/wm/accelerator_registrar_impl.h" | 13 #include "mash/wm/accelerator_registrar_impl.h" |
14 #include "mash/wm/root_window_controller.h" | 14 #include "mash/wm/root_window_controller.h" |
15 #include "mash/wm/root_windows_observer.h" | 15 #include "mash/wm/root_windows_observer.h" |
16 #include "mash/wm/user_window_controller_impl.h" | 16 #include "mash/wm/user_window_controller_impl.h" |
17 #include "mojo/services/tracing/public/cpp/tracing_impl.h" | 17 #include "mojo/services/tracing/public/cpp/tracing_impl.h" |
18 #include "mojo/shell/public/cpp/application_connection.h" | 18 #include "mojo/shell/public/cpp/connection.h" |
19 #include "mojo/shell/public/cpp/shell.h" | 19 #include "mojo/shell/public/cpp/shell.h" |
20 #include "ui/mojo/init/ui_init.h" | 20 #include "ui/mojo/init/ui_init.h" |
21 #include "ui/views/mus/aura_init.h" | 21 #include "ui/views/mus/aura_init.h" |
22 #include "ui/views/mus/display_converter.h" | 22 #include "ui/views/mus/display_converter.h" |
23 | 23 |
24 namespace mash { | 24 namespace mash { |
25 namespace wm { | 25 namespace wm { |
26 | 26 |
27 WindowManagerApplication::WindowManagerApplication() | 27 WindowManagerApplication::WindowManagerApplication() |
28 : shell_(nullptr), window_manager_factory_binding_(this) {} | 28 : shell_(nullptr), window_manager_factory_binding_(this) {} |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 shell_->ConnectToService("mojo:mus", &wm_factory_service); | 113 shell_->ConnectToService("mojo:mus", &wm_factory_service); |
114 wm_factory_service->SetWindowManagerFactory( | 114 wm_factory_service->SetWindowManagerFactory( |
115 window_manager_factory_binding_.CreateInterfacePtrAndBind()); | 115 window_manager_factory_binding_.CreateInterfacePtrAndBind()); |
116 | 116 |
117 user_window_controller_.reset(new UserWindowControllerImpl()); | 117 user_window_controller_.reset(new UserWindowControllerImpl()); |
118 | 118 |
119 root_controllers_.insert( | 119 root_controllers_.insert( |
120 RootWindowController::CreateUsingWindowTreeHost(this)); | 120 RootWindowController::CreateUsingWindowTreeHost(this)); |
121 } | 121 } |
122 | 122 |
123 bool WindowManagerApplication::AcceptConnection( | 123 bool WindowManagerApplication::AcceptConnection(mojo::Connection* connection) { |
124 mojo::ApplicationConnection* connection) { | |
125 connection->AddService<mash::wm::mojom::UserWindowController>(this); | 124 connection->AddService<mash::wm::mojom::UserWindowController>(this); |
126 connection->AddService<mus::mojom::AcceleratorRegistrar>(this); | 125 connection->AddService<mus::mojom::AcceleratorRegistrar>(this); |
127 return true; | 126 return true; |
128 } | 127 } |
129 | 128 |
130 void WindowManagerApplication::Create( | 129 void WindowManagerApplication::Create( |
131 mojo::ApplicationConnection* connection, | 130 mojo::Connection* connection, |
132 mojo::InterfaceRequest<mash::wm::mojom::UserWindowController> request) { | 131 mojo::InterfaceRequest<mash::wm::mojom::UserWindowController> request) { |
133 if (!root_controllers_.empty() && (*root_controllers_.begin())->root()) { | 132 if (!root_controllers_.empty() && (*root_controllers_.begin())->root()) { |
134 user_window_controller_binding_.AddBinding(user_window_controller_.get(), | 133 user_window_controller_binding_.AddBinding(user_window_controller_.get(), |
135 std::move(request)); | 134 std::move(request)); |
136 } else { | 135 } else { |
137 user_window_controller_requests_.push_back(make_scoped_ptr( | 136 user_window_controller_requests_.push_back(make_scoped_ptr( |
138 new mojo::InterfaceRequest<mash::wm::mojom::UserWindowController>( | 137 new mojo::InterfaceRequest<mash::wm::mojom::UserWindowController>( |
139 std::move(request)))); | 138 std::move(request)))); |
140 } | 139 } |
141 } | 140 } |
142 | 141 |
143 void WindowManagerApplication::Create( | 142 void WindowManagerApplication::Create( |
144 mojo::ApplicationConnection* connection, | 143 mojo::Connection* connection, |
145 mojo::InterfaceRequest<mus::mojom::AcceleratorRegistrar> request) { | 144 mojo::InterfaceRequest<mus::mojom::AcceleratorRegistrar> request) { |
146 static int accelerator_registrar_count = 0; | 145 static int accelerator_registrar_count = 0; |
147 if (accelerator_registrar_count == std::numeric_limits<int>::max()) { | 146 if (accelerator_registrar_count == std::numeric_limits<int>::max()) { |
148 // Restart from zero if we have reached the limit. It is technically | 147 // Restart from zero if we have reached the limit. It is technically |
149 // possible to end up with multiple active registrars with the same | 148 // possible to end up with multiple active registrars with the same |
150 // namespace, but it is highly unlikely. In the event that multiple | 149 // namespace, but it is highly unlikely. In the event that multiple |
151 // registrars have the same namespace, this new registrar will be unable to | 150 // registrars have the same namespace, this new registrar will be unable to |
152 // install accelerators. | 151 // install accelerators. |
153 accelerator_registrar_count = 0; | 152 accelerator_registrar_count = 0; |
154 } | 153 } |
155 accelerator_registrars_.insert(new AcceleratorRegistrarImpl( | 154 accelerator_registrars_.insert(new AcceleratorRegistrarImpl( |
156 this, ++accelerator_registrar_count, std::move(request), | 155 this, ++accelerator_registrar_count, std::move(request), |
157 base::Bind(&WindowManagerApplication::OnAcceleratorRegistrarDestroyed, | 156 base::Bind(&WindowManagerApplication::OnAcceleratorRegistrarDestroyed, |
158 base::Unretained(this)))); | 157 base::Unretained(this)))); |
159 } | 158 } |
160 | 159 |
161 void WindowManagerApplication::CreateWindowManager( | 160 void WindowManagerApplication::CreateWindowManager( |
162 mus::mojom::DisplayPtr display, | 161 mus::mojom::DisplayPtr display, |
163 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> client_request) { | 162 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> client_request) { |
164 root_controllers_.insert(RootWindowController::CreateFromDisplay( | 163 root_controllers_.insert(RootWindowController::CreateFromDisplay( |
165 this, std::move(display), std::move(client_request))); | 164 this, std::move(display), std::move(client_request))); |
166 } | 165 } |
167 | 166 |
168 } // namespace wm | 167 } // namespace wm |
169 } // namespace mash | 168 } // namespace mash |
OLD | NEW |