Skip to content

Commit

Permalink
Mark touch released events handled by default on Windows.
Browse files Browse the repository at this point in the history
When a touch event is not handled, WindowEventDispatcher will generate
gesture events from it. However, when those gesture events are marked as
handled that handling doesn't propagate back to the original touch
event.

For bug 852241, the hamburger menu only handles gesture events. On
Windows, selecting an option with a touch would cause the hamburger menu
to close, but because the touch event wasn't marked as handled Windows
would pass it along to the underlying window, causing it to gain focus.
Most of the time it would be gaining focus anyway (since the hamburger
menu just closed) so this isn't noticeable, but the Cast dialog is a
newly-added surface that closes if it loses focus. In this case, it
seems to not appear at all.

Similarly for bug 866421, when the guest window becomes restored it
reveals the window underneath and then Windows passes the event along,
giving it focus.

This patch marks all touch released as handled by default, which
prevents Windows from ever propagating them. These events generate the
tap gestures that cause the state change in the hamburger menu and
window size in the above bugs.

Bug: 852241, 866421
Change-Id: I10a67d56fdc46d5b91282e0f395c895339f71951
Reviewed-on: https://chromium-review.googlesource.com/c/1260507
Commit-Queue: Bret Sepulveda <[email protected]>
Reviewed-by: Scott Violet <[email protected]>
Cr-Commit-Position: refs/heads/master@{#599037}
  • Loading branch information
bsep-chromium authored and Commit Bot committed Oct 12, 2018
1 parent 1ea750a commit c6058c3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ui/views/win/hwnd_message_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2988,7 +2988,10 @@ LRESULT HWNDMessageHandler::HandlePointerEventTypeTouch(UINT message,
if (event_type == ui::ET_TOUCH_RELEASED)
id_generator_.ReleaseNumber(pointer_id);

SetMsgHandled(event.handled());
// Mark all touch released events handled. These will usually turn into tap
// gestures, and doing this avoids propagating the event to other windows.
const bool always_mark_handled = event_type == ui::ET_TOUCH_RELEASED;
SetMsgHandled(always_mark_handled || event.handled());
}
return 0;
}
Expand Down

0 comments on commit c6058c3

Please sign in to comment.