Chromium Code Reviews| Index: ui/aura/mus/focus_synchronizer.cc |
| diff --git a/ui/aura/mus/focus_synchronizer.cc b/ui/aura/mus/focus_synchronizer.cc |
| index 1e1e408ad5b9362f1270bf91b3ee1774a8e20fc9..5fbcacb3f1064a572d136d17677bf7c4c52cb339 100644 |
| --- a/ui/aura/mus/focus_synchronizer.cc |
| +++ b/ui/aura/mus/focus_synchronizer.cc |
| @@ -42,7 +42,7 @@ void FocusSynchronizer::SetFocusFromServer(WindowMus* window) { |
| Window* root = window->GetWindow()->GetRootWindow(); |
| // The client should provide a focus client for all roots. |
| DCHECK(client::GetFocusClient(root)); |
| - if (active_focus_client_root_ != root) |
| + if (!is_singleton_focus_client_ && active_focus_client_root_ != root) |
|
msw
2017/04/26 23:01:08
If |is_singleton_focus_client_| is true, should th
sky
2017/04/26 23:30:28
Done.
|
| SetActiveFocusClient(client::GetFocusClient(root), root); |
| window->GetWindow()->Focus(); |
| } else if (active_focus_client_) { |
| @@ -54,19 +54,31 @@ void FocusSynchronizer::OnFocusedWindowDestroyed() { |
| focused_window_ = nullptr; |
| } |
| +void FocusSynchronizer::SetSingletonFocusClient( |
| + client::FocusClient* focus_client) { |
| + SetActiveFocusClient(focus_client, nullptr); |
| + if (focus_client) |
| + is_singleton_focus_client_ = true; |
| +} |
| + |
| void FocusSynchronizer::SetActiveFocusClient(client::FocusClient* focus_client, |
| Window* focus_client_root) { |
| - if (focus_client_root == active_focus_client_root_) { |
| - DCHECK_EQ(focus_client, active_focus_client_); |
| + if (focus_client == active_focus_client_ && |
| + focus_client_root == active_focus_client_root_) { |
| return; |
| } |
| + is_singleton_focus_client_ = false; |
| + |
| if (active_focus_client_root_) |
| active_focus_client_root_->RemoveObserver(this); |
| active_focus_client_root_ = focus_client_root; |
| if (active_focus_client_root_) |
| active_focus_client_root_->AddObserver(this); |
| + if (focus_client == active_focus_client_) |
| + return; |
| + |
| OnActiveFocusClientChanged(focus_client, focus_client_root); |
| for (FocusSynchronizerObserver& observer : observers_) |
| observer.OnActiveFocusClientChanged(focus_client, focus_client_root); |
| @@ -118,12 +130,14 @@ void FocusSynchronizer::OnWindowFocused(Window* gained_focus, |
| } |
| void FocusSynchronizer::OnWindowDestroying(Window* window) { |
| + DCHECK(!is_singleton_focus_client_); |
| SetActiveFocusClient(nullptr, nullptr); |
| } |
| void FocusSynchronizer::OnWindowPropertyChanged(Window* window, |
| const void* key, |
| intptr_t old) { |
| + DCHECK(!is_singleton_focus_client_); |
| if (key != client::kFocusClientKey) |
| return; |