Commit 04be0abc authored by pkotwicz's avatar pkotwicz Committed by Commit bot

Do not hide the cursor on a key up

When pressing an accelerator, the user may release the modifier key first.
e.g. press Ctrl, press A, release Ctrl, release A
This CL prevents the cursor from being hidden in this scenario.

BUG=454902
TEST=WindowManagerTest.UpdateCursorVisibilityAccelerator

Review URL: https://codereview.chromium.org/960073002

Cr-Commit-Position: refs/heads/master@{#319885}
parent 22e9acc2
......@@ -21,6 +21,9 @@ CursorManager::~CursorManager() {
bool CursorManager::ShouldHideCursorOnKeyEvent(
const ui::KeyEvent& event) const {
if (event.type() != ui::ET_KEY_PRESSED)
return false;
// Clicking on a key when the accessibility virtual keyboard is enabled should
// not hide the cursor.
if (keyboard::GetAccessibilityKeyboardEnabled())
......
......@@ -770,16 +770,35 @@ TEST_F(WindowManagerTest, UpdateCursorVisibilityOnKeyEvent) {
generator.MoveMouseTo(gfx::Point(0, 0));
EXPECT_TRUE(cursor_manager->IsCursorVisible());
EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
// Releasing a key also hides the cursor but does not disable mouse events.
// Releasing a key does does not hide the cursor and 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());
}
// Test that pressing an accelerator does not hide the cursor.
TEST_F(WindowManagerTest, UpdateCursorVisibilityAccelerator) {
ui::test::EventGenerator& generator = GetEventGenerator();
::wm::CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager();
ASSERT_TRUE(cursor_manager->IsCursorVisible());
// Press Ctrl+A, release A first.
generator.PressKey(ui::VKEY_CONTROL, ui::EF_CONTROL_DOWN);
generator.PressKey(ui::VKEY_A, ui::EF_CONTROL_DOWN);
generator.ReleaseKey(ui::VKEY_A, ui::EF_CONTROL_DOWN);
generator.ReleaseKey(ui::VKEY_CONTROL, ui::EF_NONE);
EXPECT_TRUE(cursor_manager->IsCursorVisible());
// Press Ctrl+A, release Ctrl first.
generator.PressKey(ui::VKEY_CONTROL, ui::EF_CONTROL_DOWN);
generator.PressKey(ui::VKEY_A, ui::EF_CONTROL_DOWN);
generator.ReleaseKey(ui::VKEY_CONTROL, ui::EF_NONE);
generator.ReleaseKey(ui::VKEY_A, ui::EF_NONE);
EXPECT_TRUE(cursor_manager->IsCursorVisible());
}
TEST_F(WindowManagerTest, TestCursorClientObserver) {
ui::test::EventGenerator& generator = GetEventGenerator();
::wm::CursorManager* cursor_manager =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment