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/views/corewm/focus_controller.h" | 5 #include "ui/views/corewm/focus_controller.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "ui/aura/client/activation_change_observer.h" | 8 #include "ui/aura/client/activation_change_observer.h" |
9 #include "ui/aura/client/aura_constants.h" | 9 #include "ui/aura/client/aura_constants.h" |
10 #include "ui/aura/client/capture_client.h" | 10 #include "ui/aura/client/capture_client.h" |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
246 WindowLostFocusFromDispositionChange(params.receiver, params.old_parent); | 246 WindowLostFocusFromDispositionChange(params.receiver, params.old_parent); |
247 } | 247 } |
248 } | 248 } |
249 | 249 |
250 //////////////////////////////////////////////////////////////////////////////// | 250 //////////////////////////////////////////////////////////////////////////////// |
251 // FocusController, private: | 251 // FocusController, private: |
252 | 252 |
253 void FocusController::SetFocusedWindow(aura::Window* window) { | 253 void FocusController::SetFocusedWindow(aura::Window* window) { |
254 if (updating_focus_ || window == focused_window_) | 254 if (updating_focus_ || window == focused_window_) |
255 return; | 255 return; |
256 DCHECK(rules_->CanFocusWindow(window)); | 256 |
257 // When a modal dialog appears, SetFocusedWindow gets called by | |
258 // ClearNativeFocus for the previously active window as it is deactivated. In | |
259 // this case, CanFocusWindow returns false and this method has no further | |
260 // work to do. | |
261 if (!rules_->CanFocusWindow(window)) | |
Ben Goodger (Google)
2013/04/25 17:19:28
I'm not happy with this. I've made it thus far tha
robertshield
2013/04/26 18:40:42
I reverted this bit and instead now perform a chec
| |
262 return; | |
263 | |
257 if (window) | 264 if (window) |
258 DCHECK_EQ(window, rules_->GetFocusableWindow(window)); | 265 DCHECK_EQ(window, rules_->GetFocusableWindow(window)); |
259 | 266 |
260 base::AutoReset<bool> updating_focus(&updating_focus_, true); | 267 base::AutoReset<bool> updating_focus(&updating_focus_, true); |
261 aura::Window* lost_focus = focused_window_; | 268 aura::Window* lost_focus = focused_window_; |
262 if (focused_window_ && observer_manager_.IsObserving(focused_window_) && | 269 if (focused_window_ && observer_manager_.IsObserving(focused_window_) && |
263 focused_window_ != active_window_) { | 270 focused_window_ != active_window_) { |
264 observer_manager_.Remove(focused_window_); | 271 observer_manager_.Remove(focused_window_); |
265 } | 272 } |
266 focused_window_ = window; | 273 focused_window_ = window; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
338 void FocusController::WindowFocusedFromInputEvent(aura::Window* window) { | 345 void FocusController::WindowFocusedFromInputEvent(aura::Window* window) { |
339 // Only focus |window| if it or any of its parents can be focused. Otherwise | 346 // Only focus |window| if it or any of its parents can be focused. Otherwise |
340 // FocusWindow() will focus the topmost window, which may not be the | 347 // FocusWindow() will focus the topmost window, which may not be the |
341 // currently focused one. | 348 // currently focused one. |
342 if (rules_->CanFocusWindow(GetToplevelWindow(window))) | 349 if (rules_->CanFocusWindow(GetToplevelWindow(window))) |
343 FocusWindow(window); | 350 FocusWindow(window); |
344 } | 351 } |
345 | 352 |
346 } // namespace corewm | 353 } // namespace corewm |
347 } // namespace views | 354 } // namespace views |
OLD | NEW |