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" |
11 #include "base/scoped_observer.h" | 11 #include "base/scoped_observer.h" |
12 #include "ui/aura/client/focus_client.h" | 12 #include "ui/aura/client/focus_client.h" |
13 #include "ui/aura/window_observer.h" | 13 #include "ui/aura/window_observer.h" |
14 #include "ui/events/event_handler.h" | 14 #include "ui/events/event_handler.h" |
| 15 #include "ui/wm/public/activation_change_observer.h" |
15 #include "ui/wm/public/activation_client.h" | 16 #include "ui/wm/public/activation_client.h" |
16 #include "ui/wm/wm_export.h" | 17 #include "ui/wm/wm_export.h" |
17 | 18 |
18 namespace wm { | 19 namespace wm { |
19 | 20 |
20 class FocusRules; | 21 class FocusRules; |
21 | 22 |
22 // FocusController handles focus and activation changes for an environment | 23 // FocusController handles focus and activation changes for an environment |
23 // encompassing one or more RootWindows. Within an environment there can be | 24 // 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 | 25 // only one focused and one active window at a time. When focus or activation |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 // Internal implementation that sets the focused window, fires events etc. | 79 // Internal implementation that sets the focused window, fires events etc. |
79 // This function must be called with a valid focusable window. | 80 // This function must be called with a valid focusable window. |
80 void SetFocusedWindow(aura::Window* window); | 81 void SetFocusedWindow(aura::Window* window); |
81 | 82 |
82 // Internal implementation that sets the active window, fires events etc. | 83 // Internal implementation that sets the active window, fires events etc. |
83 // This function must be called with a valid |activatable_window|. | 84 // This function must be called with a valid |activatable_window|. |
84 // |requested window| refers to the window that was passed in to an external | 85 // |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 | 86 // request (e.g. FocusWindow or ActivateWindow). It may be NULL, e.g. if |
86 // SetActiveWindow was not called by an external request. |activatable_window| | 87 // SetActiveWindow was not called by an external request. |activatable_window| |
87 // refers to the actual window to be activated, which may be different. | 88 // refers to the actual window to be activated, which may be different. |
88 void SetActiveWindow(aura::Window* requested_window, | 89 void SetActiveWindow( |
89 aura::Window* activatable_window); | 90 aura::client::ActivationChangeObserver::ActivationReason reason, |
| 91 aura::Window* requested_window, |
| 92 aura::Window* activatable_window); |
90 | 93 |
91 // Called when a window's disposition changed such that it and its hierarchy | 94 // 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 | 95 // 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. | 96 // as a starting point for finding a window to focus next based on rules. |
94 void WindowLostFocusFromDispositionChange(aura::Window* window, | 97 void WindowLostFocusFromDispositionChange(aura::Window* window, |
95 aura::Window* next); | 98 aura::Window* next); |
96 | 99 |
97 // Called when an attempt is made to focus or activate a window via an input | 100 // 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 | 101 // event targeted at that window. Rules determine the best focusable window |
99 // for the input window. | 102 // for the input window. |
100 void WindowFocusedFromInputEvent(aura::Window* window); | 103 void WindowFocusedFromInputEvent(aura::Window* window); |
101 | 104 |
| 105 void FocusWindowImpl( |
| 106 aura::client::ActivationChangeObserver::ActivationReason reason, |
| 107 aura::Window* window); |
| 108 |
102 aura::Window* active_window_; | 109 aura::Window* active_window_; |
103 aura::Window* focused_window_; | 110 aura::Window* focused_window_; |
104 | 111 |
105 bool updating_focus_; | 112 bool updating_focus_; |
106 bool updating_activation_; | 113 bool updating_activation_; |
107 | 114 |
108 scoped_ptr<FocusRules> rules_; | 115 scoped_ptr<FocusRules> rules_; |
109 | 116 |
110 ObserverList<aura::client::ActivationChangeObserver> activation_observers_; | 117 ObserverList<aura::client::ActivationChangeObserver> activation_observers_; |
111 ObserverList<aura::client::FocusChangeObserver> focus_observers_; | 118 ObserverList<aura::client::FocusChangeObserver> focus_observers_; |
112 | 119 |
113 ScopedObserver<aura::Window, aura::WindowObserver> observer_manager_; | 120 ScopedObserver<aura::Window, aura::WindowObserver> observer_manager_; |
114 | 121 |
115 DISALLOW_COPY_AND_ASSIGN(FocusController); | 122 DISALLOW_COPY_AND_ASSIGN(FocusController); |
116 }; | 123 }; |
117 | 124 |
118 } // namespace wm | 125 } // namespace wm |
119 | 126 |
120 #endif // UI_WM_CORE_FOCUS_CONTROLLER_H_ | 127 #endif // UI_WM_CORE_FOCUS_CONTROLLER_H_ |
OLD | NEW |