| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/aura/mus/focus_synchronizer.h" | 5 #include "ui/aura/mus/focus_synchronizer.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "services/ui/public/interfaces/window_tree.mojom.h" | 8 #include "services/ui/public/interfaces/window_tree.mojom.h" |
| 9 #include "ui/aura/client/focus_client.h" | 9 #include "ui/aura/client/focus_client.h" |
| 10 #include "ui/aura/env.h" | 10 #include "ui/aura/env.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 } | 26 } |
| 27 | 27 |
| 28 void FocusSynchronizer::SetFocusFromServer(WindowMus* window) { | 28 void FocusSynchronizer::SetFocusFromServer(WindowMus* window) { |
| 29 if (focused_window_ == window) | 29 if (focused_window_ == window) |
| 30 return; | 30 return; |
| 31 | 31 |
| 32 DCHECK(!setting_focus_); | 32 DCHECK(!setting_focus_); |
| 33 base::AutoReset<bool> focus_reset(&setting_focus_, true); | 33 base::AutoReset<bool> focus_reset(&setting_focus_, true); |
| 34 base::AutoReset<WindowMus*> window_setting_focus_to_reset( | 34 base::AutoReset<WindowMus*> window_setting_focus_to_reset( |
| 35 &window_setting_focus_to_, window); | 35 &window_setting_focus_to_, window); |
| 36 Env* env = aura::Env::GetInstance(); | 36 Env* env = Env::GetInstance(); |
| 37 if (window) { | 37 if (window) { |
| 38 Window* root = window->GetWindow()->GetRootWindow(); | 38 Window* root = window->GetWindow()->GetRootWindow(); |
| 39 // The client should provide a focus client for all roots. |
| 40 DCHECK(client::GetFocusClient(root)); |
| 39 if (env->active_focus_client_root() != root) | 41 if (env->active_focus_client_root() != root) |
| 40 env->SetActiveFocusClient(aura::client::GetFocusClient(root), root); | 42 env->SetActiveFocusClient(client::GetFocusClient(root), root); |
| 41 window->GetWindow()->Focus(); | 43 window->GetWindow()->Focus(); |
| 42 } else if (env->active_focus_client()) { | 44 } else if (env->active_focus_client()) { |
| 43 env->active_focus_client()->FocusWindow(nullptr); | 45 env->active_focus_client()->FocusWindow(nullptr); |
| 44 } | 46 } |
| 45 } | 47 } |
| 46 | 48 |
| 47 void FocusSynchronizer::OnFocusedWindowDestroyed() { | 49 void FocusSynchronizer::OnFocusedWindowDestroyed() { |
| 48 focused_window_ = nullptr; | 50 focused_window_ = nullptr; |
| 49 } | 51 } |
| 50 | 52 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 if (focus_client) { | 91 if (focus_client) { |
| 90 Window* focused_window = focus_client->GetFocusedWindow(); | 92 Window* focused_window = focus_client->GetFocusedWindow(); |
| 91 SetFocusedWindow(focused_window ? WindowMus::Get(focused_window) | 93 SetFocusedWindow(focused_window ? WindowMus::Get(focused_window) |
| 92 : WindowMus::Get(window)); | 94 : WindowMus::Get(window)); |
| 93 } else { | 95 } else { |
| 94 SetFocusedWindow(nullptr); | 96 SetFocusedWindow(nullptr); |
| 95 } | 97 } |
| 96 } | 98 } |
| 97 | 99 |
| 98 } // namespace aura | 100 } // namespace aura |
| OLD | NEW |