Commit 265353f0 authored by Mitsuru Oshima's avatar Mitsuru Oshima Committed by Commit Bot

Update which window the mouse is physically on

This fixes the regression in crrev.com/c/1826666.

Bug: 1019737
Test: covered by unittest
Change-Id: I45401bb8c482d763991ca34f51537f2a5a6889e6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1893511
Auto-Submit: Mitsuru Oshima <oshima@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarkylechar <kylechar@chromium.org>
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#711786}
parent 75fb4297
......@@ -248,10 +248,22 @@ TEST_F(X11WindowOzoneTest, MouseEnterAndDelete) {
EXPECT_CALL(delegate_2, OnMouseEnter()).Times(1);
window_manager()->MouseOnWindow(static_cast<X11WindowOzone*>(window_2.get()));
// Removing the window should reset the |window_mouse_currently_on_|.
EXPECT_EQ(window_2.get(),
window_manager()->window_mouse_currently_on_for_test());
window_2.reset();
// Dispatch Event on window 1 while event is captured on window 2.
::testing::Mock::VerifyAndClearExpectations(&delegate_1);
EXPECT_CALL(delegate_1, OnMouseEnter()).Times(1);
window_2->SetCapture();
ScopedXI2Event xi_event;
xi_event.InitGenericButtonEvent(kPointerDeviceId, ET_MOUSE_PRESSED,
gfx::Point(0, 0), EF_NONE);
DispatchXEvent(xi_event, widget_1);
EXPECT_EQ(window_1.get(),
window_manager()->window_mouse_currently_on_for_test());
// Removing the window should reset the |window_mouse_currently_on_|.
window_1.reset();
EXPECT_FALSE(window_manager()->window_mouse_currently_on_for_test());
}
......
......@@ -476,6 +476,13 @@ uint32_t X11Window::DispatchEvent(const PlatformEvent& event) {
ProcessEvent(event);
return POST_DISPATCH_STOP_PROPAGATION;
#else
// Notify that the mouse gets physically entered to the window regardless of
// the grab. This is used to update the mouse cursor state.
auto* window_manager = X11WindowManager::GetInstance();
DCHECK(window_manager);
if (event->IsMouseEvent())
window_manager->MouseOnWindow(this);
OnXWindowEvent(event);
return POST_DISPATCH_STOP_PROPAGATION;
#endif
......@@ -565,9 +572,6 @@ void X11Window::OnXWindowEvent(ui::Event* event) {
return;
}
if (event->IsMouseEvent())
window_manager->MouseOnWindow(this);
#if defined(USE_OZONE)
DispatchEventFromNativeUiEvent(
event, base::BindOnce(&PlatformWindowDelegate::DispatchEvent,
......
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