diff options
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_; |