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

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

Issue 2769213005: Adds kWillProcessAccelerator_KeyEventProperty (Closed)
Patch Set: cleanup 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
« no previous file with comments | « ash/common/accelerators/accelerator_controller.cc ('k') | ash/public/interfaces/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "ash/common/wm_shell.h" 11 #include "ash/common/wm_shell.h"
12 #include "ash/mus/accelerators/accelerator_ids.h" 12 #include "ash/mus/accelerators/accelerator_ids.h"
13 #include "ash/mus/window_manager.h" 13 #include "ash/mus/window_manager.h"
14 #include "ash/public/interfaces/event_properties.mojom.h"
14 #include "ash/shell.h" 15 #include "ash/shell.h"
15 #include "base/logging.h" 16 #include "base/logging.h"
16 #include "services/ui/common/accelerator_util.h" 17 #include "services/ui/common/accelerator_util.h"
18 #include "services/ui/public/cpp/property_type_converters.h"
17 #include "ui/base/accelerators/accelerator_history.h" 19 #include "ui/base/accelerators/accelerator_history.h"
18 20
19 namespace ash { 21 namespace ash {
20 namespace mus { 22 namespace mus {
21 namespace { 23 namespace {
22 24
23 // Callback from registering the accelerators. 25 // Callback from registering the accelerators.
24 void OnAcceleratorsAdded(const std::vector<ui::Accelerator>& accelerators, 26 void OnAcceleratorsAdded(const std::vector<ui::Accelerator>& accelerators,
25 bool added) { 27 bool added) {
26 // All our accelerators should be registered, so we expect |added| to be true. 28 // All our accelerators should be registered, so we expect |added| to be true.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // same as it was in ash. We need to figure out exactly what is needed of 79 // same as it was in ash. We need to figure out exactly what is needed of
78 // previous accelerator so that we can either register for the right set of 80 // previous accelerator so that we can either register for the right set of
79 // accelerators, or make WS send the previous accelerator. 81 // accelerators, or make WS send the previous accelerator.
80 // http://crbug.com/630683. 82 // http://crbug.com/630683.
81 accelerator_controller->accelerator_history()->StoreCurrentAccelerator( 83 accelerator_controller->accelerator_history()->StoreCurrentAccelerator(
82 accelerator); 84 accelerator);
83 WmWindow* target_window = WmShell::Get()->GetFocusedWindow(); 85 WmWindow* target_window = WmShell::Get()->GetFocusedWindow();
84 if (!target_window) 86 if (!target_window)
85 target_window = Shell::GetWmRootWindowForNewWindows(); 87 target_window = Shell::GetWmRootWindowForNewWindows();
86 DCHECK(target_window); 88 DCHECK(target_window);
87 return router_->ProcessAccelerator(target_window, *(event.AsKeyEvent()), 89 if (router_->ProcessAccelerator(target_window, *(event.AsKeyEvent()),
88 accelerator) 90 accelerator)) {
89 ? ui::mojom::EventResult::HANDLED 91 return ui::mojom::EventResult::HANDLED;
90 : ui::mojom::EventResult::UNHANDLED; 92 }
93 if (accelerator_controller->IsActionForAcceleratorEnabled(accelerator)) {
94 // We do have an accelerator for the key. Set a property so that the real
95 // target knows we have an accelerator.
96 (*properties)[mojom::kWillProcessAccelerator_KeyEventProperty] =
sky 2017/03/24 18:02:23 The |properties| supplied here are passed back to
sadrul 2017/03/24 18:05:01 Ooh, right. This is only for pre-target accelerato
sky 2017/03/24 18:11:54 Exactly. See line 75.
97 std::vector<uint8_t>();
98 }
99 return ui::mojom::EventResult::UNHANDLED;
91 } 100 }
92 DCHECK_EQ(GetAcceleratorLocalId(id), ids.post_id); 101 DCHECK_EQ(GetAcceleratorLocalId(id), ids.post_id);
93 // NOTE: for post return value doesn't really matter. 102 // NOTE: for post return value doesn't really matter.
94 return Shell::Get()->accelerator_controller()->Process(accelerator) 103 return Shell::Get()->accelerator_controller()->Process(accelerator)
95 ? ui::mojom::EventResult::HANDLED 104 ? ui::mojom::EventResult::HANDLED
96 : ui::mojom::EventResult::UNHANDLED; 105 : ui::mojom::EventResult::UNHANDLED;
97 } 106 }
98 107
99 void AcceleratorControllerRegistrar::OnAcceleratorsRegistered( 108 void AcceleratorControllerRegistrar::OnAcceleratorsRegistered(
100 const std::vector<ui::Accelerator>& accelerators) { 109 const std::vector<ui::Accelerator>& accelerators) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 // Common case is we never wrap once, so this is typically cheap. Additionally 180 // Common case is we never wrap once, so this is typically cheap. Additionally
172 // we expect there not to be too many accelerators. 181 // we expect there not to be too many accelerators.
173 while (ids_.count(next_id_) > 0) 182 while (ids_.count(next_id_) > 0)
174 ++next_id_; 183 ++next_id_;
175 ids_.insert(next_id_); 184 ids_.insert(next_id_);
176 return next_id_++; 185 return next_id_++;
177 } 186 }
178 187
179 } // namespace mus 188 } // namespace mus
180 } // namespace ash 189 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/accelerators/accelerator_controller.cc ('k') | ash/public/interfaces/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698