diff options
author | mazda@chromium.org <mazda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-04 21:39:30 +0000 |
---|---|---|
committer | mazda@chromium.org <mazda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-04 21:39:30 +0000 |
commit | 4e721741ebb5f584d23483bf1f5577dea2539f3c (patch) | |
tree | b952663a8fbddad65d4bb69062c0da762394e438 /ash | |
parent | bb986abf62f8a4bc98537b008c205c83f6940e34 (diff) | |
download | chromium_src-4e721741ebb5f584d23483bf1f5577dea2539f3c.zip chromium_src-4e721741ebb5f584d23483bf1f5577dea2539f3c.tar.gz chromium_src-4e721741ebb5f584d23483bf1f5577dea2539f3c.tar.bz2 |
Differentiate invisible cursor mode and disabled mouse events mode.
I made the cursor visibility and the mouse events enable state work as follows.
- Typing keys just hides the cursor and mouse events are not disabled (mouse hover state is not cleared)
- Scrolling a web page when the cursor is invisible disables mouse events.
- Touch events disable mouse events.
BUG=154979
TBR=jln@chromium.org
Review URL: https://codereview.chromium.org/11888003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@180528 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/shell.cc | 10 | ||||
-rw-r--r-- | ash/wm/session_state_controller_impl.cc | 4 | ||||
-rw-r--r-- | ash/wm/session_state_controller_impl2.cc | 6 | ||||
-rw-r--r-- | ash/wm/window_manager_unittest.cc | 80 |
4 files changed, 62 insertions, 38 deletions
diff --git a/ash/shell.cc b/ash/shell.cc index b788522..cd317d7 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -582,12 +582,14 @@ void Shell::Init() { user_wallpaper_delegate_->InitializeWallpaper(); if (initially_hide_cursor_) - cursor_manager_.DisableMouseEvents(); + cursor_manager_.HideCursor(); cursor_manager_.SetCursor(ui::kCursorPointer); - // Cursor might have been hidden by somethign other than chrome. - // Let the first mouse event show the cursor. - env_filter_->set_cursor_hidden_by_filter(true); + if (!cursor_manager_.IsCursorVisible()) { + // Cursor might have been hidden by something other than chrome. + // Let the first mouse event show the cursor. + env_filter_->set_cursor_hidden_by_filter(true); + } } void Shell::ShowContextMenu(const gfx::Point& location_in_screen) { diff --git a/ash/wm/session_state_controller_impl.cc b/ash/wm/session_state_controller_impl.cc index b31b29b6..7a54f35 100644 --- a/ash/wm/session_state_controller_impl.cc +++ b/ash/wm/session_state_controller_impl.cc @@ -52,7 +52,7 @@ void SessionStateControllerImpl::OnAppTerminating() { shutting_down_ = true; Shell* shell = ash::Shell::GetInstance(); shell->env_filter()->set_cursor_hidden_by_filter(false); - shell->cursor_manager()->DisableMouseEvents(); + shell->cursor_manager()->HideCursor(); animator_->StartAnimation( internal::SessionStateAnimator::kAllContainersMask, internal::SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, @@ -219,7 +219,7 @@ void SessionStateControllerImpl::RequestShutdownImpl() { Shell* shell = ash::Shell::GetInstance(); shell->env_filter()->set_cursor_hidden_by_filter(false); - shell->cursor_manager()->DisableMouseEvents(); + shell->cursor_manager()->HideCursor(); if (login_status_ != user::LOGGED_IN_NONE) { // Hide the other containers before starting the animation. diff --git a/ash/wm/session_state_controller_impl2.cc b/ash/wm/session_state_controller_impl2.cc index 6858a91..2a386a3 100644 --- a/ash/wm/session_state_controller_impl2.cc +++ b/ash/wm/session_state_controller_impl2.cc @@ -171,7 +171,7 @@ void SessionStateControllerImpl2::OnAppTerminating() { shutting_down_ = true; Shell* shell = ash::Shell::GetInstance(); shell->env_filter()->set_cursor_hidden_by_filter(false); - shell->cursor_manager()->DisableMouseEvents(); + shell->cursor_manager()->HideCursor(); animator_->StartAnimation( internal::SessionStateAnimator::kAllContainersMask, internal::SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY, @@ -279,7 +279,7 @@ void SessionStateControllerImpl2::RequestShutdownImpl() { Shell* shell = ash::Shell::GetInstance(); shell->env_filter()->set_cursor_hidden_by_filter(false); - shell->cursor_manager()->DisableMouseEvents(); + shell->cursor_manager()->HideCursor(); StartShutdownAnimationImpl(); } @@ -338,7 +338,7 @@ void SessionStateControllerImpl2::OnPreShutdownAnimationTimeout() { Shell* shell = ash::Shell::GetInstance(); shell->env_filter()->set_cursor_hidden_by_filter(false); - shell->cursor_manager()->DisableMouseEvents(); + shell->cursor_manager()->HideCursor(); StartRealShutdownTimer(false); } diff --git a/ash/wm/window_manager_unittest.cc b/ash/wm/window_manager_unittest.cc index bf1317a..b5ff1e1d 100644 --- a/ash/wm/window_manager_unittest.cc +++ b/ash/wm/window_manager_unittest.cc @@ -642,56 +642,78 @@ TEST_F(WindowManagerTest, AdditionalFilters) { // We should show and hide the cursor in response to mouse and touch events as // requested. TEST_F(WindowManagerTest, UpdateCursorVisibility) { - aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); - root_window->SetBounds(gfx::Rect(0, 0, 500, 500)); - scoped_ptr<aura::Window> window(CreateTestWindowInShell( - SK_ColorWHITE, -1, gfx::Rect(0, 0, 500, 500))); - + aura::test::EventGenerator& generator = GetEventGenerator(); ash::CursorManager* cursor_manager = ash::Shell::GetInstance()->cursor_manager(); - ui::MouseEvent mouse_moved( - ui::ET_MOUSE_MOVED, gfx::Point(0, 0), gfx::Point(0, 0), 0x0); - ui::TouchEvent touch_pressed1( - ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 0, getTime()); - ui::TouchEvent touch_pressed2( - ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 1, getTime()); - ui::TouchEvent touch_released1( - ui::ET_TOUCH_RELEASED, gfx::Point(0, 0), 0, getTime()); - ui::TouchEvent touch_released2( - ui::ET_TOUCH_RELEASED, gfx::Point(0, 0), 1, getTime()); - - root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved); + generator.MoveMouseTo(gfx::Point(0, 0)); EXPECT_TRUE(cursor_manager->IsCursorVisible()); - root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch_pressed1); + EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); + generator.PressTouch(); EXPECT_FALSE(cursor_manager->IsCursorVisible()); - root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved); + EXPECT_FALSE(cursor_manager->IsMouseEventsEnabled()); + generator.MoveMouseTo(gfx::Point(0, 0)); EXPECT_TRUE(cursor_manager->IsCursorVisible()); - root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch_released1); + EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); + generator.ReleaseTouch(); EXPECT_TRUE(cursor_manager->IsCursorVisible()); + EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); // If someone else made cursor invisible keep it invisible even after it // received mouse events. - cursor_manager->DisableMouseEvents(); - root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved); + cursor_manager->EnableMouseEvents(); + cursor_manager->HideCursor(); + generator.MoveMouseTo(gfx::Point(0, 0)); EXPECT_FALSE(cursor_manager->IsCursorVisible()); - root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch_pressed2); + EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); + generator.PressTouch(); EXPECT_FALSE(cursor_manager->IsCursorVisible()); - root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved); + EXPECT_FALSE(cursor_manager->IsMouseEventsEnabled()); + generator.MoveMouseTo(gfx::Point(0, 0)); EXPECT_FALSE(cursor_manager->IsCursorVisible()); - root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch_released2); + EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); + generator.ReleaseTouch(); EXPECT_FALSE(cursor_manager->IsCursorVisible()); + EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); // Back to normal. cursor_manager->EnableMouseEvents(); - root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved); + cursor_manager->ShowCursor(); + generator.MoveMouseTo(gfx::Point(0, 0)); + EXPECT_TRUE(cursor_manager->IsCursorVisible()); + EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); + generator.PressTouch(); + EXPECT_FALSE(cursor_manager->IsCursorVisible()); + EXPECT_FALSE(cursor_manager->IsMouseEventsEnabled()); + generator.MoveMouseTo(gfx::Point(0, 0)); + EXPECT_TRUE(cursor_manager->IsCursorVisible()); + EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); + generator.ReleaseTouch(); EXPECT_TRUE(cursor_manager->IsCursorVisible()); - root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch_pressed2); + EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); +} + +TEST_F(WindowManagerTest, UpdateCursorVisibilityOnKeyEvent) { + aura::test::EventGenerator& generator = GetEventGenerator(); + ash::CursorManager* cursor_manager = + ash::Shell::GetInstance()->cursor_manager(); + + // Pressing a key hides the cursor but does not disable mouse events. + generator.PressKey(ui::VKEY_A, ui::EF_NONE); EXPECT_FALSE(cursor_manager->IsCursorVisible()); - root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved); + EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); + // Moving mouse shows the cursor. + generator.MoveMouseTo(gfx::Point(0, 0)); EXPECT_TRUE(cursor_manager->IsCursorVisible()); - root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch_released2); + EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); + // Releasing a key also hides the cursor but does not disable mouse events. + generator.ReleaseKey(ui::VKEY_A, ui::EF_NONE); + EXPECT_FALSE(cursor_manager->IsCursorVisible()); + EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); + // Moving mouse shows the cursor again. + generator.MoveMouseTo(gfx::Point(0, 0)); EXPECT_TRUE(cursor_manager->IsCursorVisible()); + EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); } } // namespace ash |