| Index: components/mus/ws/event_dispatcher.cc
|
| diff --git a/components/mus/ws/event_dispatcher.cc b/components/mus/ws/event_dispatcher.cc
|
| index ead61660ad570645411ad7e55eec1f77a37ee403..eed987de4ad881598da5395c32cdef60f0ec426b 100644
|
| --- a/components/mus/ws/event_dispatcher.cc
|
| +++ b/components/mus/ws/event_dispatcher.cc
|
| @@ -58,11 +58,16 @@ class EventMatcher {
|
| public:
|
| explicit EventMatcher(const mojom::EventMatcher& matcher)
|
| : fields_to_match_(NONE),
|
| + accelerator_phase_(mojom::AcceleratorPhase::PRE_TARGET),
|
| event_type_(ui::ET_UNKNOWN),
|
| event_flags_(ui::EF_NONE),
|
| ignore_event_flags_(ui::EF_NONE),
|
| keyboard_code_(ui::VKEY_UNKNOWN),
|
| pointer_type_(ui::EventPointerType::POINTER_TYPE_UNKNOWN) {
|
| + if (matcher.accelerator_matcher) {
|
| + fields_to_match_ |= ACCELERATOR_PHASE;
|
| + accelerator_phase_ = matcher.accelerator_matcher->accelerator_phase;
|
| + }
|
| if (matcher.type_matcher) {
|
| fields_to_match_ |= TYPE;
|
| switch (matcher.type_matcher->type) {
|
| @@ -124,7 +129,10 @@ class EventMatcher {
|
|
|
| ~EventMatcher() {}
|
|
|
| - bool MatchesEvent(const ui::Event& event) const {
|
| + bool MatchesEvent(const ui::Event& event,
|
| + const mojom::AcceleratorPhase phase) const {
|
| + if ((fields_to_match_ & ACCELERATOR_PHASE) && accelerator_phase_ != phase)
|
| + return false;
|
| if ((fields_to_match_ & TYPE) && event.type() != event_type_)
|
| return false;
|
| int flags = event.flags() & ~ignore_event_flags_;
|
| @@ -154,6 +162,7 @@ class EventMatcher {
|
|
|
| bool Equals(const EventMatcher& matcher) const {
|
| return fields_to_match_ == matcher.fields_to_match_ &&
|
| + accelerator_phase_ == matcher.accelerator_phase_ &&
|
| event_type_ == matcher.event_type_ &&
|
| event_flags_ == matcher.event_flags_ &&
|
| ignore_event_flags_ == matcher.ignore_event_flags_ &&
|
| @@ -170,9 +179,11 @@ class EventMatcher {
|
| KEYBOARD_CODE = 1 << 2,
|
| POINTER_KIND = 1 << 3,
|
| POINTER_LOCATION = 1 << 4,
|
| + ACCELERATOR_PHASE = 1 << 5,
|
| };
|
|
|
| uint32_t fields_to_match_;
|
| + mojom::AcceleratorPhase accelerator_phase_;
|
| ui::EventType event_type_;
|
| // Bitfields of kEventFlag* and kMouseEventFlag* values in
|
| // input_event_constants.mojom.
|
| @@ -296,7 +307,8 @@ void EventDispatcher::ProcessEvent(const ui::Event& event) {
|
| const ui::KeyEvent* key_event = event.AsKeyEvent();
|
| if (event.type() == ui::ET_KEY_PRESSED && !key_event->is_char()) {
|
| uint32_t accelerator = 0u;
|
| - if (FindAccelerator(*key_event, &accelerator)) {
|
| + if (FindAccelerator(*key_event, mojom::AcceleratorPhase::PRE_TARGET,
|
| + &accelerator)) {
|
| delegate_->OnAccelerator(accelerator, event);
|
| return;
|
| }
|
| @@ -504,9 +516,10 @@ bool EventDispatcher::IsObservingWindow(ServerWindow* window) {
|
| }
|
|
|
| bool EventDispatcher::FindAccelerator(const ui::KeyEvent& event,
|
| + const mojom::AcceleratorPhase phase,
|
| uint32_t* accelerator_id) {
|
| for (const auto& pair : accelerators_) {
|
| - if (pair.second.MatchesEvent(event)) {
|
| + if (pair.second.MatchesEvent(event, phase)) {
|
| *accelerator_id = pair.first;
|
| return true;
|
| }
|
|
|