Chromium Code Reviews| Index: ui/views/widget/desktop_aura/desktop_native_widget_aura.cc |
| diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc |
| index 0a8dca11691649205e875eaa804ddcc592b65cd9..6f478287f91659d1708e540a57e817c71bc6421e 100644 |
| --- a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc |
| +++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc |
| @@ -244,6 +244,7 @@ DesktopNativeWidgetAura::DesktopNativeWidgetAura( |
| content_window_(new aura::Window(this)), |
| native_widget_delegate_(delegate), |
| last_drop_operation_(ui::DragDropTypes::DRAG_NONE), |
| + restore_focus_on_activate_(false), |
| cursor_(gfx::kNullCursor), |
| widget_type_(Widget::InitParams::TYPE_WINDOW), |
| close_widget_factory_(this) { |
| @@ -1091,7 +1092,16 @@ void DesktopNativeWidgetAura::OnWindowActivated( |
| aura::Window* gained_active, |
| aura::Window* lost_active) { |
| DCHECK(content_window_ == gained_active || content_window_ == lost_active); |
| - if (lost_active == content_window_ && GetWidget()->HasFocusManager()) { |
| + if (gained_active == content_window_ && restore_focus_on_activate_) { |
| + restore_focus_on_activate_ = false; |
| + // For OS_LINUX, desktop native widget may not be activated when child |
| + // widgets gets aura activation changes. Only when desktop native widget is |
| + // active, we can rely on aura activation to restore focused view. |
| + if (GetWidget()->IsActive()) |
| + GetWidget()->GetFocusManager()->RestoreFocusedView(); |
|
sky
2016/11/19 15:33:23
For the non-linux case don't we end up in HandleAc
Qiang(Joe) Xu
2016/11/19 23:48:56
Good catch. I think make restore_focus_on_activate
|
| + } else if (lost_active == content_window_ && GetWidget()->HasFocusManager()) { |
| + DCHECK(!restore_focus_on_activate_); |
| + restore_focus_on_activate_ = true; |
| // Pass in false so that ClearNativeFocus() isn't invoked. |
| GetWidget()->GetFocusManager()->StoreFocusedView(false); |
| } |