From 7878bad42c0fd1d51a667aa9697d4f0d923493b0 Mon Sep 17 00:00:00 2001 From: "sadrul@chromium.org" Date: Tue, 21 Jan 2014 18:13:09 +0000 Subject: 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 --- ash/autoclick/autoclick_controller.cc | 3 ++- ash/autoclick/autoclick_unittest.cc | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'ash/autoclick') 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 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 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 -- cgit v1.1