OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_WM_CORE_FOCUS_CONTROLLER_H_ | 5 #ifndef UI_WM_CORE_FOCUS_CONTROLLER_H_ |
6 #define UI_WM_CORE_FOCUS_CONTROLLER_H_ | 6 #define UI_WM_CORE_FOCUS_CONTROLLER_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
(...skipping 10 matching lines...) Expand all Loading... | |
21 | 21 |
22 // FocusController handles focus and activation changes for an environment | 22 // FocusController handles focus and activation changes for an environment |
23 // encompassing one or more RootWindows. Within an environment there can be | 23 // encompassing one or more RootWindows. Within an environment there can be |
24 // only one focused and one active window at a time. When focus or activation | 24 // only one focused and one active window at a time. When focus or activation |
25 // changes notifications are sent using the | 25 // changes notifications are sent using the |
26 // aura::client::Focus/ActivationChangeObserver interfaces. | 26 // aura::client::Focus/ActivationChangeObserver interfaces. |
27 // Changes to focus and activation can be from three sources: | 27 // Changes to focus and activation can be from three sources: |
28 // . the Aura Client API (implemented here in aura::client::ActivationClient). | 28 // . the Aura Client API (implemented here in aura::client::ActivationClient). |
29 // (The FocusController must be set as the ActivationClient implementation | 29 // (The FocusController must be set as the ActivationClient implementation |
30 // for all RootWindows). | 30 // for all RootWindows). |
31 // . input events (implemented here in ui::EventHandler). | 31 // . input events (implemented here in ui::EventHandler). |
tdanderson
2015/05/26 21:13:52
Be sure the documentation in FocusController is st
bruthig
2015/06/03 21:59:31
Done.
| |
32 // (The FocusController must be registered as a pre-target handler for | 32 // (The FocusController must be registered as a pre-target handler for |
33 // the applicable environment owner, either a RootWindow or another type). | 33 // the applicable environment owner, either a RootWindow or another type). |
34 // . Window disposition changes (implemented here in aura::WindowObserver). | 34 // . Window disposition changes (implemented here in aura::WindowObserver). |
35 // (The FocusController registers itself as an observer of the active and | 35 // (The FocusController registers itself as an observer of the active and |
36 // focused windows). | 36 // focused windows). |
37 class WM_EXPORT FocusController : public aura::client::ActivationClient, | 37 class WM_EXPORT FocusController : public aura::client::ActivationClient, |
38 public aura::client::FocusClient, | 38 public aura::client::FocusClient, |
39 public ui::EventHandler, | |
40 public aura::WindowObserver { | 39 public aura::WindowObserver { |
41 public: | 40 public: |
42 // |rules| cannot be NULL. | 41 // |rules| cannot be NULL. |
43 explicit FocusController(FocusRules* rules); | 42 explicit FocusController(FocusRules* rules); |
44 ~FocusController() override; | 43 ~FocusController() override; |
45 | 44 |
46 private: | 45 private: |
47 // Overridden from aura::client::ActivationClient: | 46 // Overridden from aura::client::ActivationClient: |
48 void AddObserver(aura::client::ActivationChangeObserver* observer) override; | 47 void AddObserver(aura::client::ActivationChangeObserver* observer) override; |
49 void RemoveObserver( | 48 void RemoveObserver( |
50 aura::client::ActivationChangeObserver* observer) override; | 49 aura::client::ActivationChangeObserver* observer) override; |
51 void ActivateWindow(aura::Window* window) override; | 50 void ActivateWindow(aura::Window* window) override; |
52 void DeactivateWindow(aura::Window* window) override; | 51 void DeactivateWindow(aura::Window* window) override; |
53 aura::Window* GetActiveWindow() override; | 52 aura::Window* GetActiveWindow() override; |
54 aura::Window* GetActivatableWindow(aura::Window* window) override; | 53 aura::Window* GetActivatableWindow(aura::Window* window) override; |
55 aura::Window* GetToplevelWindow(aura::Window* window) override; | 54 aura::Window* GetToplevelWindow(aura::Window* window) override; |
56 bool CanActivateWindow(aura::Window* window) const override; | 55 bool CanActivateWindow(aura::Window* window) const override; |
57 | 56 |
58 // Overridden from aura::client::FocusClient: | 57 // Overridden from aura::client::FocusClient: |
59 void AddObserver(aura::client::FocusChangeObserver* observer) override; | 58 void AddObserver(aura::client::FocusChangeObserver* observer) override; |
60 void RemoveObserver(aura::client::FocusChangeObserver* observer) override; | 59 void RemoveObserver(aura::client::FocusChangeObserver* observer) override; |
61 void FocusWindow(aura::Window* window) override; | 60 void FocusWindow(aura::Window* window) override; |
62 void ResetFocusWithinActiveWindow(aura::Window* window) override; | 61 void ResetFocusWithinActiveWindow(aura::Window* window) override; |
63 aura::Window* GetFocusedWindow() override; | 62 aura::Window* GetFocusedWindow() override; |
64 | 63 |
65 // Overridden from ui::EventHandler: | |
66 void OnKeyEvent(ui::KeyEvent* event) override; | |
67 void OnMouseEvent(ui::MouseEvent* event) override; | |
68 void OnScrollEvent(ui::ScrollEvent* event) override; | |
69 void OnTouchEvent(ui::TouchEvent* event) override; | |
70 void OnGestureEvent(ui::GestureEvent* event) override; | |
71 | |
72 // Overridden from aura::WindowObserver: | 64 // Overridden from aura::WindowObserver: |
73 void OnWindowVisibilityChanged(aura::Window* window, bool visible) override; | 65 void OnWindowVisibilityChanged(aura::Window* window, bool visible) override; |
74 void OnWindowDestroying(aura::Window* window) override; | 66 void OnWindowDestroying(aura::Window* window) override; |
75 void OnWindowHierarchyChanging(const HierarchyChangeParams& params) override; | 67 void OnWindowHierarchyChanging(const HierarchyChangeParams& params) override; |
76 void OnWindowHierarchyChanged(const HierarchyChangeParams& params) override; | 68 void OnWindowHierarchyChanged(const HierarchyChangeParams& params) override; |
77 | 69 |
78 // Internal implementation that sets the focused window, fires events etc. | 70 // Internal implementation that sets the focused window, fires events etc. |
79 // This function must be called with a valid focusable window. | 71 // This function must be called with a valid focusable window. |
80 void SetFocusedWindow(aura::Window* window); | 72 void SetFocusedWindow(aura::Window* window); |
81 | 73 |
82 // Internal implementation that sets the active window, fires events etc. | 74 // Internal implementation that sets the active window, fires events etc. |
83 // This function must be called with a valid |activatable_window|. | 75 // This function must be called with a valid |activatable_window|. |
84 // |requested window| refers to the window that was passed in to an external | 76 // |requested window| refers to the window that was passed in to an external |
85 // request (e.g. FocusWindow or ActivateWindow). It may be NULL, e.g. if | 77 // request (e.g. FocusWindow or ActivateWindow). It may be NULL, e.g. if |
86 // SetActiveWindow was not called by an external request. |activatable_window| | 78 // SetActiveWindow was not called by an external request. |activatable_window| |
87 // refers to the actual window to be activated, which may be different. | 79 // refers to the actual window to be activated, which may be different. |
88 void SetActiveWindow(aura::Window* requested_window, | 80 void SetActiveWindow(aura::Window* requested_window, |
89 aura::Window* activatable_window); | 81 aura::Window* activatable_window); |
90 | 82 |
91 // Called when a window's disposition changed such that it and its hierarchy | 83 // Called when a window's disposition changed such that it and its hierarchy |
92 // are no longer focusable/activatable. |next| is a valid window that is used | 84 // are no longer focusable/activatable. |next| is a valid window that is used |
93 // as a starting point for finding a window to focus next based on rules. | 85 // as a starting point for finding a window to focus next based on rules. |
94 void WindowLostFocusFromDispositionChange(aura::Window* window, | 86 void WindowLostFocusFromDispositionChange(aura::Window* window, |
95 aura::Window* next); | 87 aura::Window* next); |
96 | 88 |
97 // Called when an attempt is made to focus or activate a window via an input | |
98 // event targeted at that window. Rules determine the best focusable window | |
99 // for the input window. | |
100 void WindowFocusedFromInputEvent(aura::Window* window); | |
101 | |
102 aura::Window* active_window_; | 89 aura::Window* active_window_; |
103 aura::Window* focused_window_; | 90 aura::Window* focused_window_; |
104 | 91 |
105 bool updating_focus_; | 92 bool updating_focus_; |
106 bool updating_activation_; | 93 bool updating_activation_; |
107 | 94 |
108 scoped_ptr<FocusRules> rules_; | 95 scoped_ptr<FocusRules> rules_; |
109 | 96 |
110 ObserverList<aura::client::ActivationChangeObserver> activation_observers_; | 97 ObserverList<aura::client::ActivationChangeObserver> activation_observers_; |
111 ObserverList<aura::client::FocusChangeObserver> focus_observers_; | 98 ObserverList<aura::client::FocusChangeObserver> focus_observers_; |
112 | 99 |
113 ScopedObserver<aura::Window, aura::WindowObserver> observer_manager_; | 100 ScopedObserver<aura::Window, aura::WindowObserver> observer_manager_; |
114 | 101 |
115 DISALLOW_COPY_AND_ASSIGN(FocusController); | 102 DISALLOW_COPY_AND_ASSIGN(FocusController); |
116 }; | 103 }; |
117 | 104 |
118 } // namespace wm | 105 } // namespace wm |
119 | 106 |
120 #endif // UI_WM_CORE_FOCUS_CONTROLLER_H_ | 107 #endif // UI_WM_CORE_FOCUS_CONTROLLER_H_ |
OLD | NEW |