Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Side by Side Diff: ash/mus/window_manager_application.cc

Issue 2029883002: Moves mash/wm into ash/mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove_static_assert
Patch Set: move comment Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/mus/window_manager_application.h ('k') | ash/mus/window_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ash/mus/window_manager_application.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "ash/mus/accelerator_registrar_impl.h"
10 #include "ash/mus/bridge/wm_globals_mus.h"
11 #include "ash/mus/bridge/wm_lookup_mus.h"
12 #include "ash/mus/root_window_controller.h"
13 #include "ash/mus/root_windows_observer.h"
14 #include "ash/mus/shelf_layout_impl.h"
15 #include "ash/mus/user_window_controller_impl.h"
9 #include "base/bind.h" 16 #include "base/bind.h"
10 #include "base/memory/ptr_util.h" 17 #include "base/memory/ptr_util.h"
11 #include "components/mus/common/event_matcher_util.h" 18 #include "components/mus/common/event_matcher_util.h"
12 #include "components/mus/public/cpp/window.h" 19 #include "components/mus/public/cpp/window.h"
13 #include "components/mus/public/interfaces/window_manager_factory.mojom.h" 20 #include "components/mus/public/interfaces/window_manager_factory.mojom.h"
14 #include "mash/wm/accelerator_registrar_impl.h"
15 #include "mash/wm/bridge/wm_globals_mus.h"
16 #include "mash/wm/bridge/wm_lookup_mus.h"
17 #include "mash/wm/root_window_controller.h"
18 #include "mash/wm/root_windows_observer.h"
19 #include "mash/wm/shelf_layout_impl.h"
20 #include "mash/wm/user_window_controller_impl.h"
21 #include "services/shell/public/cpp/connection.h" 21 #include "services/shell/public/cpp/connection.h"
22 #include "services/shell/public/cpp/connector.h" 22 #include "services/shell/public/cpp/connector.h"
23 #include "services/tracing/public/cpp/tracing_impl.h" 23 #include "services/tracing/public/cpp/tracing_impl.h"
24 #include "ui/events/event.h" 24 #include "ui/events/event.h"
25 #include "ui/events/mojo/input_events_type_converters.h" 25 #include "ui/events/mojo/input_events_type_converters.h"
26 #include "ui/views/mus/aura_init.h" 26 #include "ui/views/mus/aura_init.h"
27 #include "ui/views/mus/screen_mus.h" 27 #include "ui/views/mus/screen_mus.h"
28 28
29 namespace mash { 29 namespace ash {
30 namespace wm { 30 namespace mus {
31 31
32 WindowManagerApplication::WindowManagerApplication() 32 WindowManagerApplication::WindowManagerApplication()
33 : connector_(nullptr), window_manager_factory_binding_(this) {} 33 : connector_(nullptr), window_manager_factory_binding_(this) {}
34 34
35 WindowManagerApplication::~WindowManagerApplication() { 35 WindowManagerApplication::~WindowManagerApplication() {
36 // AcceleratorRegistrarImpl removes an observer in its destructor. Destroy 36 // AcceleratorRegistrarImpl removes an observer in its destructor. Destroy
37 // it early on. 37 // it early on.
38 std::set<AcceleratorRegistrarImpl*> accelerator_registrars( 38 std::set<AcceleratorRegistrarImpl*> accelerator_registrars(
39 accelerator_registrars_); 39 accelerator_registrars_);
40 for (AcceleratorRegistrarImpl* registrar : accelerator_registrars) 40 for (AcceleratorRegistrarImpl* registrar : accelerator_registrars)
(...skipping 12 matching lines...) Expand all
53 } 53 }
54 return root_controllers; 54 return root_controllers;
55 } 55 }
56 56
57 void WindowManagerApplication::OnRootWindowControllerGotRoot( 57 void WindowManagerApplication::OnRootWindowControllerGotRoot(
58 RootWindowController* root_controller) { 58 RootWindowController* root_controller) {
59 if (globals_) 59 if (globals_)
60 return; // |root_controller| is the > 1 root, nothing to do. 60 return; // |root_controller| is the > 1 root, nothing to do.
61 61
62 if (connector_) 62 if (connector_)
63 aura_init_.reset(new views::AuraInit(connector_, "mash_wm_resources.pak")); 63 aura_init_.reset(new views::AuraInit(connector_, "ash_mus_resources.pak"));
64 64
65 globals_.reset(new WmGlobalsMus(root_controller->root()->window_tree())); 65 globals_.reset(new WmGlobalsMus(root_controller->root()->window_tree()));
66 lookup_.reset(new WmLookupMus); 66 lookup_.reset(new WmLookupMus);
67 } 67 }
68 68
69 void WindowManagerApplication::OnRootWindowControllerDoneInit( 69 void WindowManagerApplication::OnRootWindowControllerDoneInit(
70 RootWindowController* root_controller) { 70 RootWindowController* root_controller) {
71 if (!screen_) { 71 if (!screen_) {
72 std::unique_ptr<views::ScreenMus> screen(new views::ScreenMus(nullptr)); 72 std::unique_ptr<views::ScreenMus> screen(new views::ScreenMus(nullptr));
73 screen->Init(connector_); 73 screen->Init(connector_);
(...skipping 20 matching lines...) Expand all
94 void WindowManagerApplication::OnRootWindowDestroyed( 94 void WindowManagerApplication::OnRootWindowDestroyed(
95 RootWindowController* root_controller) { 95 RootWindowController* root_controller) {
96 root_controllers_.erase(root_controller); 96 root_controllers_.erase(root_controller);
97 user_window_controller_.reset(nullptr); 97 user_window_controller_.reset(nullptr);
98 } 98 }
99 99
100 void WindowManagerApplication::OnAccelerator(uint32_t id, 100 void WindowManagerApplication::OnAccelerator(uint32_t id,
101 const ui::Event& event) { 101 const ui::Event& event) {
102 for (auto* registrar : accelerator_registrars_) { 102 for (auto* registrar : accelerator_registrars_) {
103 if (registrar->OwnsAccelerator(id)) { 103 if (registrar->OwnsAccelerator(id)) {
104 registrar->ProcessAccelerator(id, mus::mojom::Event::From(event)); 104 registrar->ProcessAccelerator(id, ::mus::mojom::Event::From(event));
105 break; 105 break;
106 } 106 }
107 } 107 }
108 } 108 }
109 109
110 void WindowManagerApplication::AddRootWindowsObserver( 110 void WindowManagerApplication::AddRootWindowsObserver(
111 RootWindowsObserver* observer) { 111 RootWindowsObserver* observer) {
112 root_windows_observers_.AddObserver(observer); 112 root_windows_observers_.AddObserver(observer);
113 } 113 }
114 114
(...skipping 12 matching lines...) Expand all
127 root_controllers_.insert(root_window_controller); 127 root_controllers_.insert(root_window_controller);
128 } 128 }
129 129
130 void WindowManagerApplication::Initialize(shell::Connector* connector, 130 void WindowManagerApplication::Initialize(shell::Connector* connector,
131 const shell::Identity& identity, 131 const shell::Identity& identity,
132 uint32_t id) { 132 uint32_t id) {
133 connector_ = connector; 133 connector_ = connector;
134 if (connector) { 134 if (connector) {
135 tracing_.Initialize(connector, identity.name()); 135 tracing_.Initialize(connector, identity.name());
136 136
137 mus::mojom::WindowManagerFactoryServicePtr wm_factory_service; 137 ::mus::mojom::WindowManagerFactoryServicePtr wm_factory_service;
138 connector_->ConnectToInterface("mojo:mus", &wm_factory_service); 138 connector_->ConnectToInterface("mojo:mus", &wm_factory_service);
139 wm_factory_service->SetWindowManagerFactory( 139 wm_factory_service->SetWindowManagerFactory(
140 window_manager_factory_binding_.CreateInterfacePtrAndBind()); 140 window_manager_factory_binding_.CreateInterfacePtrAndBind());
141 } 141 }
142 142
143 shelf_layout_.reset(new ShelfLayoutImpl); 143 shelf_layout_.reset(new ShelfLayoutImpl);
144 user_window_controller_.reset(new UserWindowControllerImpl()); 144 user_window_controller_.reset(new UserWindowControllerImpl());
145 } 145 }
146 146
147 bool WindowManagerApplication::AcceptConnection(shell::Connection* connection) { 147 bool WindowManagerApplication::AcceptConnection(shell::Connection* connection) {
148 connection->AddInterface<ash::mojom::ShelfLayout>(this); 148 connection->AddInterface<mojom::ShelfLayout>(this);
149 connection->AddInterface<ash::mojom::UserWindowController>(this); 149 connection->AddInterface<mojom::UserWindowController>(this);
150 connection->AddInterface<mus::mojom::AcceleratorRegistrar>(this); 150 connection->AddInterface<::mus::mojom::AcceleratorRegistrar>(this);
151 if (connection->GetRemoteIdentity().name() == "mojo:mash_session") 151 if (connection->GetRemoteIdentity().name() == "mojo:mash_session")
152 connection->GetInterface(&session_); 152 connection->GetInterface(&session_);
153 return true; 153 return true;
154 } 154 }
155 155
156 void WindowManagerApplication::Create( 156 void WindowManagerApplication::Create(
157 shell::Connection* connection, 157 shell::Connection* connection,
158 mojo::InterfaceRequest<ash::mojom::ShelfLayout> request) { 158 mojo::InterfaceRequest<mojom::ShelfLayout> request) {
159 // TODO(msw): Handle multiple shelves (one per display). 159 // TODO(msw): Handle multiple shelves (one per display).
160 if (!root_controllers_.empty() && (*root_controllers_.begin())->root()) { 160 if (!root_controllers_.empty() && (*root_controllers_.begin())->root()) {
161 shelf_layout_bindings_.AddBinding(shelf_layout_.get(), std::move(request)); 161 shelf_layout_bindings_.AddBinding(shelf_layout_.get(), std::move(request));
162 } else { 162 } else {
163 shelf_layout_requests_.push_back( 163 shelf_layout_requests_.push_back(base::WrapUnique(
164 base::WrapUnique(new mojo::InterfaceRequest<ash::mojom::ShelfLayout>( 164 new mojo::InterfaceRequest<mojom::ShelfLayout>(std::move(request))));
165 }
166 }
167
168 void WindowManagerApplication::Create(
169 shell::Connection* connection,
170 mojo::InterfaceRequest<mojom::UserWindowController> request) {
171 if (!root_controllers_.empty() && (*root_controllers_.begin())->root()) {
172 user_window_controller_bindings_.AddBinding(user_window_controller_.get(),
173 std::move(request));
174 } else {
175 user_window_controller_requests_.push_back(base::WrapUnique(
176 new mojo::InterfaceRequest<mojom::UserWindowController>(
165 std::move(request)))); 177 std::move(request))));
166 } 178 }
167 } 179 }
168 180
169 void WindowManagerApplication::Create( 181 void WindowManagerApplication::Create(
170 shell::Connection* connection, 182 shell::Connection* connection,
171 mojo::InterfaceRequest<ash::mojom::UserWindowController> request) { 183 mojo::InterfaceRequest<::mus::mojom::AcceleratorRegistrar> request) {
172 if (!root_controllers_.empty() && (*root_controllers_.begin())->root()) {
173 user_window_controller_bindings_.AddBinding(user_window_controller_.get(),
174 std::move(request));
175 } else {
176 user_window_controller_requests_.push_back(base::WrapUnique(
177 new mojo::InterfaceRequest<ash::mojom::UserWindowController>(
178 std::move(request))));
179 }
180 }
181
182 void WindowManagerApplication::Create(
183 shell::Connection* connection,
184 mojo::InterfaceRequest<mus::mojom::AcceleratorRegistrar> request) {
185 static int accelerator_registrar_count = 0; 184 static int accelerator_registrar_count = 0;
186 if (accelerator_registrar_count == std::numeric_limits<int>::max()) { 185 if (accelerator_registrar_count == std::numeric_limits<int>::max()) {
187 // Restart from zero if we have reached the limit. It is technically 186 // Restart from zero if we have reached the limit. It is technically
188 // possible to end up with multiple active registrars with the same 187 // possible to end up with multiple active registrars with the same
189 // namespace, but it is highly unlikely. In the event that multiple 188 // namespace, but it is highly unlikely. In the event that multiple
190 // registrars have the same namespace, this new registrar will be unable to 189 // registrars have the same namespace, this new registrar will be unable to
191 // install accelerators. 190 // install accelerators.
192 accelerator_registrar_count = 0; 191 accelerator_registrar_count = 0;
193 } 192 }
194 accelerator_registrars_.insert(new AcceleratorRegistrarImpl( 193 accelerator_registrars_.insert(new AcceleratorRegistrarImpl(
195 this, ++accelerator_registrar_count, std::move(request), 194 this, ++accelerator_registrar_count, std::move(request),
196 base::Bind(&WindowManagerApplication::OnAcceleratorRegistrarDestroyed, 195 base::Bind(&WindowManagerApplication::OnAcceleratorRegistrarDestroyed,
197 base::Unretained(this)))); 196 base::Unretained(this))));
198 } 197 }
199 198
200 void WindowManagerApplication::CreateWindowManager( 199 void WindowManagerApplication::CreateWindowManager(
201 mus::mojom::DisplayPtr display, 200 ::mus::mojom::DisplayPtr display,
202 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> client_request) { 201 mojo::InterfaceRequest<::mus::mojom::WindowTreeClient> client_request) {
203 AddRootWindowController(RootWindowController::CreateFromDisplay( 202 AddRootWindowController(RootWindowController::CreateFromDisplay(
204 this, std::move(display), std::move(client_request))); 203 this, std::move(display), std::move(client_request)));
205 } 204 }
206 205
207 } // namespace wm 206 } // namespace mus
208 } // namespace mash 207 } // namespace ash
OLDNEW
« no previous file with comments | « ash/mus/window_manager_application.h ('k') | ash/mus/window_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698