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

Side by Side Diff: ash/mus/accelerators/accelerator_controller_registrar.cc

Issue 2761233003: Adds ability for accelerators to add key/value pairs to KeyEvent (Closed)
Patch Set: feedback and compile Created 3 years, 9 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/accelerators/accelerator_controller_registrar.h" 5 #include "ash/mus/accelerators/accelerator_controller_registrar.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "ash/common/accelerators/accelerator_controller.h" 9 #include "ash/common/accelerators/accelerator_controller.h"
10 #include "ash/common/accelerators/accelerator_router.h" 10 #include "ash/common/accelerators/accelerator_router.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 // during shutdown, then this is unnecessary and results in a bunch of 49 // during shutdown, then this is unnecessary and results in a bunch of
50 // messages that are dropped. 50 // messages that are dropped.
51 for (uint16_t local_id : ids_) { 51 for (uint16_t local_id : ids_) {
52 window_manager_->window_manager_client()->RemoveAccelerator( 52 window_manager_->window_manager_client()->RemoveAccelerator(
53 ComputeAcceleratorId(id_namespace_, local_id)); 53 ComputeAcceleratorId(id_namespace_, local_id));
54 } 54 }
55 } 55 }
56 56
57 ui::mojom::EventResult AcceleratorControllerRegistrar::OnAccelerator( 57 ui::mojom::EventResult AcceleratorControllerRegistrar::OnAccelerator(
58 uint32_t id, 58 uint32_t id,
59 const ui::Event& event) { 59 const ui::Event& event,
60 // TODO: during startup a bunch of accelerators are registered, resulting in 60 std::unordered_map<std::string, std::vector<uint8_t>>* properties) {
61 // lots of IPC. We should optimize this to send a single IPC.
62 // http://crbug.com/632050
63 const ui::Accelerator accelerator(*event.AsKeyEvent()); 61 const ui::Accelerator accelerator(*event.AsKeyEvent());
64 auto iter = accelerator_to_ids_.find(accelerator); 62 auto iter = accelerator_to_ids_.find(accelerator);
65 if (iter == accelerator_to_ids_.end()) { 63 if (iter == accelerator_to_ids_.end()) {
66 // Because of timing we may have unregistered the accelerator already, 64 // Because of timing we may have unregistered the accelerator already,
67 // ignore in that case. 65 // ignore in that case.
68 return ui::mojom::EventResult::UNHANDLED; 66 return ui::mojom::EventResult::UNHANDLED;
69 } 67 }
70 68
71 const Ids& ids = iter->second; 69 const Ids& ids = iter->second;
72 AcceleratorController* accelerator_controller = 70 AcceleratorController* accelerator_controller =
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 // Common case is we never wrap once, so this is typically cheap. Additionally 171 // Common case is we never wrap once, so this is typically cheap. Additionally
174 // we expect there not to be too many accelerators. 172 // we expect there not to be too many accelerators.
175 while (ids_.count(next_id_) > 0) 173 while (ids_.count(next_id_) > 0)
176 ++next_id_; 174 ++next_id_;
177 ids_.insert(next_id_); 175 ids_.insert(next_id_);
178 return next_id_++; 176 return next_id_++;
179 } 177 }
180 178
181 } // namespace mus 179 } // namespace mus
182 } // namespace ash 180 } // namespace ash
OLDNEW
« no previous file with comments | « ash/mus/accelerators/accelerator_controller_registrar.h ('k') | ash/mus/accelerators/accelerator_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698