From 3010ee1ce68b7234d17daf0c45cad0df8cd1e498 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Tue, 4 Aug 2015 13:53:59 -0400 Subject: [PATCH] Windows: Fix focus/blur handling (issue #1677) --- patch/patch.cfg | 11 ++++++- patch/patches/aura_window_1677.patch | 32 +++++++++++++++++++ ..._180.patch => views_widget_180_1677.patch} | 9 ++++-- 3 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 patch/patches/aura_window_1677.patch rename patch/patches/{views_widget_180.patch => views_widget_180_1677.patch} (96%) diff --git a/patch/patch.cfg b/patch/patch.cfg index 49ab96d4b..ef643abaa 100644 --- a/patch/patch.cfg +++ b/patch/patch.cfg @@ -49,7 +49,9 @@ patches = [ { # Allow specification of a parent window handle for Widget creation. # https://code.google.com/p/chromiumembedded/issues/detail?id=180 - 'name': 'views_widget_180', + # Fix focus/blur handling on Windows. + # https://bitbucket.org/chromiumembedded/cef/issues/1677 + 'name': 'views_widget_180_1677', 'path': '../ui/views/widget/', }, { @@ -182,4 +184,11 @@ patches = [ 'name': 'hwnd_message_handler_1481', 'path': '../ui/views/win/', }, + { + # Fix focus/blur handling on Windows. + # https://bitbucket.org/chromiumembedded/cef/issues/1677 + # https://codereview.chromium.org/1135063002 (reverted) + 'name': 'aura_window_1677', + 'path': '../ui/aura/', + }, ] diff --git a/patch/patches/aura_window_1677.patch b/patch/patches/aura_window_1677.patch new file mode 100644 index 000000000..c126648a3 --- /dev/null +++ b/patch/patches/aura_window_1677.patch @@ -0,0 +1,32 @@ +diff --git window.cc window.cc +index 0c021f8..ec62e3e 100644 +--- window.cc ++++ window.cc +@@ -637,6 +637,12 @@ void Window::Focus() { + client->FocusWindow(this); + } + ++void Window::Blur() { ++ client::FocusClient* client = client::GetFocusClient(this); ++ DCHECK(client); ++ client->FocusWindow(NULL); ++} ++ + bool Window::HasFocus() const { + client::FocusClient* client = client::GetFocusClient(this); + return client && client->GetFocusedWindow() == this; +diff --git window.h window.h +index 749a66a..229a867 100644 +--- window.h ++++ window.h +@@ -262,8 +262,9 @@ class AURA_EXPORT Window : public ui::LayerDelegate, + // that has a delegate set). The toplevel window may be |this|. + Window* GetToplevelWindow(); + +- // Claims focus. ++ // Claims or relinquishes the claim to focus. + void Focus(); ++ void Blur(); + + // Returns true if the Window is currently the focused window. + bool HasFocus() const; diff --git a/patch/patches/views_widget_180.patch b/patch/patches/views_widget_180_1677.patch similarity index 96% rename from patch/patches/views_widget_180.patch rename to patch/patches/views_widget_180_1677.patch index 98bcf3fbc..8b9b69b9d 100644 --- a/patch/patches/views_widget_180.patch +++ b/patch/patches/views_widget_180_1677.patch @@ -12,7 +12,7 @@ index a8e088c..838b6a0 100644 return host ? host->GetAcceleratedWidget() : NULL; } diff --git desktop_aura/desktop_window_tree_host_win.cc desktop_aura/desktop_window_tree_host_win.cc -index 93b3c5b..e0e505e 100644 +index 93b3c5b..a0940ce 100644 --- desktop_aura/desktop_window_tree_host_win.cc +++ desktop_aura/desktop_window_tree_host_win.cc @@ -131,7 +131,9 @@ void DesktopWindowTreeHostWin::Init(aura::Window* content_window, @@ -26,7 +26,7 @@ index 93b3c5b..e0e505e 100644 parent_hwnd = params.parent->GetHost()->GetAcceleratedWidget(); message_handler_->set_remove_standard_frame(params.remove_standard_frame); -@@ -793,6 +795,7 @@ void DesktopWindowTreeHostWin::HandleFrameChanged() { +@@ -793,10 +795,12 @@ void DesktopWindowTreeHostWin::HandleFrameChanged() { void DesktopWindowTreeHostWin::HandleNativeFocus(HWND last_focused_window) { // TODO(beng): inform the native_widget_delegate_. @@ -34,6 +34,11 @@ index 93b3c5b..e0e505e 100644 } void DesktopWindowTreeHostWin::HandleNativeBlur(HWND focused_window) { + // TODO(beng): inform the native_widget_delegate_. ++ GetWidget()->GetNativeWindow()->Blur(); + } + + bool DesktopWindowTreeHostWin::HandleMouseEvent(const ui::MouseEvent& event) { diff --git desktop_aura/desktop_window_tree_host_x11.cc desktop_aura/desktop_window_tree_host_x11.cc index a56deb7..a5e8422 100644 --- desktop_aura/desktop_window_tree_host_x11.cc