| OLD | NEW |
| 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 "components/mus/ws/event_matcher.h" | 5 #include "components/mus/ws/event_matcher.h" |
| 6 | 6 |
| 7 namespace mus { | 7 namespace mus { |
| 8 namespace ws { | 8 namespace ws { |
| 9 | 9 |
| 10 EventMatcher::EventMatcher(const mojom::EventMatcher& matcher) | 10 EventMatcher::EventMatcher(const mojom::EventMatcher& matcher) |
| 11 : fields_to_match_(NONE), | 11 : fields_to_match_(NONE), |
| 12 event_type_(ui::ET_UNKNOWN), | 12 event_type_(ui::ET_UNKNOWN), |
| 13 event_flags_(ui::EF_NONE), | 13 event_flags_(ui::EF_NONE), |
| 14 ignore_event_flags_(ui::EF_NONE), | 14 ignore_event_flags_(ui::EF_NONE), |
| 15 keyboard_code_(ui::VKEY_UNKNOWN), | 15 keyboard_code_(ui::VKEY_UNKNOWN), |
| 16 pointer_type_(ui::EventPointerType::POINTER_TYPE_UNKNOWN) { | 16 pointer_type_(ui::EventPointerType::POINTER_TYPE_UNKNOWN) { |
| 17 if (matcher.type_matcher) { | 17 if (matcher.type_matcher) { |
| 18 fields_to_match_ |= TYPE; | 18 fields_to_match_ |= TYPE; |
| 19 switch (matcher.type_matcher->type) { | 19 switch (matcher.type_matcher->type) { |
| 20 case mus::mojom::EventType::POINTER_DOWN: | 20 case ui::mojom::EventType::POINTER_DOWN: |
| 21 event_type_ = ui::ET_POINTER_DOWN; | 21 event_type_ = ui::ET_POINTER_DOWN; |
| 22 break; | 22 break; |
| 23 case mus::mojom::EventType::POINTER_MOVE: | 23 case ui::mojom::EventType::POINTER_MOVE: |
| 24 event_type_ = ui::ET_POINTER_MOVED; | 24 event_type_ = ui::ET_POINTER_MOVED; |
| 25 break; | 25 break; |
| 26 case mus::mojom::EventType::MOUSE_EXIT: | 26 case ui::mojom::EventType::MOUSE_EXIT: |
| 27 event_type_ = ui::ET_POINTER_EXITED; | 27 event_type_ = ui::ET_POINTER_EXITED; |
| 28 break; | 28 break; |
| 29 case mus::mojom::EventType::POINTER_UP: | 29 case ui::mojom::EventType::POINTER_UP: |
| 30 event_type_ = ui::ET_POINTER_UP; | 30 event_type_ = ui::ET_POINTER_UP; |
| 31 break; | 31 break; |
| 32 case mus::mojom::EventType::POINTER_CANCEL: | 32 case ui::mojom::EventType::POINTER_CANCEL: |
| 33 event_type_ = ui::ET_POINTER_CANCELLED; | 33 event_type_ = ui::ET_POINTER_CANCELLED; |
| 34 break; | 34 break; |
| 35 case mus::mojom::EventType::KEY_PRESSED: | 35 case ui::mojom::EventType::KEY_PRESSED: |
| 36 event_type_ = ui::ET_KEY_PRESSED; | 36 event_type_ = ui::ET_KEY_PRESSED; |
| 37 break; | 37 break; |
| 38 case mus::mojom::EventType::KEY_RELEASED: | 38 case ui::mojom::EventType::KEY_RELEASED: |
| 39 event_type_ = ui::ET_KEY_RELEASED; | 39 event_type_ = ui::ET_KEY_RELEASED; |
| 40 break; | 40 break; |
| 41 default: | 41 default: |
| 42 NOTREACHED(); | 42 NOTREACHED(); |
| 43 } | 43 } |
| 44 } | 44 } |
| 45 if (matcher.flags_matcher) { | 45 if (matcher.flags_matcher) { |
| 46 fields_to_match_ |= FLAGS; | 46 fields_to_match_ |= FLAGS; |
| 47 event_flags_ = matcher.flags_matcher->flags; | 47 event_flags_ = matcher.flags_matcher->flags; |
| 48 if (matcher.ignore_flags_matcher) | 48 if (matcher.ignore_flags_matcher) |
| 49 ignore_event_flags_ = matcher.ignore_flags_matcher->flags; | 49 ignore_event_flags_ = matcher.ignore_flags_matcher->flags; |
| 50 } | 50 } |
| 51 if (matcher.key_matcher) { | 51 if (matcher.key_matcher) { |
| 52 fields_to_match_ |= KEYBOARD_CODE; | 52 fields_to_match_ |= KEYBOARD_CODE; |
| 53 keyboard_code_ = static_cast<uint16_t>(matcher.key_matcher->keyboard_code); | 53 keyboard_code_ = static_cast<uint16_t>(matcher.key_matcher->keyboard_code); |
| 54 } | 54 } |
| 55 if (matcher.pointer_kind_matcher) { | 55 if (matcher.pointer_kind_matcher) { |
| 56 fields_to_match_ |= POINTER_KIND; | 56 fields_to_match_ |= POINTER_KIND; |
| 57 switch (matcher.pointer_kind_matcher->pointer_kind) { | 57 switch (matcher.pointer_kind_matcher->pointer_kind) { |
| 58 case mojom::PointerKind::MOUSE: | 58 case ui::mojom::PointerKind::MOUSE: |
| 59 pointer_type_ = ui::EventPointerType::POINTER_TYPE_MOUSE; | 59 pointer_type_ = ui::EventPointerType::POINTER_TYPE_MOUSE; |
| 60 break; | 60 break; |
| 61 case mojom::PointerKind::TOUCH: | 61 case ui::mojom::PointerKind::TOUCH: |
| 62 pointer_type_ = ui::EventPointerType::POINTER_TYPE_TOUCH; | 62 pointer_type_ = ui::EventPointerType::POINTER_TYPE_TOUCH; |
| 63 break; | 63 break; |
| 64 default: | 64 default: |
| 65 NOTREACHED(); | 65 NOTREACHED(); |
| 66 } | 66 } |
| 67 } | 67 } |
| 68 if (matcher.pointer_location_matcher) { | 68 if (matcher.pointer_location_matcher) { |
| 69 fields_to_match_ |= POINTER_LOCATION; | 69 fields_to_match_ |= POINTER_LOCATION; |
| 70 pointer_region_ = matcher.pointer_location_matcher->region; | 70 pointer_region_ = matcher.pointer_location_matcher->region; |
| 71 } | 71 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 event_type_ == other.event_type_ && | 104 event_type_ == other.event_type_ && |
| 105 event_flags_ == other.event_flags_ && | 105 event_flags_ == other.event_flags_ && |
| 106 ignore_event_flags_ == other.ignore_event_flags_ && | 106 ignore_event_flags_ == other.ignore_event_flags_ && |
| 107 keyboard_code_ == other.keyboard_code_ && | 107 keyboard_code_ == other.keyboard_code_ && |
| 108 pointer_type_ == other.pointer_type_ && | 108 pointer_type_ == other.pointer_type_ && |
| 109 pointer_region_ == other.pointer_region_; | 109 pointer_region_ == other.pointer_region_; |
| 110 } | 110 } |
| 111 | 111 |
| 112 } // namespace ws | 112 } // namespace ws |
| 113 } // namespace mus | 113 } // namespace mus |
| OLD | NEW |