diff options
author | afakhry <afakhry@chromium.org> | 2015-05-04 16:27:27 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-04 23:28:14 +0000 |
commit | 404d0118fa4c40676cbd2f6da3e5ba5d62f39b61 (patch) | |
tree | af9b8af96102ec9b56e888d289c65041935479fe /ui | |
parent | fe491f7956d0ecbb02ee163f7ad01ec47b388206 (diff) | |
download | chromium_src-404d0118fa4c40676cbd2f6da3e5ba5d62f39b61.zip chromium_src-404d0118fa4c40676cbd2f6da3e5ba5d62f39b61.tar.gz chromium_src-404d0118fa4c40676cbd2f6da3e5ba5d62f39b61.tar.bz2 |
Converting (Alt+LeftClick -> RightClick) to (Search+LeftClick -> RightClick)
Some web apps have behaviors for Alt+LeftClick so we had to do this
conversion.
However this change will result in popping up the AppList whenever
Search+Click is pressed and then search is released while in a web
app that consumes the Search+Click by showing a context menu and
then prevents default. This context menu differs from the native
context menu in that it doesn't have its own MenuEventDispatcher.
So the Search release event is passed to the accelerator controller
and then the controller thinks the both current and previous
accelerators are the "Search" key.
We had to fix this by listening to mouse events in the AcceleratorFilter
and then clear the current accelerator in the accelerator history.
BUG=248762
TEST=unit_tests --gtest_filter=EventRewriterTest.*
Review URL: https://codereview.chromium.org/1117173003
Cr-Commit-Position: refs/heads/master@{#328213}
Diffstat (limited to 'ui')
-rw-r--r-- | ui/base/accelerators/accelerator_history.h | 5 | ||||
-rw-r--r-- | ui/wm/core/accelerator_filter.cc | 13 | ||||
-rw-r--r-- | ui/wm/core/accelerator_filter.h | 3 |
3 files changed, 18 insertions, 3 deletions
diff --git a/ui/base/accelerators/accelerator_history.h b/ui/base/accelerators/accelerator_history.h index 435e752..4b0f51a 100644 --- a/ui/base/accelerators/accelerator_history.h +++ b/ui/base/accelerators/accelerator_history.h @@ -25,8 +25,9 @@ class UI_BASE_EXPORT AcceleratorHistory { return current_accelerator_; } - // Returns the most recent previously recorded accelerator that is different - // than the current. + // Returns the most recent previously recorded key accelerator that is + // different than the current. Non-synthesized mouse events will be stored + // in the histroy as an empty accelerator. const Accelerator& previous_accelerator() const { return previous_accelerator_; } diff --git a/ui/wm/core/accelerator_filter.cc b/ui/wm/core/accelerator_filter.cc index 12e9131..b2d1120 100644 --- a/ui/wm/core/accelerator_filter.cc +++ b/ui/wm/core/accelerator_filter.cc @@ -71,6 +71,19 @@ void AcceleratorFilter::OnKeyEvent(ui::KeyEvent* event) { event->StopPropagation(); } +void AcceleratorFilter::OnMouseEvent(ui::MouseEvent* event) { + // When a mouse event is interleaved between two key accelerators, we must + // store this event as an empty default accelerator in the accelerator + // history, so that the |AcceleratorController| can notice that something + // actually happened between those two key accelerators. + // Non-real synthesized mouse events should be ignored because we don't want + // them to interfere with tracking the key accelerator. + if (event->flags() & ui::EF_IS_SYNTHESIZED) + return; + + accelerator_history_->StoreCurrentAccelerator(ui::Accelerator()); +} + ui::Accelerator CreateAcceleratorFromKeyEvent(const ui::KeyEvent& key_event) { const int kModifierFlagMask = (ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN); diff --git a/ui/wm/core/accelerator_filter.h b/ui/wm/core/accelerator_filter.h index 79317e1..d98a39c 100644 --- a/ui/wm/core/accelerator_filter.h +++ b/ui/wm/core/accelerator_filter.h @@ -28,8 +28,9 @@ class WM_EXPORT AcceleratorFilter : public ui::EventHandler { ui::AcceleratorHistory* accelerator_history); ~AcceleratorFilter() override; - // Overridden from ui::EventHandler: + // ui::EventHandler: void OnKeyEvent(ui::KeyEvent* event) override; + void OnMouseEvent(ui::MouseEvent* event) override; private: scoped_ptr<AcceleratorDelegate> delegate_; |