OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef COMPONENTS_MUS_WS_EVENT_MATCHER_H_ | |
6 #define COMPONENTS_MUS_WS_EVENT_MATCHER_H_ | |
7 | |
8 #include <stdint.h> | |
9 | |
10 #include "base/macros.h" | |
11 #include "components/mus/public/interfaces/event_matcher.mojom.h" | |
12 #include "ui/events/event.h" | |
13 #include "ui/events/mojo/event_constants.mojom.h" | |
14 #include "ui/events/mojo/keyboard_codes.mojom.h" | |
15 #include "ui/gfx/geometry/rect_f.h" | |
16 | |
17 namespace mus { | |
18 namespace ws { | |
19 | |
20 // Wraps a mojom::EventMatcher and allows events to be tested against it. | |
21 class EventMatcher { | |
22 public: | |
23 explicit EventMatcher(const mojom::EventMatcher& matcher); | |
24 ~EventMatcher(); | |
25 | |
26 bool MatchesEvent(const ui::Event& event) const; | |
27 | |
28 bool Equals(const EventMatcher& other) const; | |
29 | |
30 private: | |
31 enum MatchFields { | |
32 NONE = 0, | |
33 TYPE = 1 << 0, | |
34 FLAGS = 1 << 1, | |
35 KEYBOARD_CODE = 1 << 2, | |
36 POINTER_KIND = 1 << 3, | |
37 POINTER_LOCATION = 1 << 4, | |
38 }; | |
39 | |
40 uint32_t fields_to_match_; | |
41 ui::EventType event_type_; | |
42 // Bitfields of kEventFlag* and kMouseEventFlag* values in | |
43 // input_event_constants.mojom. | |
44 int event_flags_; | |
45 int ignore_event_flags_; | |
46 uint16_t keyboard_code_; | |
47 ui::EventPointerType pointer_type_; | |
48 gfx::RectF pointer_region_; | |
49 | |
50 DISALLOW_COPY_AND_ASSIGN(EventMatcher); | |
51 }; | |
52 | |
53 } // namespace ws | |
54 } // namespace mus | |
55 | |
56 #endif // COMPONENTS_MUS_WS_EVENT_MATCHER_H_ | |
OLD | NEW |