| 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 13 matching lines...) Expand all Loading... |
| 24 if (window->GetProperty(aura::client::kModalKey) != ui::MODAL_TYPE_WINDOW) | 24 if (window->GetProperty(aura::client::kModalKey) != ui::MODAL_TYPE_WINDOW) |
| 25 return; | 25 return; |
| 26 | 26 |
| 27 aura::Window* transient_parent = window->transient_parent(); | 27 aura::Window* transient_parent = window->transient_parent(); |
| 28 while (transient_parent) { | 28 while (transient_parent) { |
| 29 transient_parent->parent()->StackChildAtTop(transient_parent); | 29 transient_parent->parent()->StackChildAtTop(transient_parent); |
| 30 transient_parent = transient_parent->transient_parent(); | 30 transient_parent = transient_parent->transient_parent(); |
| 31 } | 31 } |
| 32 } | 32 } |
| 33 | 33 |
| 34 // Stack's |window|'s layer above |relative_to|'s layer. |
| 35 void StackWindowLayerAbove(aura::Window* window, aura::Window* relative_to) { |
| 36 // Stack |window| above the last transient child of |relative_to| that shares |
| 37 // the same parent. |
| 38 const aura::Window::Windows& window_transients( |
| 39 relative_to->transient_children()); |
| 40 for (aura::Window::Windows::const_iterator i = window_transients.begin(); |
| 41 i != window_transients.end(); ++i) { |
| 42 aura::Window* transient = *i; |
| 43 if (transient->parent() == relative_to->parent()) |
| 44 relative_to = transient; |
| 45 } |
| 46 window->layer()->parent()->StackAbove(window->layer(), relative_to->layer()); |
| 47 } |
| 48 |
| 34 } // namespace | 49 } // namespace |
| 35 | 50 |
| 36 //////////////////////////////////////////////////////////////////////////////// | 51 //////////////////////////////////////////////////////////////////////////////// |
| 37 // FocusController, public: | 52 // FocusController, public: |
| 38 | 53 |
| 39 FocusController::FocusController(FocusRules* rules) | 54 FocusController::FocusController(FocusRules* rules) |
| 40 : active_window_(NULL), | 55 : active_window_(NULL), |
| 41 focused_window_(NULL), | 56 focused_window_(NULL), |
| 42 updating_focus_(false), | 57 updating_focus_(false), |
| 43 updating_activation_(false), | 58 updating_activation_(false), |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 //////////////////////////////////////////////////////////////////////////////// | 208 //////////////////////////////////////////////////////////////////////////////// |
| 194 // FocusController, aura::WindowObserver implementation: | 209 // FocusController, aura::WindowObserver implementation: |
| 195 | 210 |
| 196 void FocusController::OnWindowVisibilityChanged(aura::Window* window, | 211 void FocusController::OnWindowVisibilityChanged(aura::Window* window, |
| 197 bool visible) { | 212 bool visible) { |
| 198 if (!visible) { | 213 if (!visible) { |
| 199 WindowLostFocusFromDispositionChange(window, window->parent()); | 214 WindowLostFocusFromDispositionChange(window, window->parent()); |
| 200 // Despite the focus change, we need to keep the window being hidden | 215 // Despite the focus change, we need to keep the window being hidden |
| 201 // stacked above the new window so it stays open on top as it animates away. | 216 // stacked above the new window so it stays open on top as it animates away. |
| 202 aura::Window* next_window = GetActiveWindow(); | 217 aura::Window* next_window = GetActiveWindow(); |
| 203 if (next_window && next_window->parent() == window->parent()) { | 218 if (next_window && next_window->parent() == window->parent()) |
| 204 window->layer()->parent()->StackAbove(window->layer(), | 219 StackWindowLayerAbove(window, next_window); |
| 205 next_window->layer()); | |
| 206 } | |
| 207 } | 220 } |
| 208 } | 221 } |
| 209 | 222 |
| 210 void FocusController::OnWindowDestroying(aura::Window* window) { | 223 void FocusController::OnWindowDestroying(aura::Window* window) { |
| 211 WindowLostFocusFromDispositionChange(window, window->parent()); | 224 WindowLostFocusFromDispositionChange(window, window->parent()); |
| 212 } | 225 } |
| 213 | 226 |
| 214 void FocusController::OnWindowHierarchyChanging( | 227 void FocusController::OnWindowHierarchyChanging( |
| 215 const HierarchyChangeParams& params) { | 228 const HierarchyChangeParams& params) { |
| 216 if (params.receiver == active_window_ && | 229 if (params.receiver == active_window_ && |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 SetFocusedWindow(rules_->GetFocusableWindow(next)); | 330 SetFocusedWindow(rules_->GetFocusableWindow(next)); |
| 318 } | 331 } |
| 319 } | 332 } |
| 320 | 333 |
| 321 void FocusController::WindowFocusedFromInputEvent(aura::Window* window) { | 334 void FocusController::WindowFocusedFromInputEvent(aura::Window* window) { |
| 322 FocusWindow(window); | 335 FocusWindow(window); |
| 323 } | 336 } |
| 324 | 337 |
| 325 } // namespace corewm | 338 } // namespace corewm |
| 326 } // namespace views | 339 } // namespace views |
| OLD | NEW |