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 "ash/mus/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/common/material_design/material_design_controller.h" | 9 #include "ash/common/material_design/material_design_controller.h" |
10 #include "ash/mus/accelerator_registrar_impl.h" | 10 #include "ash/mus/accelerators/accelerator_registrar_impl.h" |
11 #include "ash/mus/root_window_controller.h" | 11 #include "ash/mus/root_window_controller.h" |
12 #include "ash/mus/shelf_layout_impl.h" | 12 #include "ash/mus/shelf_layout_impl.h" |
13 #include "ash/mus/user_window_controller_impl.h" | 13 #include "ash/mus/user_window_controller_impl.h" |
14 #include "ash/mus/window_manager.h" | 14 #include "ash/mus/window_manager.h" |
15 #include "base/bind.h" | 15 #include "base/bind.h" |
16 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
17 #include "services/shell/public/cpp/connection.h" | 17 #include "services/shell/public/cpp/connection.h" |
18 #include "services/shell/public/cpp/connector.h" | 18 #include "services/shell/public/cpp/connector.h" |
19 #include "services/tracing/public/cpp/tracing_impl.h" | 19 #include "services/tracing/public/cpp/tracing_impl.h" |
20 #include "services/ui/common/event_matcher_util.h" | 20 #include "services/ui/common/event_matcher_util.h" |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 user_window_controller_requests_.push_back(std::move(request)); | 147 user_window_controller_requests_.push_back(std::move(request)); |
148 } | 148 } |
149 } | 149 } |
150 | 150 |
151 void WindowManagerApplication::Create( | 151 void WindowManagerApplication::Create( |
152 shell::Connection* connection, | 152 shell::Connection* connection, |
153 mojo::InterfaceRequest<::ui::mojom::AcceleratorRegistrar> request) { | 153 mojo::InterfaceRequest<::ui::mojom::AcceleratorRegistrar> request) { |
154 if (!window_manager_->window_manager_client()) | 154 if (!window_manager_->window_manager_client()) |
155 return; // Can happen during shutdown. | 155 return; // Can happen during shutdown. |
156 | 156 |
157 static int accelerator_registrar_count = 0; | 157 uint16_t accelerator_namespace_id; |
158 if (accelerator_registrar_count == std::numeric_limits<int>::max()) { | 158 if (!window_manager_->GetNextAcceleratorNamespaceId( |
159 // Restart from zero if we have reached the limit. It is technically | 159 &accelerator_namespace_id)) { |
160 // possible to end up with multiple active registrars with the same | 160 DVLOG(1) << "Max number of accelerators registered, ignoring request."; |
161 // namespace, but it is highly unlikely. In the event that multiple | 161 // All ids are used. Normally shouldn't happen, so we close the connection. |
162 // registrars have the same namespace, this new registrar will be unable to | 162 return; |
163 // install accelerators. | |
164 accelerator_registrar_count = 0; | |
165 } | 163 } |
166 accelerator_registrars_.insert(new AcceleratorRegistrarImpl( | 164 accelerator_registrars_.insert(new AcceleratorRegistrarImpl( |
167 window_manager_.get(), ++accelerator_registrar_count, std::move(request), | 165 window_manager_.get(), accelerator_namespace_id, std::move(request), |
168 base::Bind(&WindowManagerApplication::OnAcceleratorRegistrarDestroyed, | 166 base::Bind(&WindowManagerApplication::OnAcceleratorRegistrarDestroyed, |
169 base::Unretained(this)))); | 167 base::Unretained(this)))); |
170 } | 168 } |
171 | 169 |
172 void WindowManagerApplication::ScreenlockStateChanged(bool locked) { | 170 void WindowManagerApplication::ScreenlockStateChanged(bool locked) { |
173 window_manager_->SetScreenLocked(locked); | 171 window_manager_->SetScreenLocked(locked); |
174 } | 172 } |
175 | 173 |
176 void WindowManagerApplication::OnRootWindowControllerAdded( | 174 void WindowManagerApplication::OnRootWindowControllerAdded( |
177 RootWindowController* controller) { | 175 RootWindowController* controller) { |
(...skipping 25 matching lines...) Expand all Loading... |
203 RootWindowController* controller) { | 201 RootWindowController* controller) { |
204 // TODO(msw): this isn't right, ownership should belong in WindowManager | 202 // TODO(msw): this isn't right, ownership should belong in WindowManager |
205 // and/or RootWindowController. But this is temporary until we get rid of | 203 // and/or RootWindowController. But this is temporary until we get rid of |
206 // sysui. | 204 // sysui. |
207 shelf_layout_.reset(); | 205 shelf_layout_.reset(); |
208 user_window_controller_.reset(); | 206 user_window_controller_.reset(); |
209 } | 207 } |
210 | 208 |
211 } // namespace mus | 209 } // namespace mus |
212 } // namespace ash | 210 } // namespace ash |
OLD | NEW |