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 #ifndef UI_AURA_MUS_FOCUS_SYNCHRONIZER_H_ | 5 #ifndef UI_AURA_MUS_FOCUS_SYNCHRONIZER_H_ |
6 #define UI_AURA_MUS_FOCUS_SYNCHRONIZER_H_ | 6 #define UI_AURA_MUS_FOCUS_SYNCHRONIZER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/observer_list.h" | 9 #include "base/observer_list.h" |
10 #include "ui/aura/aura_export.h" | 10 #include "ui/aura/aura_export.h" |
(...skipping 10 matching lines...) Expand all Loading... | |
21 namespace aura { | 21 namespace aura { |
22 | 22 |
23 class FocusSynchronizerDelegate; | 23 class FocusSynchronizerDelegate; |
24 class WindowMus; | 24 class WindowMus; |
25 | 25 |
26 namespace client { | 26 namespace client { |
27 class FocusClient; | 27 class FocusClient; |
28 } | 28 } |
29 | 29 |
30 // FocusSynchronizer is resonsible for keeping focus in sync between aura | 30 // FocusSynchronizer is resonsible for keeping focus in sync between aura |
31 // and the mus server. | 31 // and the mus server. FocusSynchronizer may be configured in two distinct |
msw
2017/04/26 23:01:08
Should riajiang@ or perkj@ review this or be CC'ed
sky
2017/04/26 23:30:28
I would have sent it to Ria, but she hasn't been a
| |
32 // ways: | |
33 // . SetSingletonFocusClient(). Use this when a single FocusClient is shared | |
34 // among all windows and never changes. | |
35 // . SetActiveFocusClient(). Use this when there may be more than one | |
36 // FocusClient. | |
32 class AURA_EXPORT FocusSynchronizer : public client::FocusChangeObserver, | 37 class AURA_EXPORT FocusSynchronizer : public client::FocusChangeObserver, |
33 public WindowObserver { | 38 public WindowObserver { |
34 public: | 39 public: |
35 FocusSynchronizer(FocusSynchronizerDelegate* delegate, | 40 FocusSynchronizer(FocusSynchronizerDelegate* delegate, |
36 ui::mojom::WindowTree* window_tree); | 41 ui::mojom::WindowTree* window_tree); |
37 ~FocusSynchronizer() override; | 42 ~FocusSynchronizer() override; |
38 | 43 |
39 client::FocusClient* active_focus_client() { return active_focus_client_; } | 44 client::FocusClient* active_focus_client() { return active_focus_client_; } |
40 Window* active_focus_client_root() { return active_focus_client_root_; } | 45 Window* active_focus_client_root() { return active_focus_client_root_; } |
41 WindowMus* focused_window() { return focused_window_; } | 46 WindowMus* focused_window() { return focused_window_; } |
42 | 47 |
43 // Add and remove observers to the FocusSynchronizer to get notified when the | 48 // Add and remove observers to the FocusSynchronizer to get notified when the |
44 // |active_focus_client_| and the |active_focus_client_root_| change. | 49 // |active_focus_client_| and the |active_focus_client_root_| change. |
45 void AddObserver(FocusSynchronizerObserver* observer); | 50 void AddObserver(FocusSynchronizerObserver* observer); |
46 void RemoveObserver(FocusSynchronizerObserver* observer); | 51 void RemoveObserver(FocusSynchronizerObserver* observer); |
47 | 52 |
48 // Called when the server side wants to change focus to |window|. | 53 // Called when the server side wants to change focus to |window|. |
49 void SetFocusFromServer(WindowMus* window); | 54 void SetFocusFromServer(WindowMus* window); |
50 | 55 |
51 // Called when the focused window is destroyed. | 56 // Called when the focused window is destroyed. |
52 void OnFocusedWindowDestroyed(); | 57 void OnFocusedWindowDestroyed(); |
53 | 58 |
59 // Used when the focus client is shared among all windows. See class | |
60 // description for details. | |
61 void SetSingletonFocusClient(client::FocusClient* focus_client); | |
62 bool is_singleton_focus_client() const { return is_singleton_focus_client_; } | |
63 | |
54 // Sets the active FocusClient and the window the FocusClient is associated | 64 // Sets the active FocusClient and the window the FocusClient is associated |
55 // with. |focus_client_root| is not necessarily the window that actually has | 65 // with. |focus_client_root| is not necessarily the window that actually has |
56 // focus. | 66 // focus. |
57 void SetActiveFocusClient(client::FocusClient* focus_client, | 67 void SetActiveFocusClient(client::FocusClient* focus_client, |
58 Window* focus_client_root); | 68 Window* focus_client_root); |
59 | 69 |
60 private: | 70 private: |
61 // Called internally to set |active_focus_client_| and update observer. | 71 // Called internally to set |active_focus_client_| and update observer. |
62 void SetActiveFocusClientInternal(client::FocusClient* focus_client); | 72 void SetActiveFocusClientInternal(client::FocusClient* focus_client); |
63 | 73 |
(...skipping 15 matching lines...) Expand all Loading... | |
79 intptr_t old) override; | 89 intptr_t old) override; |
80 | 90 |
81 FocusSynchronizerDelegate* delegate_; | 91 FocusSynchronizerDelegate* delegate_; |
82 ui::mojom::WindowTree* window_tree_; | 92 ui::mojom::WindowTree* window_tree_; |
83 | 93 |
84 base::ObserverList<FocusSynchronizerObserver> observers_; | 94 base::ObserverList<FocusSynchronizerObserver> observers_; |
85 | 95 |
86 bool setting_focus_ = false; | 96 bool setting_focus_ = false; |
87 WindowMus* window_setting_focus_to_ = nullptr; | 97 WindowMus* window_setting_focus_to_ = nullptr; |
88 | 98 |
99 bool is_singleton_focus_client_ = false; | |
100 | |
89 client::FocusClient* active_focus_client_ = nullptr; | 101 client::FocusClient* active_focus_client_ = nullptr; |
90 // The window that |active_focus_client_| is associated with. | 102 // The window that |active_focus_client_| is associated with. |
91 Window* active_focus_client_root_ = nullptr; | 103 Window* active_focus_client_root_ = nullptr; |
92 // The window that actually has focus. | 104 // The window that actually has focus. |
93 WindowMus* focused_window_ = nullptr; | 105 WindowMus* focused_window_ = nullptr; |
94 | 106 |
95 DISALLOW_COPY_AND_ASSIGN(FocusSynchronizer); | 107 DISALLOW_COPY_AND_ASSIGN(FocusSynchronizer); |
96 }; | 108 }; |
97 | 109 |
98 } // namespace aura | 110 } // namespace aura |
99 | 111 |
100 #endif // UI_AURA_MUS_FOCUS_SYNCHRONIZER_H_ | 112 #endif // UI_AURA_MUS_FOCUS_SYNCHRONIZER_H_ |
OLD | NEW |