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/accelerator_registrar_impl.h" | 5 #include "ash/mus/accelerator_registrar_impl.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "ash/mus/root_window_controller.h" | 10 #include "ash/mus/root_window_controller.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 } | 49 } |
50 | 50 |
51 void AcceleratorRegistrarImpl::Destroy() { | 51 void AcceleratorRegistrarImpl::Destroy() { |
52 delete this; | 52 delete this; |
53 } | 53 } |
54 | 54 |
55 bool AcceleratorRegistrarImpl::OwnsAccelerator(uint32_t accelerator_id) const { | 55 bool AcceleratorRegistrarImpl::OwnsAccelerator(uint32_t accelerator_id) const { |
56 return !!accelerators_.count(accelerator_id); | 56 return !!accelerators_.count(accelerator_id); |
57 } | 57 } |
58 | 58 |
59 void AcceleratorRegistrarImpl::ProcessAccelerator( | 59 void AcceleratorRegistrarImpl::ProcessAccelerator(uint32_t accelerator_id, |
60 uint32_t accelerator_id, | 60 const ui::Event& event) { |
61 ::mus::mojom::EventPtr event) { | |
62 DCHECK(OwnsAccelerator(accelerator_id)); | 61 DCHECK(OwnsAccelerator(accelerator_id)); |
| 62 // TODO(moshayedi): crbug.com/617167. Don't clone even once we map |
| 63 // mojom::Event directly to ui::Event. |
63 accelerator_handler_->OnAccelerator(accelerator_id & kAcceleratorIdMask, | 64 accelerator_handler_->OnAccelerator(accelerator_id & kAcceleratorIdMask, |
64 std::move(event)); | 65 ui::Event::Clone(event)); |
65 } | 66 } |
66 | 67 |
67 AcceleratorRegistrarImpl::~AcceleratorRegistrarImpl() { | 68 AcceleratorRegistrarImpl::~AcceleratorRegistrarImpl() { |
68 wm_app_->RemoveRootWindowsObserver(this); | 69 wm_app_->RemoveRootWindowsObserver(this); |
69 RemoveAllAccelerators(); | 70 RemoveAllAccelerators(); |
70 destroy_callback_.Run(this); | 71 destroy_callback_.Run(this); |
71 } | 72 } |
72 | 73 |
73 uint32_t AcceleratorRegistrarImpl::ComputeAcceleratorId( | 74 uint32_t AcceleratorRegistrarImpl::ComputeAcceleratorId( |
74 uint32_t accelerator_id) const { | 75 uint32_t accelerator_id) const { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 } | 164 } |
164 | 165 |
165 void AcceleratorRegistrarImpl::OnRootWindowControllerAdded( | 166 void AcceleratorRegistrarImpl::OnRootWindowControllerAdded( |
166 RootWindowController* controller) { | 167 RootWindowController* controller) { |
167 for (const auto& pair : accelerators_) | 168 for (const auto& pair : accelerators_) |
168 AddAcceleratorToRoot(controller, pair.first); | 169 AddAcceleratorToRoot(controller, pair.first); |
169 } | 170 } |
170 | 171 |
171 } // namespace mus | 172 } // namespace mus |
172 } // namespace ash | 173 } // namespace ash |
OLD | NEW |