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 #include "ui/wm/core/focus_controller.h" | 5 #include "ui/wm/core/focus_controller.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "ui/aura/client/aura_constants.h" | 9 #include "ui/aura/client/aura_constants.h" |
10 #include "ui/aura/client/default_capture_client.h" | 10 #include "ui/aura/client/default_capture_client.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 } | 49 } |
50 aura::Window* reactivation_requested_window() const { | 50 aura::Window* reactivation_requested_window() const { |
51 return reactivation_requested_window_; | 51 return reactivation_requested_window_; |
52 } | 52 } |
53 aura::Window* reactivation_actual_window() const { | 53 aura::Window* reactivation_actual_window() const { |
54 return reactivation_actual_window_; | 54 return reactivation_actual_window_; |
55 } | 55 } |
56 | 56 |
57 private: | 57 private: |
58 // Overridden from aura::client::ActivationChangeObserver: | 58 // Overridden from aura::client::ActivationChangeObserver: |
59 void OnWindowActivated(aura::Window* gained_active, | 59 void OnWindowActivated(ActivationReason reason, |
| 60 aura::Window* gained_active, |
60 aura::Window* lost_active) override { | 61 aura::Window* lost_active) override { |
61 ++activation_changed_count_; | 62 ++activation_changed_count_; |
62 } | 63 } |
63 void OnAttemptToReactivateWindow(aura::Window* request_active, | 64 void OnAttemptToReactivateWindow(aura::Window* request_active, |
64 aura::Window* actual_active) override { | 65 aura::Window* actual_active) override { |
65 ++reactivation_count_; | 66 ++reactivation_count_; |
66 reactivation_requested_window_ = request_active; | 67 reactivation_requested_window_ = request_active; |
67 reactivation_actual_window_ = actual_active; | 68 reactivation_actual_window_ = actual_active; |
68 } | 69 } |
69 | 70 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 ~RecordingActivationAndFocusChangeObserver() override { | 109 ~RecordingActivationAndFocusChangeObserver() override { |
109 aura::client::GetActivationClient(root_)->RemoveObserver(this); | 110 aura::client::GetActivationClient(root_)->RemoveObserver(this); |
110 aura::client::GetFocusClient(root_)->RemoveObserver(this); | 111 aura::client::GetFocusClient(root_)->RemoveObserver(this); |
111 } | 112 } |
112 | 113 |
113 bool was_notified_with_deleted_window() const { | 114 bool was_notified_with_deleted_window() const { |
114 return was_notified_with_deleted_window_; | 115 return was_notified_with_deleted_window_; |
115 } | 116 } |
116 | 117 |
117 // Overridden from aura::client::ActivationChangeObserver: | 118 // Overridden from aura::client::ActivationChangeObserver: |
118 void OnWindowActivated(aura::Window* gained_active, | 119 void OnWindowActivated(ActivationReason reason, |
| 120 aura::Window* gained_active, |
119 aura::Window* lost_active) override { | 121 aura::Window* lost_active) override { |
120 if (lost_active && lost_active == deleter_->GetDeletedWindow()) | 122 if (lost_active && lost_active == deleter_->GetDeletedWindow()) |
121 was_notified_with_deleted_window_ = true; | 123 was_notified_with_deleted_window_ = true; |
122 } | 124 } |
123 | 125 |
124 // Overridden from aura::client::FocusChangeObserver: | 126 // Overridden from aura::client::FocusChangeObserver: |
125 void OnWindowFocused(aura::Window* gained_focus, | 127 void OnWindowFocused(aura::Window* gained_focus, |
126 aura::Window* lost_focus) override { | 128 aura::Window* lost_focus) override { |
127 if (lost_focus && lost_focus == deleter_->GetDeletedWindow()) | 129 if (lost_focus && lost_focus == deleter_->GetDeletedWindow()) |
128 was_notified_with_deleted_window_ = true; | 130 was_notified_with_deleted_window_ = true; |
(...skipping 22 matching lines...) Expand all Loading... |
151 : root_(window->GetRootWindow()), | 153 : root_(window->GetRootWindow()), |
152 window_(window), | 154 window_(window), |
153 did_delete_(false) { | 155 did_delete_(false) { |
154 aura::client::GetActivationClient(root_)->AddObserver(this); | 156 aura::client::GetActivationClient(root_)->AddObserver(this); |
155 } | 157 } |
156 ~DeleteOnLoseActivationChangeObserver() override { | 158 ~DeleteOnLoseActivationChangeObserver() override { |
157 aura::client::GetActivationClient(root_)->RemoveObserver(this); | 159 aura::client::GetActivationClient(root_)->RemoveObserver(this); |
158 } | 160 } |
159 | 161 |
160 // Overridden from aura::client::ActivationChangeObserver: | 162 // Overridden from aura::client::ActivationChangeObserver: |
161 void OnWindowActivated(aura::Window* gained_active, | 163 void OnWindowActivated(ActivationReason reason, |
| 164 aura::Window* gained_active, |
162 aura::Window* lost_active) override { | 165 aura::Window* lost_active) override { |
163 if (window_ && lost_active == window_) { | 166 if (window_ && lost_active == window_) { |
164 delete lost_active; | 167 delete lost_active; |
165 did_delete_ = true; | 168 did_delete_ = true; |
166 } | 169 } |
167 } | 170 } |
168 | 171 |
169 // Overridden from WindowDeleter: | 172 // Overridden from WindowDeleter: |
170 aura::Window* GetDeletedWindow() override { | 173 aura::Window* GetDeletedWindow() override { |
171 return did_delete_ ? window_ : NULL; | 174 return did_delete_ ? window_ : NULL; |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 : activated_window_(activated_window), | 299 : activated_window_(activated_window), |
297 shift_focus_to_(NULL) {} | 300 shift_focus_to_(NULL) {} |
298 ~FocusShiftingActivationObserver() override {} | 301 ~FocusShiftingActivationObserver() override {} |
299 | 302 |
300 void set_shift_focus_to(aura::Window* shift_focus_to) { | 303 void set_shift_focus_to(aura::Window* shift_focus_to) { |
301 shift_focus_to_ = shift_focus_to; | 304 shift_focus_to_ = shift_focus_to; |
302 } | 305 } |
303 | 306 |
304 private: | 307 private: |
305 // Overridden from aura::client::ActivationChangeObserver: | 308 // Overridden from aura::client::ActivationChangeObserver: |
306 void OnWindowActivated(aura::Window* gained_active, | 309 void OnWindowActivated(ActivationReason reason, |
| 310 aura::Window* gained_active, |
307 aura::Window* lost_active) override { | 311 aura::Window* lost_active) override { |
308 // Shift focus to a child. This should prevent the default focusing from | 312 // Shift focus to a child. This should prevent the default focusing from |
309 // occurring in FocusController::FocusWindow(). | 313 // occurring in FocusController::FocusWindow(). |
310 if (gained_active == activated_window_) { | 314 if (gained_active == activated_window_) { |
311 aura::client::FocusClient* client = | 315 aura::client::FocusClient* client = |
312 aura::client::GetFocusClient(gained_active); | 316 aura::client::GetFocusClient(gained_active); |
313 client->FocusWindow(shift_focus_to_); | 317 client->FocusWindow(shift_focus_to_); |
314 } | 318 } |
315 } | 319 } |
316 | 320 |
(...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1301 TransientChildWindowActivationTest); | 1305 TransientChildWindowActivationTest); |
1302 | 1306 |
1303 // - Verifies that the focused text input client is cleard when the window focus | 1307 // - Verifies that the focused text input client is cleard when the window focus |
1304 // changes. | 1308 // changes. |
1305 ALL_FOCUS_TESTS(FocusedTextInputClient); | 1309 ALL_FOCUS_TESTS(FocusedTextInputClient); |
1306 | 1310 |
1307 // If a mouse event was handled, it should not activate a window. | 1311 // If a mouse event was handled, it should not activate a window. |
1308 FOCUS_CONTROLLER_TEST(FocusControllerMouseEventTest, IgnoreHandledEvent); | 1312 FOCUS_CONTROLLER_TEST(FocusControllerMouseEventTest, IgnoreHandledEvent); |
1309 | 1313 |
1310 } // namespace wm | 1314 } // namespace wm |
OLD | NEW |