From 4e6c558bf23838eea239d30d02df164b799d7e51 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Tue, 27 Oct 2020 14:43:10 -0400 Subject: [PATCH] Windows: Fix focus assignment when clicking WebView with external parent (fixes issue #3031) --- patch/patch.cfg | 5 ++++- ...565_1677_1749.patch => views_widget.patch} | 20 ++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) rename patch/patches/{views_widget_180_1481_1565_1677_1749.patch => views_widget.patch} (96%) diff --git a/patch/patch.cfg b/patch/patch.cfg index c6cfbc2b8..6dee29049 100644 --- a/patch/patch.cfg +++ b/patch/patch.cfg @@ -103,7 +103,10 @@ patches = [ # # Support configuration of RWHVGuest device scale factor. # https://bitbucket.org/chromiumembedded/cef/issues/2078 - 'name': 'views_widget_180_1481_1565_1677_1749', + # + # Windows: Fix focus assignment when clicking WebView with external parent. + # https://bitbucket.org/chromiumembedded/cef/issues/3031 + 'name': 'views_widget', }, { # Allow specification of a custom WebContentsView. diff --git a/patch/patches/views_widget_180_1481_1565_1677_1749.patch b/patch/patches/views_widget.patch similarity index 96% rename from patch/patches/views_widget_180_1481_1565_1677_1749.patch rename to patch/patches/views_widget.patch index c617bbbd2..48ff9c85d 100644 --- a/patch/patches/views_widget_180_1481_1565_1677_1749.patch +++ b/patch/patches/views_widget.patch @@ -73,7 +73,7 @@ index 5b2aa87a53fa..302626b947c6 100644 FRIEND_TEST_ALL_PREFIXES( BrowserSideFlingBrowserTest, diff --git content/browser/renderer_host/render_widget_host_view_event_handler.cc content/browser/renderer_host/render_widget_host_view_event_handler.cc -index b49d2f96efec..080a49940263 100644 +index b49d2f96efec..d6308880de1b 100644 --- content/browser/renderer_host/render_widget_host_view_event_handler.cc +++ content/browser/renderer_host/render_widget_host_view_event_handler.cc @@ -37,6 +37,10 @@ @@ -102,6 +102,24 @@ index b49d2f96efec..080a49940263 100644 #endif synthetic_move_position_ = center_in_screen; } +@@ -985,6 +997,17 @@ bool RenderWidgetHostViewEventHandler::MatchesSynthesizedMovePosition( + } + + void RenderWidgetHostViewEventHandler::SetKeyboardFocus() { ++#if defined(OS_WIN) ++ if (host_view_->HasExternalParent() && ++ window_ && window_->delegate()->CanFocus()) { ++ aura::WindowTreeHost* host = window_->GetHost(); ++ if (host) { ++ gfx::AcceleratedWidget hwnd = host->GetAcceleratedWidget(); ++ if (!(::GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_NOACTIVATE)) ++ ::SetFocus(hwnd); ++ } ++ } ++#endif + // TODO(wjmaclean): can host_ ever be null? + if (host_ && set_focus_on_mouse_down_or_key_event_) { + set_focus_on_mouse_down_or_key_event_ = false; diff --git content/public/browser/render_widget_host_view.h content/public/browser/render_widget_host_view.h index beba7a3a40b8..941acdfbff8b 100644 --- content/public/browser/render_widget_host_view.h