| 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 "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "ui/aura/client/aura_constants.h" | 8 #include "ui/aura/client/aura_constants.h" |
| 9 #include "ui/aura/client/capture_client.h" | 9 #include "ui/aura/client/capture_client.h" |
| 10 #include "ui/aura/client/focus_change_observer.h" | 10 #include "ui/aura/client/focus_change_observer.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 aura::client::FocusChangeObserver* observer) { | 101 aura::client::FocusChangeObserver* observer) { |
| 102 focus_observers_.RemoveObserver(observer); | 102 focus_observers_.RemoveObserver(observer); |
| 103 } | 103 } |
| 104 | 104 |
| 105 void FocusController::FocusWindow(aura::Window* window) { | 105 void FocusController::FocusWindow(aura::Window* window) { |
| 106 if (window && | 106 if (window && |
| 107 (window->Contains(focused_window_) || window->Contains(active_window_))) { | 107 (window->Contains(focused_window_) || window->Contains(active_window_))) { |
| 108 return; | 108 return; |
| 109 } | 109 } |
| 110 | 110 |
| 111 // We should not be messing with the focus if the window has capture, unless | |
| 112 // no has focus. | |
| 113 if (window && (aura::client::GetCaptureWindow(window) == window) && | |
| 114 focused_window_) { | |
| 115 return; | |
| 116 } | |
| 117 | |
| 118 // Focusing a window also activates its containing activatable window. Note | 111 // Focusing a window also activates its containing activatable window. Note |
| 119 // that the rules could redirect activation activation and/or focus. | 112 // that the rules could redirect activation activation and/or focus. |
| 120 aura::Window* focusable = rules_->GetFocusableWindow(window); | 113 aura::Window* focusable = rules_->GetFocusableWindow(window); |
| 121 aura::Window* activatable = | 114 aura::Window* activatable = |
| 122 focusable ? rules_->GetActivatableWindow(focusable) : NULL; | 115 focusable ? rules_->GetActivatableWindow(focusable) : NULL; |
| 123 | 116 |
| 124 // We need valid focusable/activatable windows in the event we're not clearing | 117 // We need valid focusable/activatable windows in the event we're not clearing |
| 125 // focus. "Clearing focus" is inferred by whether or not |window| passed to | 118 // focus. "Clearing focus" is inferred by whether or not |window| passed to |
| 126 // this function is non-NULL. | 119 // this function is non-NULL. |
| 127 if (window && (!focusable || !activatable)) | 120 if (window && (!focusable || !activatable)) |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 | 346 |
| 354 void FocusController::WindowFocusedFromInputEvent(aura::Window* window) { | 347 void FocusController::WindowFocusedFromInputEvent(aura::Window* window) { |
| 355 // Only focus |window| if it or any of its parents can be focused. Otherwise | 348 // Only focus |window| if it or any of its parents can be focused. Otherwise |
| 356 // FocusWindow() will focus the topmost window, which may not be the | 349 // FocusWindow() will focus the topmost window, which may not be the |
| 357 // currently focused one. | 350 // currently focused one. |
| 358 if (rules_->CanFocusWindow(GetToplevelWindow(window))) | 351 if (rules_->CanFocusWindow(GetToplevelWindow(window))) |
| 359 FocusWindow(window); | 352 FocusWindow(window); |
| 360 } | 353 } |
| 361 | 354 |
| 362 } // namespace wm | 355 } // namespace wm |
| OLD | NEW |