Windows: Fix focus/blur handling (issue #1677)

This commit is contained in:
Marshall Greenblatt 2015-08-04 13:53:59 -04:00
parent 5f0720e096
commit 3010ee1ce6
3 changed files with 49 additions and 3 deletions

View File

@ -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/',
},
]

View File

@ -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;

View File

@ -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