forked from kiwibrowser/src
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevent_matcher_util.cc
60 lines (51 loc) · 2.38 KB
/
event_matcher_util.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/event_matcher_util.h"
namespace ash {
ui::mojom::EventMatcherPtr BuildKeyReleaseMatcher() {
ui::mojom::EventMatcherPtr matcher(ui::mojom::EventMatcher::New());
matcher->type_matcher = ui::mojom::EventTypeMatcher::New();
matcher->type_matcher->type = ui::mojom::EventType::KEY_RELEASED;
return matcher;
}
ui::mojom::EventMatcherPtr BuildAltMatcher() {
ui::mojom::EventMatcherPtr matcher(ui::mojom::EventMatcher::New());
matcher->flags_matcher = ui::mojom::EventFlagsMatcher::New();
matcher->flags_matcher->flags = ui::mojom::kEventFlagAltDown;
matcher->ignore_flags_matcher = ui::mojom::EventFlagsMatcher::New();
matcher->ignore_flags_matcher->flags =
ui::mojom::kEventFlagCapsLockOn | ui::mojom::kEventFlagScrollLockOn |
ui::mojom::kEventFlagNumLockOn | ui::mojom::kEventFlagControlDown;
return matcher;
}
ui::mojom::EventMatcherPtr BuildControlMatcher() {
ui::mojom::EventMatcherPtr matcher(ui::mojom::EventMatcher::New());
matcher->flags_matcher = ui::mojom::EventFlagsMatcher::New();
matcher->flags_matcher->flags = ui::mojom::kEventFlagControlDown;
matcher->ignore_flags_matcher = ui::mojom::EventFlagsMatcher::New();
matcher->ignore_flags_matcher->flags =
ui::mojom::kEventFlagCapsLockOn | ui::mojom::kEventFlagScrollLockOn |
ui::mojom::kEventFlagNumLockOn | ui::mojom::kEventFlagAltDown;
return matcher;
}
ui::mojom::EventMatcherPtr BuildKeyMatcher(ui::mojom::KeyboardCode code) {
ui::mojom::EventMatcherPtr matcher(ui::mojom::EventMatcher::New());
matcher->key_matcher = ui::mojom::KeyEventMatcher::New();
matcher->key_matcher->keyboard_code = code;
return matcher;
}
void BuildKeyMatcherRange(ui::mojom::KeyboardCode start,
ui::mojom::KeyboardCode end,
std::vector<::ui::mojom::EventMatcherPtr>* matchers) {
for (int i = static_cast<int>(start); i <= static_cast<int>(end); ++i) {
matchers->push_back(
BuildKeyMatcher(static_cast<ui::mojom::KeyboardCode>(i)));
}
}
void BuildKeyMatcherList(std::vector<ui::mojom::KeyboardCode> codes,
std::vector<::ui::mojom::EventMatcherPtr>* matchers) {
for (auto& code : codes)
matchers->push_back(BuildKeyMatcher(code));
}
} // namespace ash