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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 aura::client::FocusChangeObserver* observer) { | 123 aura::client::FocusChangeObserver* observer) { |
124 focus_observers_.RemoveObserver(observer); | 124 focus_observers_.RemoveObserver(observer); |
125 } | 125 } |
126 | 126 |
127 void FocusController::FocusWindow(aura::Window* window) { | 127 void FocusController::FocusWindow(aura::Window* window) { |
128 if (window && | 128 if (window && |
129 (window->Contains(focused_window_) || window->Contains(active_window_))) { | 129 (window->Contains(focused_window_) || window->Contains(active_window_))) { |
130 return; | 130 return; |
131 } | 131 } |
132 | 132 |
133 // We should not be messing with the focus if the window has capture. | 133 // We should not be messing with the focus if the window has capture, unless |
134 if (window && (aura::client::GetCaptureWindow(window) == window)) | 134 // no has focus. |
| 135 if (window && (aura::client::GetCaptureWindow(window) == window) && |
| 136 focused_window_) { |
135 return; | 137 return; |
| 138 } |
136 | 139 |
137 // Focusing a window also activates its containing activatable window. Note | 140 // Focusing a window also activates its containing activatable window. Note |
138 // that the rules could redirect activation activation and/or focus. | 141 // that the rules could redirect activation activation and/or focus. |
139 aura::Window* focusable = rules_->GetFocusableWindow(window); | 142 aura::Window* focusable = rules_->GetFocusableWindow(window); |
140 aura::Window* activatable = | 143 aura::Window* activatable = |
141 focusable ? rules_->GetActivatableWindow(focusable) : NULL; | 144 focusable ? rules_->GetActivatableWindow(focusable) : NULL; |
142 | 145 |
143 // We need valid focusable/activatable windows in the event we're not clearing | 146 // We need valid focusable/activatable windows in the event we're not clearing |
144 // focus. "Clearing focus" is inferred by whether or not |window| passed to | 147 // focus. "Clearing focus" is inferred by whether or not |window| passed to |
145 // this function is non-NULL. | 148 // this function is non-NULL. |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 void FocusController::WindowFocusedFromInputEvent(aura::Window* window) { | 352 void FocusController::WindowFocusedFromInputEvent(aura::Window* window) { |
350 // Only focus |window| if it or any of its parents can be focused. Otherwise | 353 // Only focus |window| if it or any of its parents can be focused. Otherwise |
351 // FocusWindow() will focus the topmost window, which may not be the | 354 // FocusWindow() will focus the topmost window, which may not be the |
352 // currently focused one. | 355 // currently focused one. |
353 if (rules_->CanFocusWindow(GetToplevelWindow(window))) | 356 if (rules_->CanFocusWindow(GetToplevelWindow(window))) |
354 FocusWindow(window); | 357 FocusWindow(window); |
355 } | 358 } |
356 | 359 |
357 } // namespace corewm | 360 } // namespace corewm |
358 } // namespace views | 361 } // namespace views |
OLD | NEW |