| 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 28 matching lines...) Expand all Loading... |
| 39 // The client should provide a focus client for all roots. | 39 // The client should provide a focus client for all roots. |
| 40 DCHECK(client::GetFocusClient(root)); | 40 DCHECK(client::GetFocusClient(root)); |
| 41 if (env->active_focus_client_root() != root) | 41 if (env->active_focus_client_root() != root) |
| 42 env->SetActiveFocusClient(client::GetFocusClient(root), root); | 42 env->SetActiveFocusClient(client::GetFocusClient(root), root); |
| 43 window->GetWindow()->Focus(); | 43 window->GetWindow()->Focus(); |
| 44 } else if (env->active_focus_client()) { | 44 } else if (env->active_focus_client()) { |
| 45 env->active_focus_client()->FocusWindow(nullptr); | 45 env->active_focus_client()->FocusWindow(nullptr); |
| 46 } | 46 } |
| 47 } | 47 } |
| 48 | 48 |
| 49 void FocusSynchronizer::ClearFocus() { |
| 50 SetFocusedWindow(nullptr); |
| 51 } |
| 52 |
| 49 void FocusSynchronizer::OnFocusedWindowDestroyed() { | 53 void FocusSynchronizer::OnFocusedWindowDestroyed() { |
| 50 focused_window_ = nullptr; | 54 focused_window_ = nullptr; |
| 51 } | 55 } |
| 52 | 56 |
| 53 void FocusSynchronizer::SetActiveFocusClient( | 57 void FocusSynchronizer::SetActiveFocusClient( |
| 54 client::FocusClient* focus_client) { | 58 client::FocusClient* focus_client) { |
| 55 if (focus_client == active_focus_client_) | 59 if (focus_client == active_focus_client_) |
| 56 return; | 60 return; |
| 57 | 61 |
| 58 if (active_focus_client_) | 62 if (active_focus_client_) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 if (focus_client) { | 95 if (focus_client) { |
| 92 Window* focused_window = focus_client->GetFocusedWindow(); | 96 Window* focused_window = focus_client->GetFocusedWindow(); |
| 93 SetFocusedWindow(focused_window ? WindowMus::Get(focused_window) | 97 SetFocusedWindow(focused_window ? WindowMus::Get(focused_window) |
| 94 : WindowMus::Get(window)); | 98 : WindowMus::Get(window)); |
| 95 } else { | 99 } else { |
| 96 SetFocusedWindow(nullptr); | 100 SetFocusedWindow(nullptr); |
| 97 } | 101 } |
| 98 } | 102 } |
| 99 | 103 |
| 100 } // namespace aura | 104 } // namespace aura |
| OLD | NEW |