diff options
Diffstat (limited to 'ui')
-rw-r--r-- | ui/wm/core/focus_controller.cc | 7 | ||||
-rw-r--r-- | ui/wm/core/focus_controller_unittest.cc | 28 |
2 files changed, 19 insertions, 16 deletions
diff --git a/ui/wm/core/focus_controller.cc b/ui/wm/core/focus_controller.cc index 66c6deb..722f6c8 100644 --- a/ui/wm/core/focus_controller.cc +++ b/ui/wm/core/focus_controller.cc @@ -108,13 +108,6 @@ void FocusController::FocusWindow(aura::Window* window) { return; } - // We should not be messing with the focus if the window has capture, unless - // no has focus. - if (window && (aura::client::GetCaptureWindow(window) == window) && - focused_window_) { - return; - } - // Focusing a window also activates its containing activatable window. Note // that the rules could redirect activation activation and/or focus. aura::Window* focusable = rules_->GetFocusableWindow(window); diff --git a/ui/wm/core/focus_controller_unittest.cc b/ui/wm/core/focus_controller_unittest.cc index 6cb5604..a773821 100644 --- a/ui/wm/core/focus_controller_unittest.cc +++ b/ui/wm/core/focus_controller_unittest.cc @@ -472,7 +472,7 @@ class FocusControllerTestBase : public aura::test::AuraTestBase { virtual void ShiftFocusOnActivation() {} virtual void ShiftFocusOnActivationDueToHide() {} virtual void NoShiftActiveOnActivation() {} - virtual void NoFocusChangeOnClickOnCaptureWindow() {} + virtual void FocusChangeDuringDrag() {} virtual void ChangeFocusWhenNothingFocusedAndCaptured() {} virtual void DontPassDeletedWindow() {} virtual void FocusedTextInputClient() {} @@ -752,24 +752,35 @@ class FocusControllerDirectTestBase : public FocusControllerTestBase { // from being made in response to an activation change notification. } - void NoFocusChangeOnClickOnCaptureWindow() override { + void FocusChangeDuringDrag() override { scoped_ptr<aura::client::DefaultCaptureClient> capture_client( new aura::client::DefaultCaptureClient(root_window())); - // Clicking on a window which has capture should not cause a focus change - // to the window. This test verifies whether that is indeed the case. + // Activating an inactive window during drag should activate the window. + // This emulates the behavior of tab dragging which is merged into the + // window below. ActivateWindowById(1); EXPECT_EQ(1, GetActiveWindowId()); EXPECT_EQ(1, GetFocusedWindowId()); aura::Window* w2 = root_window()->GetChildById(2); - aura::client::GetCaptureClient(root_window())->SetCapture(w2); ui::test::EventGenerator generator(root_window(), w2); - generator.ClickLeftButton(); + generator.PressLeftButton(); + aura::client::GetCaptureClient(root_window())->SetCapture(w2); + EXPECT_EQ(2, GetActiveWindowId()); + EXPECT_EQ(2, GetFocusedWindowId()); + generator.MoveMouseTo(gfx::Point(0, 0)); + // Emulate the behavior of merging a tab into an inactive window: + // transferring the mouse capture and activate the window. + aura::Window* w1 = root_window()->GetChildById(1); + aura::client::GetCaptureClient(root_window())->SetCapture(w1); + aura::client::GetActivationClient(root_window())->ActivateWindow(w1); EXPECT_EQ(1, GetActiveWindowId()); EXPECT_EQ(1, GetFocusedWindowId()); - aura::client::GetCaptureClient(root_window())->ReleaseCapture(w2); + + generator.ReleaseLeftButton(); + aura::client::GetCaptureClient(root_window())->ReleaseCapture(w1); } // Verifies focus change is honored while capture held. @@ -1256,8 +1267,7 @@ DIRECT_FOCUS_CHANGE_TESTS(ShiftFocusOnActivation); DIRECT_FOCUS_CHANGE_TESTS(ShiftFocusOnActivationDueToHide); DIRECT_FOCUS_CHANGE_TESTS(NoShiftActiveOnActivation); -// Clicking on a window which has capture should not result in a focus change. -DIRECT_FOCUS_CHANGE_TESTS(NoFocusChangeOnClickOnCaptureWindow); +FOCUS_CONTROLLER_TEST(FocusControllerApiTest, FocusChangeDuringDrag); FOCUS_CONTROLLER_TEST(FocusControllerApiTest, ChangeFocusWhenNothingFocusedAndCaptured); |