| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef UI_AURA_MUS_FOCUS_SYNCHRONIZER_H_ | |
| 6 #define UI_AURA_MUS_FOCUS_SYNCHRONIZER_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "ui/aura/client/focus_change_observer.h" | |
| 10 #include "ui/aura/env_observer.h" | |
| 11 | |
| 12 namespace ui { | |
| 13 namespace mojom { | |
| 14 class WindowTree; | |
| 15 } | |
| 16 } | |
| 17 | |
| 18 namespace aura { | |
| 19 | |
| 20 class FocusSynchronizerDelegate; | |
| 21 class WindowMus; | |
| 22 | |
| 23 namespace client { | |
| 24 class FocusClient; | |
| 25 } | |
| 26 | |
| 27 // FocusSynchronizer is resonsible for keeping focus in sync between aura | |
| 28 // and the mus server. | |
| 29 class FocusSynchronizer : public client::FocusChangeObserver, | |
| 30 public EnvObserver { | |
| 31 public: | |
| 32 FocusSynchronizer(FocusSynchronizerDelegate* delegate, | |
| 33 ui::mojom::WindowTree* window_tree); | |
| 34 ~FocusSynchronizer() override; | |
| 35 | |
| 36 // Called when the server side wants to change focus to |window|. | |
| 37 void SetFocusFromServer(WindowMus* window); | |
| 38 | |
| 39 // Called when the focused window is destroyed. | |
| 40 void OnFocusedWindowDestroyed(); | |
| 41 | |
| 42 WindowMus* focused_window() { return focused_window_; } | |
| 43 | |
| 44 private: | |
| 45 void SetActiveFocusClient(client::FocusClient* focus_client); | |
| 46 | |
| 47 // Called internally to set |focused_window_| and update the server. | |
| 48 void SetFocusedWindow(WindowMus* window); | |
| 49 | |
| 50 // Overriden from client::FocusChangeObserver: | |
| 51 void OnWindowFocused(Window* gained_focus, Window* lost_focus) override; | |
| 52 | |
| 53 // Overrided from EnvObserver: | |
| 54 void OnWindowInitialized(Window* window) override; | |
| 55 void OnActiveFocusClientChanged(client::FocusClient* focus_client, | |
| 56 Window* window) override; | |
| 57 | |
| 58 FocusSynchronizerDelegate* delegate_; | |
| 59 ui::mojom::WindowTree* window_tree_; | |
| 60 | |
| 61 client::FocusClient* active_focus_client_ = nullptr; | |
| 62 | |
| 63 bool setting_focus_ = false; | |
| 64 WindowMus* window_setting_focus_to_ = nullptr; | |
| 65 WindowMus* focused_window_ = nullptr; | |
| 66 | |
| 67 DISALLOW_COPY_AND_ASSIGN(FocusSynchronizer); | |
| 68 }; | |
| 69 | |
| 70 } // namespace aura | |
| 71 | |
| 72 #endif // UI_AURA_MUS_FOCUS_SYNCHRONIZER_H_ | |
| OLD | NEW |