From c6058c3e1f9a4118c88bf487e6c5a3fe2f562269 Mon Sep 17 00:00:00 2001 From: Bret Sepulveda Date: Fri, 12 Oct 2018 00:36:13 +0000 Subject: [PATCH] Mark touch released events handled by default on Windows. 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 Reviewed-by: Scott Violet Cr-Commit-Position: refs/heads/master@{#599037} --- ui/views/win/hwnd_message_handler.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc index 9afbcf6ca30a6..8cb2c191bbe29 100644 --- a/ui/views/win/hwnd_message_handler.cc +++ b/ui/views/win/hwnd_message_handler.cc @@ -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; }