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 "mojo/services/tracing/public/cpp/tracing_impl.h" | 20 #include "mojo/services/tracing/public/cpp/tracing_impl.h" |
20 #include "mojo/shell/public/cpp/connection.h" | 21 #include "mojo/shell/public/cpp/connection.h" |
21 #include "mojo/shell/public/cpp/connector.h" | 22 #include "mojo/shell/public/cpp/connector.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 = | |
sky
2016/04/13 23:44:11
These casts make me nervous. I prefer GetShelfLayo
msw
2016/04/15 17:25:06
Done (as a RootWindowController member, which stil
| |
78 static_cast<ShelfLayout*>(root_controller->GetLayoutManagerForContainer( | |
79 mash::wm::mojom::Container::USER_SHELF)); | |
80 for (auto& request : shelf_layout_requests_) | |
81 shelf_layout_bindings_.AddBinding(shelf_layout, std::move(*request)); | |
82 shelf_layout_requests_.clear(); | |
83 } | |
84 | |
74 FOR_EACH_OBSERVER(RootWindowsObserver, root_windows_observers_, | 85 FOR_EACH_OBSERVER(RootWindowsObserver, root_windows_observers_, |
75 OnRootWindowControllerAdded(root_controller)); | 86 OnRootWindowControllerAdded(root_controller)); |
76 } | 87 } |
77 | 88 |
78 void WindowManagerApplication::OnRootWindowDestroyed( | 89 void WindowManagerApplication::OnRootWindowDestroyed( |
79 RootWindowController* root_controller) { | 90 RootWindowController* root_controller) { |
80 root_controllers_.erase(root_controller); | 91 root_controllers_.erase(root_controller); |
81 user_window_controller_.reset(nullptr); | 92 user_window_controller_.reset(nullptr); |
82 } | 93 } |
83 | 94 |
(...skipping 30 matching lines...) Expand all Loading... | |
114 | 125 |
115 mus::mojom::WindowManagerFactoryServicePtr wm_factory_service; | 126 mus::mojom::WindowManagerFactoryServicePtr wm_factory_service; |
116 connector_->ConnectToInterface("mojo:mus", &wm_factory_service); | 127 connector_->ConnectToInterface("mojo:mus", &wm_factory_service); |
117 wm_factory_service->SetWindowManagerFactory( | 128 wm_factory_service->SetWindowManagerFactory( |
118 window_manager_factory_binding_.CreateInterfacePtrAndBind()); | 129 window_manager_factory_binding_.CreateInterfacePtrAndBind()); |
119 | 130 |
120 user_window_controller_.reset(new UserWindowControllerImpl()); | 131 user_window_controller_.reset(new UserWindowControllerImpl()); |
121 } | 132 } |
122 | 133 |
123 bool WindowManagerApplication::AcceptConnection(mojo::Connection* connection) { | 134 bool WindowManagerApplication::AcceptConnection(mojo::Connection* connection) { |
124 connection->AddInterface<mash::wm::mojom::UserWindowController>(this); | 135 connection->AddInterface<mojom::ShelfLayout>(this); |
136 connection->AddInterface<mojom::UserWindowController>(this); | |
125 connection->AddInterface<mus::mojom::AcceleratorRegistrar>(this); | 137 connection->AddInterface<mus::mojom::AcceleratorRegistrar>(this); |
126 if (connection->GetRemoteIdentity().name() == "mojo:mash_session") | 138 if (connection->GetRemoteIdentity().name() == "mojo:mash_session") |
127 connection->GetInterface(&session_); | 139 connection->GetInterface(&session_); |
128 return true; | 140 return true; |
129 } | 141 } |
130 | 142 |
131 void WindowManagerApplication::Create( | 143 void WindowManagerApplication::Create( |
132 mojo::Connection* connection, | 144 mojo::Connection* connection, |
133 mojo::InterfaceRequest<mash::wm::mojom::UserWindowController> request) { | 145 mojo::InterfaceRequest<mojom::ShelfLayout> request) { |
146 // TODO(msw): Handle multiple shelves (one per display). | |
134 if (!root_controllers_.empty() && (*root_controllers_.begin())->root()) { | 147 if (!root_controllers_.empty() && (*root_controllers_.begin())->root()) { |
135 user_window_controller_binding_.AddBinding(user_window_controller_.get(), | 148 ShelfLayout* shelf_layout = static_cast<ShelfLayout*>( |
136 std::move(request)); | 149 (*root_controllers_.begin()) |
150 ->GetLayoutManagerForContainer( | |
151 mash::wm::mojom::Container::USER_SHELF)); | |
152 shelf_layout_bindings_.AddBinding(shelf_layout, std::move(request)); | |
153 } else { | |
154 shelf_layout_requests_.push_back(base::WrapUnique( | |
155 new mojo::InterfaceRequest<mojom::ShelfLayout>(std::move(request)))); | |
156 } | |
157 } | |
158 | |
159 void WindowManagerApplication::Create( | |
160 mojo::Connection* connection, | |
161 mojo::InterfaceRequest<mojom::UserWindowController> request) { | |
162 if (!root_controllers_.empty() && (*root_controllers_.begin())->root()) { | |
163 user_window_controller_bindings_.AddBinding(user_window_controller_.get(), | |
164 std::move(request)); | |
137 } else { | 165 } else { |
138 user_window_controller_requests_.push_back(base::WrapUnique( | 166 user_window_controller_requests_.push_back(base::WrapUnique( |
139 new mojo::InterfaceRequest<mash::wm::mojom::UserWindowController>( | 167 new mojo::InterfaceRequest<mojom::UserWindowController>( |
140 std::move(request)))); | 168 std::move(request)))); |
141 } | 169 } |
142 } | 170 } |
143 | 171 |
144 void WindowManagerApplication::Create( | 172 void WindowManagerApplication::Create( |
145 mojo::Connection* connection, | 173 mojo::Connection* connection, |
146 mojo::InterfaceRequest<mus::mojom::AcceleratorRegistrar> request) { | 174 mojo::InterfaceRequest<mus::mojom::AcceleratorRegistrar> request) { |
147 static int accelerator_registrar_count = 0; | 175 static int accelerator_registrar_count = 0; |
148 if (accelerator_registrar_count == std::numeric_limits<int>::max()) { | 176 if (accelerator_registrar_count == std::numeric_limits<int>::max()) { |
149 // Restart from zero if we have reached the limit. It is technically | 177 // Restart from zero if we have reached the limit. It is technically |
(...skipping 11 matching lines...) Expand all Loading... | |
161 | 189 |
162 void WindowManagerApplication::CreateWindowManager( | 190 void WindowManagerApplication::CreateWindowManager( |
163 mus::mojom::DisplayPtr display, | 191 mus::mojom::DisplayPtr display, |
164 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> client_request) { | 192 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> client_request) { |
165 root_controllers_.insert(RootWindowController::CreateFromDisplay( | 193 root_controllers_.insert(RootWindowController::CreateFromDisplay( |
166 this, std::move(display), std::move(client_request))); | 194 this, std::move(display), std::move(client_request))); |
167 } | 195 } |
168 | 196 |
169 } // namespace wm | 197 } // namespace wm |
170 } // namespace mash | 198 } // namespace mash |
OLD | NEW |