Skip to content

Commit

Permalink
Reset Cursor type when pointer exits
Browse files Browse the repository at this point in the history
If user places the pointer/mouse on any end of a browser window, cursor
type changes accordingly, to indicated a possible interactive resize operation.

If the user crosses the browser window bounds through the same end, the mouse
type stored in ui::CursorManager isn't reset. If pointer reenters the
window through the same end, Aura tries to set the cursor type to the
same as previously (to indicate it is over the same end). During the
call chain, CursorManager::SetCursor compares the last Cursor stored
and the new one and updates the cursor instance if they differ.

In case of regular Chrome/x11 builds, the check passes because
CursorData is set to the Cursor instance, and values always differ
from the CursorData cached by CursorManager.
In case of Linux/Ozone builds, CursorData is only set on Ozone side,
so the call bail out and cursor is not updated.

Patch fixes it by resetting the cursor type whenever pointer leaves
the browser window. This ensures, when reentering from the same end, the
comparison in CursorManager::SetCursor passes, and cursor gets updated.

Issue Igalia#317
  • Loading branch information
tonikitoo committed Dec 4, 2017
1 parent 2bbae11 commit b5a3e52
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions ui/wm/core/compound_event_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,18 @@ void CompoundEventFilter::UpdateCursor(aura::Window* target,
aura::client::CursorClient* cursor_client =
aura::client::GetCursorClient(root_window);
if (cursor_client) {
// In some configurations, notably Linux/Ozone, cursor data are only
// set in Ozone side. This makes the check in CursorManager::SetCursor
// unreliable and fail in some circumstances where it passes on regular
// Linux/X11 builds.
// To make sure, cursor is properly set when it reenters a browser window
// through the same end, we reset it when it exits, otherwise the check in
// CursorManager::SetCursor will comparent Cursors of the same type.
if (event->type() == ui::ET_MOUSE_EXITED) {
cursor_client->SetCursor(ui::CursorType::kPointer);
return;
}

gfx::NativeCursor cursor = target->GetCursor(event->location());
if ((event->flags() & ui::EF_IS_NON_CLIENT)) {
if (target->delegate()) {
Expand Down Expand Up @@ -196,11 +208,14 @@ void CompoundEventFilter::OnMouseEvent(ui::MouseEvent* event) {
// on Desktop for testing, or a bug in pointer barrier).
if (!(event->flags() & ui::EF_FROM_TOUCH) &&
(event->type() == ui::ET_MOUSE_ENTERED ||
event->type() == ui::ET_MOUSE_EXITED ||
event->type() == ui::ET_MOUSE_MOVED ||
event->type() == ui::ET_MOUSE_PRESSED ||
event->type() == ui::ET_MOUSEWHEEL)) {
SetMouseEventsEnableStateOnEvent(window, event, true);
SetCursorVisibilityOnEvent(window, event, true);
if (event->type() != ui::ET_MOUSE_EXITED) {
SetMouseEventsEnableStateOnEvent(window, event, true);
SetCursorVisibilityOnEvent(window, event, true);
}
UpdateCursor(window, event);
}

Expand Down

0 comments on commit b5a3e52

Please sign in to comment.