diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-17 20:03:59 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-17 20:03:59 +0000 |
commit | bba44ab86413595a9e80d298426baddce3984aeb (patch) | |
tree | eddeb81991ab93f6fe6d327a07fb48c0e5199a52 /ash | |
parent | da8adfd3e38ca18f9f957240c0e40d8ec750552e (diff) | |
download | chromium_src-bba44ab86413595a9e80d298426baddce3984aeb.zip chromium_src-bba44ab86413595a9e80d298426baddce3984aeb.tar.gz chromium_src-bba44ab86413595a9e80d298426baddce3984aeb.tar.bz2 |
Don't set focus if the click target is already activated.
BUG=110117
TEST=test case added in ActivateOnMouse
Review URL: http://codereview.chromium.org/9198001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117942 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/wm/root_window_event_filter.cc | 2 | ||||
-rw-r--r-- | ash/wm/root_window_event_filter_unittest.cc | 35 |
2 files changed, 27 insertions, 10 deletions
diff --git a/ash/wm/root_window_event_filter.cc b/ash/wm/root_window_event_filter.cc index 564033f..f8a1269 100644 --- a/ash/wm/root_window_event_filter.cc +++ b/ash/wm/root_window_event_filter.cc @@ -87,7 +87,7 @@ bool RootWindowEventFilter::PreHandleMouseEvent(aura::Window* target, if (FilterMouseEvent(target, event)) return true; - if (event->type() == ui::ET_MOUSE_PRESSED) + if (event->type() == ui::ET_MOUSE_PRESSED && GetActiveWindow() != target) target->GetFocusManager()->SetFocusedWindow(target); return false; diff --git a/ash/wm/root_window_event_filter_unittest.cc b/ash/wm/root_window_event_filter_unittest.cc index f664e3f..94e6cbb 100644 --- a/ash/wm/root_window_event_filter_unittest.cc +++ b/ash/wm/root_window_event_filter_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -133,11 +133,11 @@ TEST_F(RootWindowEventFilterTest, ActivateOnMouse) { TestActivationDelegate d1; aura::test::TestWindowDelegate wd; scoped_ptr<aura::Window> w1(aura::test::CreateTestWindowWithDelegate( - &wd, 1, gfx::Rect(10, 10, 50, 50), NULL)); + &wd, -1, gfx::Rect(10, 10, 50, 50), NULL)); d1.SetWindow(w1.get()); TestActivationDelegate d2; scoped_ptr<aura::Window> w2(aura::test::CreateTestWindowWithDelegate( - &wd, 2, gfx::Rect(70, 70, 50, 50), NULL)); + &wd, -1, gfx::Rect(70, 70, 50, 50), NULL)); d2.SetWindow(w2.get()); aura::internal::FocusManager* focus_manager = w1->GetFocusManager(); @@ -155,9 +155,7 @@ TEST_F(RootWindowEventFilterTest, ActivateOnMouse) { { // Click on window2. - gfx::Point press_point = w2->bounds().CenterPoint(); - aura::Window::ConvertPointToWindow(w2->parent(), root_window, &press_point); - aura::test::EventGenerator generator(press_point); + aura::test::EventGenerator generator(w2.get()); generator.ClickLeftButton(); // Window2 should have become active. @@ -173,9 +171,7 @@ TEST_F(RootWindowEventFilterTest, ActivateOnMouse) { { // Click back on window1, but set it up so w1 doesn't activate on click. - gfx::Point press_point = w1->bounds().CenterPoint(); - aura::Window::ConvertPointToWindow(w1->parent(), root_window, &press_point); - aura::test::EventGenerator generator(press_point); + aura::test::EventGenerator generator(w1.get()); d1.set_activate(false); generator.ClickLeftButton(); @@ -199,6 +195,27 @@ TEST_F(RootWindowEventFilterTest, ActivateOnMouse) { EXPECT_EQ(w1.get(), focus_manager->GetFocusedWindow()); EXPECT_EQ(1, d1.activated_count()); EXPECT_EQ(0, d1.lost_active_count()); + + // Clicking an active window with a child shouldn't steal the + // focus from the child. + scoped_ptr<aura::Window> w11(CreateTestWindowWithDelegate( + &wd, -1, gfx::Rect(10, 10, 10, 10), w1.get())); + { + aura::test::EventGenerator generator(w11.get()); + // First set the focus to the child |w11|. + generator.ClickLeftButton(); + EXPECT_EQ(w11.get(), focus_manager->GetFocusedWindow()); + EXPECT_EQ(w1.get(), GetActiveWindow()); + + // Then click the parent active window. The focus shouldn't move. + gfx::Point left_top = w1->bounds().origin(); + aura::Window::ConvertPointToWindow(w1->parent(), root_window, &left_top); + left_top.Offset(1, 1); + generator.MoveMouseTo(left_top); + generator.ClickLeftButton(); + EXPECT_EQ(w11.get(), focus_manager->GetFocusedWindow()); + EXPECT_EQ(w1.get(), GetActiveWindow()); + } } // Essentially the same as ActivateOnMouse, but for touch events. |