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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 SetActiveWindow(next_activatable); | 329 SetActiveWindow(next_activatable); |
330 if (!(active_window_ && active_window_->Contains(focused_window_))) | 330 if (!(active_window_ && active_window_->Contains(focused_window_))) |
331 SetFocusedWindow(next_activatable); | 331 SetFocusedWindow(next_activatable); |
332 } else if (window->Contains(focused_window_)) { | 332 } else if (window->Contains(focused_window_)) { |
333 // Active window isn't changing, but focused window might be. | 333 // Active window isn't changing, but focused window might be. |
334 SetFocusedWindow(rules_->GetFocusableWindow(next)); | 334 SetFocusedWindow(rules_->GetFocusableWindow(next)); |
335 } | 335 } |
336 } | 336 } |
337 | 337 |
338 void FocusController::WindowFocusedFromInputEvent(aura::Window* window) { | 338 void FocusController::WindowFocusedFromInputEvent(aura::Window* window) { |
339 FocusWindow(window); | 339 // 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 |
| 341 // currently focused one. |
| 342 if (rules_->CanFocusWindow(GetToplevelWindow(window))) |
| 343 FocusWindow(window); |
340 } | 344 } |
341 | 345 |
342 } // namespace corewm | 346 } // namespace corewm |
343 } // namespace views | 347 } // namespace views |
OLD | NEW |