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..cc24e7e7adf47b3245e79168f3e97a32e3da2f41 100644 |
| --- a/ui/aura/mus/focus_synchronizer.cc |
| +++ b/ui/aura/mus/focus_synchronizer.cc |
| @@ -42,7 +42,9 @@ 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_) |
| + DCHECK_EQ(active_focus_client_, client::GetFocusClient(root)); |
|
msw
2017/04/26 23:44:46
q: this should work in release builds, right? (DCH
sky
2017/04/27 02:49:41
If it were a blank line this wouldn't compile at a
|
| + else if (active_focus_client_root_ != root) |
| SetActiveFocusClient(client::GetFocusClient(root), root); |
| window->GetWindow()->Focus(); |
| } else if (active_focus_client_) { |
| @@ -54,19 +56,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 +132,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; |