diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-21 18:13:09 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-21 18:13:09 +0000 |
commit | 7878bad42c0fd1d51a667aa9697d4f0d923493b0 (patch) | |
tree | 1003be661467f36cfaa7816ee842f7b545f93a49 /ash/autoclick | |
parent | d9905a8a12fd44a62148d2254010c01c435418dd (diff) | |
download | chromium_src-7878bad42c0fd1d51a667aa9697d4f0d923493b0.zip chromium_src-7878bad42c0fd1d51a667aa9697d4f0d923493b0.tar.gz chromium_src-7878bad42c0fd1d51a667aa9697d4f0d923493b0.tar.bz2 |
autoclick: Ignore synthetic mouse-move events,
Synthetic mouse-move events are generated on various occasions (e.g. when
a window shows up, hides, moves, or transforms). Ignore these events for
autoclick.
BUG=none
R=jamescook@chromium.org, tengs@chromium.org
Review URL: https://codereview.chromium.org/142463002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@246075 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/autoclick')
-rw-r--r-- | ash/autoclick/autoclick_controller.cc | 3 | ||||
-rw-r--r-- | ash/autoclick/autoclick_unittest.cc | 20 |
2 files changed, 22 insertions, 1 deletions
diff --git a/ash/autoclick/autoclick_controller.cc b/ash/autoclick/autoclick_controller.cc index 6638b6d..c72d88a 100644 --- a/ash/autoclick/autoclick_controller.cc +++ b/ash/autoclick/autoclick_controller.cc @@ -122,7 +122,8 @@ void AutoclickControllerImpl::InitClickTimer() { } void AutoclickControllerImpl::OnMouseEvent(ui::MouseEvent* event) { - if (event->type() == ui::ET_MOUSE_MOVED) { + if (event->type() == ui::ET_MOUSE_MOVED && + !(event->flags() & ui::EF_IS_SYNTHESIZED)) { mouse_event_flags_ = event->flags(); gfx::Point mouse_location = event->root_location(); diff --git a/ash/autoclick/autoclick_unittest.cc b/ash/autoclick/autoclick_unittest.cc index 5151a9a7..4310b1e 100644 --- a/ash/autoclick/autoclick_unittest.cc +++ b/ash/autoclick/autoclick_unittest.cc @@ -7,6 +7,7 @@ #include "ash/test/ash_test_base.h" #include "ui/aura/root_window.h" #include "ui/aura/test/event_generator.h" +#include "ui/aura/test/test_window_delegate.h" #include "ui/aura/window.h" #include "ui/events/event.h" #include "ui/events/event_constants.h" @@ -287,4 +288,23 @@ TEST_F(AutoclickTest, UserInputCancelsAutoclick) { EXPECT_EQ(0u, events.size()); } +TEST_F(AutoclickTest, SynthesizedMouseMovesIgnored) { + GetAutoclickController()->SetEnabled(true); + std::vector<ui::MouseEvent> events; + GetEventGenerator().MoveMouseTo(100, 100); + events = WaitForMouseEvents(); + EXPECT_EQ(2u, events.size()); + + // Show a window and make sure the new window is under the cursor. As a + // result, synthesized mouse events will be dispatched to the window, but it + // should not trigger an autoclick. + aura::test::EventCountDelegate delegate; + scoped_ptr<aura::Window> window(CreateTestWindowInShellWithDelegate( + &delegate, 123, gfx::Rect(50, 50, 100, 100))); + window->Show(); + events = WaitForMouseEvents(); + EXPECT_EQ(0u, events.size()); + EXPECT_EQ("1 1 0", delegate.GetMouseMotionCountsAndReset()); +} + } // namespace ash |