diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-03 17:38:02 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-03 17:38:02 +0000 |
commit | 10f0b0f028472ec7670ffbab605d44744766236d (patch) | |
tree | f4b69353e2ec7bcb7bc1cdde12a223f73ee7aa26 /ui/aura/shared | |
parent | a4da9ea9376ab3dff1c2be4be4f2692b95be33f6 (diff) | |
download | chromium_src-10f0b0f028472ec7670ffbab605d44744766236d.zip chromium_src-10f0b0f028472ec7670ffbab605d44744766236d.tar.gz chromium_src-10f0b0f028472ec7670ffbab605d44744766236d.tar.bz2 |
aura: Fix hiding the cursor on touch events.
Touching on any window, whether currently active or not, should hide the
mouse cursor. This regressed in r147456.
BUG=140257
TEST=move the mouse to show the cursor, then touch the chrome window title. the cursor should become invisible.
Review URL: https://chromiumcodereview.appspot.com/10831135
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149870 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/aura/shared')
-rw-r--r-- | ui/aura/shared/compound_event_filter.cc | 16 | ||||
-rw-r--r-- | ui/aura/shared/compound_event_filter.h | 5 | ||||
-rw-r--r-- | ui/aura/shared/compound_event_filter_unittest.cc | 7 |
3 files changed, 20 insertions, 8 deletions
diff --git a/ui/aura/shared/compound_event_filter.cc b/ui/aura/shared/compound_event_filter.cc index 4bc8866..85cff86 100644 --- a/ui/aura/shared/compound_event_filter.cc +++ b/ui/aura/shared/compound_event_filter.cc @@ -103,7 +103,7 @@ bool CompoundEventFilter::PreHandleMouseEvent(aura::Window* target, if (event->type() == ui::ET_MOUSE_MOVED || event->type() == ui::ET_MOUSE_PRESSED || event->type() == ui::ET_MOUSEWHEEL) { - SetVisibilityOnEvent(target, event, true); + SetCursorVisibilityOnEvent(target, event, true); UpdateCursor(target, event); } @@ -125,7 +125,12 @@ bool CompoundEventFilter::PreHandleMouseEvent(aura::Window* target, ui::TouchStatus CompoundEventFilter::PreHandleTouchEvent( aura::Window* target, aura::TouchEvent* event) { - return FilterTouchEvent(target, event); + ui::TouchStatus status = FilterTouchEvent(target, event); + if (status == ui::TOUCH_STATUS_UNKNOWN && + event->type() == ui::ET_TOUCH_PRESSED) { + SetCursorVisibilityOnEvent(target, event, false); + } + return status; } ui::GestureStatus CompoundEventFilter::PreHandleGestureEvent( @@ -145,7 +150,6 @@ ui::GestureStatus CompoundEventFilter::PreHandleGestureEvent( event->details().touch_points() == 1 && target->GetRootWindow() && GetActiveWindow(target) != target) { - SetVisibilityOnEvent(target, event, false); target->GetFocusManager()->SetFocusedWindow( FindFocusableWindowFor(target), event); } @@ -211,9 +215,9 @@ ui::TouchStatus CompoundEventFilter::FilterTouchEvent( return status; } -void CompoundEventFilter::SetVisibilityOnEvent(aura::Window* target, - aura::LocatedEvent* event, - bool show) { +void CompoundEventFilter::SetCursorVisibilityOnEvent(aura::Window* target, + aura::LocatedEvent* event, + bool show) { if (update_cursor_visibility_ && !(event->flags() & ui::EF_IS_SYNTHESIZED)) { aura::client::CursorClient* client = aura::client::GetCursorClient(target->GetRootWindow()); diff --git a/ui/aura/shared/compound_event_filter.h b/ui/aura/shared/compound_event_filter.h index 6fe76be..f255dd6 100644 --- a/ui/aura/shared/compound_event_filter.h +++ b/ui/aura/shared/compound_event_filter.h @@ -68,8 +68,9 @@ class AURA_EXPORT CompoundEventFilter : public aura::EventFilter { // Sets the visibility of the cursor if the event is not synthesized and // |update_cursor_visibility_| is true. - void SetVisibilityOnEvent(aura::Window* target, aura::LocatedEvent* event, - bool show); + void SetCursorVisibilityOnEvent(aura::Window* target, + aura::LocatedEvent* event, + bool show); // Additional event filters that pre-handles events. ObserverList<aura::EventFilter, true> filters_; diff --git a/ui/aura/shared/compound_event_filter_unittest.cc b/ui/aura/shared/compound_event_filter_unittest.cc index 4709a97..85ee580 100644 --- a/ui/aura/shared/compound_event_filter_unittest.cc +++ b/ui/aura/shared/compound_event_filter_unittest.cc @@ -80,8 +80,15 @@ TEST_F(CompoundEventFilterTest, TouchHidesCursor) { root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); EXPECT_FALSE(cursor_client.IsCursorVisible()); + // Move the cursor again. The cursor should be visible. root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse); EXPECT_TRUE(cursor_client.IsCursorVisible()); + + // Now activate the window and press on it again. + aura::client::GetActivationClient( + root_window())->ActivateWindow(window.get()); + root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); + EXPECT_FALSE(cursor_client.IsCursorVisible()); } } // namespace test |