| OLD | NEW |
| 1 // Copyright 2015 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 "services/ui/common/event_matcher_util.h" | 5 #include "services/ui/common/accelerator_util.h" |
| 6 | 6 |
| 7 namespace ui { | 7 namespace ui { |
| 8 | 8 |
| 9 mojom::EventMatcherPtr CreateKeyMatcher(ui::mojom::KeyboardCode code, | 9 mojom::EventMatcherPtr CreateKeyMatcher(ui::mojom::KeyboardCode code, |
| 10 int flags) { | 10 int flags) { |
| 11 mojom::EventMatcherPtr matcher(mojom::EventMatcher::New()); | 11 mojom::EventMatcherPtr matcher(mojom::EventMatcher::New()); |
| 12 matcher->type_matcher = mojom::EventTypeMatcher::New(); | 12 matcher->type_matcher = mojom::EventTypeMatcher::New(); |
| 13 matcher->flags_matcher = mojom::EventFlagsMatcher::New(); | 13 matcher->flags_matcher = mojom::EventFlagsMatcher::New(); |
| 14 matcher->ignore_flags_matcher = mojom::EventFlagsMatcher::New(); | 14 matcher->ignore_flags_matcher = mojom::EventFlagsMatcher::New(); |
| 15 // Ignoring these makes most accelerator scenarios more straight forward. Code | 15 // Ignoring these makes most accelerator scenarios more straight forward. Code |
| 16 // that needs to check them can override this setting. | 16 // that needs to check them can override this setting. |
| 17 matcher->ignore_flags_matcher->flags = ui::mojom::kEventFlagCapsLockOn | | 17 matcher->ignore_flags_matcher->flags = ui::mojom::kEventFlagCapsLockOn | |
| 18 ui::mojom::kEventFlagScrollLockOn | | 18 ui::mojom::kEventFlagScrollLockOn | |
| 19 ui::mojom::kEventFlagNumLockOn; | 19 ui::mojom::kEventFlagNumLockOn; |
| 20 matcher->key_matcher = mojom::KeyEventMatcher::New(); | 20 matcher->key_matcher = mojom::KeyEventMatcher::New(); |
| 21 | |
| 22 matcher->type_matcher->type = ui::mojom::EventType::KEY_PRESSED; | 21 matcher->type_matcher->type = ui::mojom::EventType::KEY_PRESSED; |
| 23 matcher->flags_matcher->flags = flags; | 22 matcher->flags_matcher->flags = flags; |
| 24 matcher->key_matcher->keyboard_code = code; | 23 matcher->key_matcher->keyboard_code = code; |
| 25 return matcher; | 24 return matcher; |
| 26 } | 25 } |
| 27 | 26 |
| 27 std::vector<ui::mojom::AcceleratorPtr> CreateAcceleratorVector( |
| 28 uint32_t id, |
| 29 ui::mojom::EventMatcherPtr event_matcher) { |
| 30 std::vector<ui::mojom::AcceleratorPtr> accelerators; |
| 31 accelerators.push_back(CreateAccelerator(id, std::move(event_matcher))); |
| 32 return accelerators; |
| 33 } |
| 34 |
| 35 ui::mojom::AcceleratorPtr CreateAccelerator( |
| 36 uint32_t id, |
| 37 ui::mojom::EventMatcherPtr event_matcher) { |
| 38 ui::mojom::AcceleratorPtr accelerator_ptr = ui::mojom::Accelerator::New(); |
| 39 accelerator_ptr->id = id; |
| 40 accelerator_ptr->event_matcher = std::move(event_matcher); |
| 41 return accelerator_ptr; |
| 42 } |
| 43 |
| 28 } // namespace ui | 44 } // namespace ui |
| OLD | NEW |