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

Side by Side Diff: services/ui/common/accelerator_util.cc

Issue 2520093003: WindowManagerClient::AddAccelerator() should take an array (Closed)
Patch Set: Rename/refactor code. Add unit test for multiple accelerators. Created 4 years 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 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 "services/ui/common/event_matcher_util.h" 5 #include "services/ui/common/accelerator_util.h"
6
7 namespace ash {
8 namespace mus {
9
10 std::vector<ui::mojom::AcceleratorTransportPtr> AddAcceleratorHelper(
11 uint32_t id,
12 ui::mojom::EventMatcherPtr event_matcher) {
13 std::vector<ui::mojom::AcceleratorTransportPtr> accelerators;
14 ui::mojom::AcceleratorTransportPtr accelerator_transport_ptr =
15 ui::mojom::AcceleratorTransport::New();
16 accelerator_transport_ptr->id = id;
17 accelerator_transport_ptr->event_matcher = std::move(event_matcher);
18 accelerators.push_back(std::move(accelerator_transport_ptr));
19 return accelerators;
20 }
21
22 } // namespace mus
23 } // namespace ash
6 24
7 namespace ui { 25 namespace ui {
8 26
9 mojom::EventMatcherPtr CreateKeyMatcher(ui::mojom::KeyboardCode code, 27 mojom::EventMatcherPtr CreateKeyMatcher(ui::mojom::KeyboardCode code,
10 int flags) { 28 int flags) {
11 mojom::EventMatcherPtr matcher(mojom::EventMatcher::New()); 29 mojom::EventMatcherPtr matcher(mojom::EventMatcher::New());
12 matcher->type_matcher = mojom::EventTypeMatcher::New(); 30 matcher->type_matcher = mojom::EventTypeMatcher::New();
13 matcher->flags_matcher = mojom::EventFlagsMatcher::New(); 31 matcher->flags_matcher = mojom::EventFlagsMatcher::New();
14 matcher->ignore_flags_matcher = mojom::EventFlagsMatcher::New(); 32 matcher->ignore_flags_matcher = mojom::EventFlagsMatcher::New();
15 // Ignoring these makes most accelerator scenarios more straight forward. Code 33 // Ignoring these makes most accelerator scenarios more straight forward. Code
16 // that needs to check them can override this setting. 34 // that needs to check them can override this setting.
17 matcher->ignore_flags_matcher->flags = ui::mojom::kEventFlagCapsLockOn | 35 matcher->ignore_flags_matcher->flags = ui::mojom::kEventFlagCapsLockOn |
18 ui::mojom::kEventFlagScrollLockOn | 36 ui::mojom::kEventFlagScrollLockOn |
19 ui::mojom::kEventFlagNumLockOn; 37 ui::mojom::kEventFlagNumLockOn;
20 matcher->key_matcher = mojom::KeyEventMatcher::New(); 38 matcher->key_matcher = mojom::KeyEventMatcher::New();
21 39
22 matcher->type_matcher->type = ui::mojom::EventType::KEY_PRESSED; 40 matcher->type_matcher->type = ui::mojom::EventType::KEY_PRESSED;
23 matcher->flags_matcher->flags = flags; 41 matcher->flags_matcher->flags = flags;
24 matcher->key_matcher->keyboard_code = code; 42 matcher->key_matcher->keyboard_code = code;
25 return matcher; 43 return matcher;
26 } 44 }
27 45
28 } // namespace ui 46 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698