| 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/mus/accelerator_registrar_impl.h" | 9 #include "ash/mus/accelerator_registrar_impl.h" |
| 10 #include "ash/mus/root_window_controller.h" | 10 #include "ash/mus/root_window_controller.h" |
| 11 #include "ash/mus/root_windows_observer.h" | |
| 12 #include "ash/mus/shelf_layout_impl.h" | 11 #include "ash/mus/shelf_layout_impl.h" |
| 13 #include "ash/mus/user_window_controller_impl.h" | 12 #include "ash/mus/user_window_controller_impl.h" |
| 14 #include "ash/mus/window_manager.h" | 13 #include "ash/mus/window_manager.h" |
| 15 #include "base/bind.h" | 14 #include "base/bind.h" |
| 16 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
| 17 #include "components/mus/common/event_matcher_util.h" | 16 #include "components/mus/common/event_matcher_util.h" |
| 18 #include "components/mus/common/gpu_service.h" | 17 #include "components/mus/common/gpu_service.h" |
| 19 #include "components/mus/public/cpp/window.h" | 18 #include "components/mus/public/cpp/window.h" |
| 20 #include "components/mus/public/cpp/window_tree_client.h" | 19 #include "components/mus/public/cpp/window_tree_client.h" |
| 21 #include "services/shell/public/cpp/connection.h" | 20 #include "services/shell/public/cpp/connection.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 36 std::set<AcceleratorRegistrarImpl*> accelerator_registrars( | 35 std::set<AcceleratorRegistrarImpl*> accelerator_registrars( |
| 37 accelerator_registrars_); | 36 accelerator_registrars_); |
| 38 for (AcceleratorRegistrarImpl* registrar : accelerator_registrars) | 37 for (AcceleratorRegistrarImpl* registrar : accelerator_registrars) |
| 39 registrar->Destroy(); | 38 registrar->Destroy(); |
| 40 | 39 |
| 41 // Destroy the WindowManager while still valid. This way we ensure | 40 // Destroy the WindowManager while still valid. This way we ensure |
| 42 // OnWillDestroyRootWindowController() is called (if it hasn't been already). | 41 // OnWillDestroyRootWindowController() is called (if it hasn't been already). |
| 43 window_manager_.reset(); | 42 window_manager_.reset(); |
| 44 } | 43 } |
| 45 | 44 |
| 46 void WindowManagerApplication::OnAccelerator(uint32_t id, | |
| 47 const ui::Event& event) { | |
| 48 for (auto* registrar : accelerator_registrars_) { | |
| 49 if (registrar->OwnsAccelerator(id)) { | |
| 50 registrar->ProcessAccelerator(id, event); | |
| 51 break; | |
| 52 } | |
| 53 } | |
| 54 } | |
| 55 | |
| 56 void WindowManagerApplication::OnAcceleratorRegistrarDestroyed( | 45 void WindowManagerApplication::OnAcceleratorRegistrarDestroyed( |
| 57 AcceleratorRegistrarImpl* registrar) { | 46 AcceleratorRegistrarImpl* registrar) { |
| 58 accelerator_registrars_.erase(registrar); | 47 accelerator_registrars_.erase(registrar); |
| 59 } | 48 } |
| 60 | 49 |
| 61 void WindowManagerApplication::InitWindowManager( | 50 void WindowManagerApplication::InitWindowManager( |
| 62 ::mus::WindowTreeClient* window_tree_client) { | 51 ::mus::WindowTreeClient* window_tree_client) { |
| 63 window_manager_->Init(window_tree_client); | 52 window_manager_->Init(window_tree_client); |
| 64 window_manager_->AddRootWindowsObserver(this); | 53 window_manager_->AddObserver(this); |
| 65 } | 54 } |
| 66 | 55 |
| 67 void WindowManagerApplication::Initialize(shell::Connector* connector, | 56 void WindowManagerApplication::Initialize(shell::Connector* connector, |
| 68 const shell::Identity& identity, | 57 const shell::Identity& identity, |
| 69 uint32_t id) { | 58 uint32_t id) { |
| 70 connector_ = connector; | 59 connector_ = connector; |
| 71 ::mus::GpuService::Initialize(connector); | 60 ::mus::GpuService::Initialize(connector); |
| 72 window_manager_.reset(new WindowManager(this, connector_)); | 61 window_manager_.reset(new WindowManager(connector_)); |
| 73 | 62 |
| 74 aura_init_.reset(new views::AuraInit(connector_, "ash_mus_resources.pak")); | 63 aura_init_.reset(new views::AuraInit(connector_, "ash_mus_resources.pak")); |
| 75 | 64 |
| 76 tracing_.Initialize(connector, identity.name()); | 65 tracing_.Initialize(connector, identity.name()); |
| 77 | 66 |
| 78 ::mus::WindowTreeClient* window_tree_client = new ::mus::WindowTreeClient( | 67 ::mus::WindowTreeClient* window_tree_client = new ::mus::WindowTreeClient( |
| 79 window_manager_.get(), window_manager_.get(), nullptr); | 68 window_manager_.get(), window_manager_.get(), nullptr); |
| 80 window_tree_client->ConnectAsWindowManager(connector); | 69 window_tree_client->ConnectAsWindowManager(connector); |
| 81 | 70 |
| 82 InitWindowManager(window_tree_client); | 71 InitWindowManager(window_tree_client); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 } else { | 104 } else { |
| 116 user_window_controller_requests_.push_back(base::WrapUnique( | 105 user_window_controller_requests_.push_back(base::WrapUnique( |
| 117 new mojo::InterfaceRequest<mojom::UserWindowController>( | 106 new mojo::InterfaceRequest<mojom::UserWindowController>( |
| 118 std::move(request)))); | 107 std::move(request)))); |
| 119 } | 108 } |
| 120 } | 109 } |
| 121 | 110 |
| 122 void WindowManagerApplication::Create( | 111 void WindowManagerApplication::Create( |
| 123 shell::Connection* connection, | 112 shell::Connection* connection, |
| 124 mojo::InterfaceRequest<::mus::mojom::AcceleratorRegistrar> request) { | 113 mojo::InterfaceRequest<::mus::mojom::AcceleratorRegistrar> request) { |
| 114 if (!window_manager_->window_manager_client()) |
| 115 return; // Can happen during shutdown. |
| 116 |
| 125 static int accelerator_registrar_count = 0; | 117 static int accelerator_registrar_count = 0; |
| 126 if (accelerator_registrar_count == std::numeric_limits<int>::max()) { | 118 if (accelerator_registrar_count == std::numeric_limits<int>::max()) { |
| 127 // Restart from zero if we have reached the limit. It is technically | 119 // Restart from zero if we have reached the limit. It is technically |
| 128 // possible to end up with multiple active registrars with the same | 120 // possible to end up with multiple active registrars with the same |
| 129 // namespace, but it is highly unlikely. In the event that multiple | 121 // namespace, but it is highly unlikely. In the event that multiple |
| 130 // registrars have the same namespace, this new registrar will be unable to | 122 // registrars have the same namespace, this new registrar will be unable to |
| 131 // install accelerators. | 123 // install accelerators. |
| 132 accelerator_registrar_count = 0; | 124 accelerator_registrar_count = 0; |
| 133 } | 125 } |
| 134 accelerator_registrars_.insert(new AcceleratorRegistrarImpl( | 126 accelerator_registrars_.insert(new AcceleratorRegistrarImpl( |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 RootWindowController* controller) { | 163 RootWindowController* controller) { |
| 172 // TODO(msw): this isn't right, ownership should belong in WindowManager | 164 // TODO(msw): this isn't right, ownership should belong in WindowManager |
| 173 // and/or RootWindowController. But this is temporary until we get rid of | 165 // and/or RootWindowController. But this is temporary until we get rid of |
| 174 // sysui. | 166 // sysui. |
| 175 shelf_layout_.reset(); | 167 shelf_layout_.reset(); |
| 176 user_window_controller_.reset(); | 168 user_window_controller_.reset(); |
| 177 } | 169 } |
| 178 | 170 |
| 179 } // namespace mus | 171 } // namespace mus |
| 180 } // namespace ash | 172 } // namespace ash |
| OLD | NEW |