summaryrefslogtreecommitdiffstats
path: root/ui/views
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-04 06:32:43 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-04 06:32:43 +0000
commit9aaa6bd8687e4b3f831b07ec2bea2c5b0fd0f732 (patch)
tree7b75f9cb501097ceed0878b2a2b3dca02fccab94 /ui/views
parentc5707ee6e2afe3d2c40b28b62f8d55dd7885a808 (diff)
downloadchromium_src-9aaa6bd8687e4b3f831b07ec2bea2c5b0fd0f732.zip
chromium_src-9aaa6bd8687e4b3f831b07ec2bea2c5b0fd0f732.tar.gz
chromium_src-9aaa6bd8687e4b3f831b07ec2bea2c5b0fd0f732.tar.bz2
Don't show cursor on mouse enter/exit as they can be generated when host window is created/removed.
BUG=none TEST=covered by test. Review URL: https://chromiumcodereview.appspot.com/22051002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@215531 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views')
-rw-r--r--ui/views/corewm/compound_event_filter.cc5
-rw-r--r--ui/views/corewm/compound_event_filter_unittest.cc39
2 files changed, 43 insertions, 1 deletions
diff --git a/ui/views/corewm/compound_event_filter.cc b/ui/views/corewm/compound_event_filter.cc
index 78f988a..418e489 100644
--- a/ui/views/corewm/compound_event_filter.cc
+++ b/ui/views/corewm/compound_event_filter.cc
@@ -169,8 +169,11 @@ void CompoundEventFilter::FilterTouchEvent(ui::TouchEvent* event) {
void CompoundEventFilter::SetCursorVisibilityOnEvent(aura::Window* target,
ui::Event* event,
bool show) {
- if (event->flags() & ui::EF_IS_SYNTHESIZED)
+ if (event->flags() & ui::EF_IS_SYNTHESIZED ||
+ event->type() == ui::ET_MOUSE_ENTERED ||
+ event->type() == ui::ET_MOUSE_EXITED) {
return;
+ }
aura::client::CursorClient* client =
aura::client::GetCursorClient(target->GetRootWindow());
if (!client)
diff --git a/ui/views/corewm/compound_event_filter_unittest.cc b/ui/views/corewm/compound_event_filter_unittest.cc
index e179bde..9d8bd5a 100644
--- a/ui/views/corewm/compound_event_filter_unittest.cc
+++ b/ui/views/corewm/compound_event_filter_unittest.cc
@@ -48,6 +48,45 @@ class ConsumeGestureEventFilter : public ui::EventHandler {
typedef aura::test::AuraTestBase CompoundEventFilterTest;
+TEST_F(CompoundEventFilterTest, CursorVisibilityChange) {
+ scoped_ptr<CompoundEventFilter> compound_filter(new CompoundEventFilter);
+ aura::Env::GetInstance()->AddPreTargetHandler(compound_filter.get());
+ aura::test::TestWindowDelegate delegate;
+ scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(&delegate, 1234,
+ gfx::Rect(5, 5, 100, 100), root_window()));
+ window->Show();
+ window->SetCapture();
+
+ aura::test::TestCursorClient cursor_client(root_window());
+
+ // Send key event to hide the cursor.
+ ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_A, 0, true);
+ root_window()->AsRootWindowHostDelegate()->OnHostKeyEvent(&key);
+ EXPECT_FALSE(cursor_client.IsCursorVisible());
+
+ // Mouse enter event should not show the cursor.
+ ui::MouseEvent enter(ui::ET_MOUSE_ENTERED, gfx::Point(10, 10),
+ gfx::Point(10, 10), 0);
+ root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent(&enter);
+ EXPECT_FALSE(cursor_client.IsCursorVisible());
+
+ // Mouse move event will show the cursor.
+ ui::MouseEvent move(ui::ET_MOUSE_MOVED, gfx::Point(10, 10),
+ gfx::Point(10, 10), 0);
+ root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent(&move);
+ EXPECT_TRUE(cursor_client.IsCursorVisible());
+
+ // Send key event to hide the cursor again.
+ root_window()->AsRootWindowHostDelegate()->OnHostKeyEvent(&key);
+ EXPECT_FALSE(cursor_client.IsCursorVisible());
+
+ // Mouse exit event should not show the cursor.
+ ui::MouseEvent exit(ui::ET_MOUSE_EXITED, gfx::Point(10, 10),
+ gfx::Point(10, 10), 0);
+ root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent(&exit);
+ EXPECT_FALSE(cursor_client.IsCursorVisible());
+}
+
TEST_F(CompoundEventFilterTest, TouchHidesCursor) {
scoped_ptr<CompoundEventFilter> compound_filter(new CompoundEventFilter);
aura::Env::GetInstance()->AddPreTargetHandler(compound_filter.get());