Chromium Code Reviews| 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" |
| 11 #include "ui/aura/client/focus_change_observer.h" | 11 #include "ui/aura/client/focus_change_observer.h" |
| 12 #include "ui/aura/env.h" | 12 #include "ui/aura/env.h" |
| 13 #include "ui/aura/window_tracker.h" | 13 #include "ui/aura/window_tracker.h" |
| 14 #include "ui/events/event.h" | 14 #include "ui/events/event.h" |
| 15 #include "ui/views/corewm/focus_rules.h" | 15 #include "ui/views/corewm/focus_rules.h" |
| 16 #include "ui/views/corewm/window_animations.h" | |
| 16 #include "ui/views/corewm/window_util.h" | 17 #include "ui/views/corewm/window_util.h" |
| 17 | 18 |
| 18 namespace views { | 19 namespace views { |
| 19 namespace corewm { | 20 namespace corewm { |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 // When a modal window is activated, we bring its entire transient parent chain | 23 // When a modal window is activated, we bring its entire transient parent chain |
| 23 // to the front. This function must be called before the modal transient is | 24 // to the front. This function must be called before the modal transient is |
| 24 // stacked at the top to ensure correct stacking order. | 25 // stacked at the top to ensure correct stacking order. |
| 25 void StackTransientParentsBelowModalWindow(aura::Window* window) { | 26 void StackTransientParentsBelowModalWindow(aura::Window* window) { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 39 // the same parent. | 40 // the same parent. |
| 40 const aura::Window::Windows& window_transients( | 41 const aura::Window::Windows& window_transients( |
| 41 GetTransientChildren(relative_to)); | 42 GetTransientChildren(relative_to)); |
| 42 for (aura::Window::Windows::const_iterator i = window_transients.begin(); | 43 for (aura::Window::Windows::const_iterator i = window_transients.begin(); |
| 43 i != window_transients.end(); ++i) { | 44 i != window_transients.end(); ++i) { |
| 44 aura::Window* transient = *i; | 45 aura::Window* transient = *i; |
| 45 if (transient->parent() == relative_to->parent()) | 46 if (transient->parent() == relative_to->parent()) |
| 46 relative_to = transient; | 47 relative_to = transient; |
| 47 } | 48 } |
| 48 if (window != relative_to) { | 49 if (window != relative_to) { |
| 49 window->layer()->parent()->StackAbove(window->layer(), | 50 ui::Layer* hiding_layer = DetachHidingAnimationLayer(window); |
| 50 relative_to->layer()); | 51 if (hiding_layer) { |
| 52 window->layer()->parent()->StackAbove(hiding_layer, | |
| 53 relative_to->layer()); | |
| 54 } | |
| 51 } | 55 } |
| 52 } | 56 } |
| 53 | 57 |
| 54 } // namespace | 58 } // namespace |
| 55 | 59 |
| 56 //////////////////////////////////////////////////////////////////////////////// | 60 //////////////////////////////////////////////////////////////////////////////// |
| 57 // FocusController, public: | 61 // FocusController, public: |
| 58 | 62 |
| 59 FocusController::FocusController(FocusRules* rules) | 63 FocusController::FocusController(FocusRules* rules) |
| 60 : active_window_(NULL), | 64 : active_window_(NULL), |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 208 // FocusController, aura::WindowObserver implementation: | 212 // FocusController, aura::WindowObserver implementation: |
| 209 | 213 |
| 210 void FocusController::OnWindowVisibilityChanged(aura::Window* window, | 214 void FocusController::OnWindowVisibilityChanged(aura::Window* window, |
| 211 bool visible) { | 215 bool visible) { |
| 212 if (!visible) { | 216 if (!visible) { |
| 213 WindowLostFocusFromDispositionChange(window, window->parent()); | 217 WindowLostFocusFromDispositionChange(window, window->parent()); |
| 214 // Despite the focus change, we need to keep the window being hidden | 218 // Despite the focus change, we need to keep the window being hidden |
| 215 // stacked above the new window so it stays open on top as it animates away. | 219 // stacked above the new window so it stays open on top as it animates away. |
| 216 aura::Window* next_window = GetActiveWindow(); | 220 aura::Window* next_window = GetActiveWindow(); |
| 217 if (next_window && next_window->parent() == window->parent()) | 221 if (next_window && next_window->parent() == window->parent()) |
| 218 StackWindowLayerAbove(window, next_window); | 222 StackWindowLayerAbove(window, next_window); |
|
sky
2014/03/05 15:49:05
Is it possible to remove this code entirely and in
oshima
2014/03/05 17:14:22
Only down side is that it will always bring the wi
| |
| 219 } | 223 } |
| 220 } | 224 } |
| 221 | 225 |
| 222 void FocusController::OnWindowDestroying(aura::Window* window) { | 226 void FocusController::OnWindowDestroying(aura::Window* window) { |
| 223 WindowLostFocusFromDispositionChange(window, window->parent()); | 227 WindowLostFocusFromDispositionChange(window, window->parent()); |
| 224 } | 228 } |
| 225 | 229 |
| 226 void FocusController::OnWindowHierarchyChanging( | 230 void FocusController::OnWindowHierarchyChanging( |
| 227 const HierarchyChangeParams& params) { | 231 const HierarchyChangeParams& params) { |
| 228 if (params.receiver == active_window_ && | 232 if (params.receiver == active_window_ && |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 370 void FocusController::WindowFocusedFromInputEvent(aura::Window* window) { | 374 void FocusController::WindowFocusedFromInputEvent(aura::Window* window) { |
| 371 // Only focus |window| if it or any of its parents can be focused. Otherwise | 375 // Only focus |window| if it or any of its parents can be focused. Otherwise |
| 372 // FocusWindow() will focus the topmost window, which may not be the | 376 // FocusWindow() will focus the topmost window, which may not be the |
| 373 // currently focused one. | 377 // currently focused one. |
| 374 if (rules_->CanFocusWindow(GetToplevelWindow(window))) | 378 if (rules_->CanFocusWindow(GetToplevelWindow(window))) |
| 375 FocusWindow(window); | 379 FocusWindow(window); |
| 376 } | 380 } |
| 377 | 381 |
| 378 } // namespace corewm | 382 } // namespace corewm |
| 379 } // namespace views | 383 } // namespace views |
| OLD | NEW |