Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(786)

Side by Side Diff: ui/views/corewm/focus_controller.cc

Issue 115453004: Moves management of transients out of Window (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix MRUWindowTracker and MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/events/event.h" 13 #include "ui/events/event.h"
14 #include "ui/views/corewm/focus_rules.h" 14 #include "ui/views/corewm/focus_rules.h"
15 #include "ui/views/corewm/transient_window_manager.h"
15 16
16 namespace views { 17 namespace views {
17 namespace corewm { 18 namespace corewm {
18 namespace { 19 namespace {
19 20
20 // When a modal window is activated, we bring its entire transient parent chain 21 // When a modal window is activated, we bring its entire transient parent chain
21 // to the front. This function must be called before the modal transient is 22 // to the front. This function must be called before the modal transient is
22 // stacked at the top to ensure correct stacking order. 23 // stacked at the top to ensure correct stacking order.
23 void StackTransientParentsBelowModalWindow(aura::Window* window) { 24 void StackTransientParentsBelowModalWindow(aura::Window* window) {
24 if (window->GetProperty(aura::client::kModalKey) != ui::MODAL_TYPE_WINDOW) 25 if (window->GetProperty(aura::client::kModalKey) != ui::MODAL_TYPE_WINDOW)
25 return; 26 return;
26 27
27 aura::Window* transient_parent = window->transient_parent(); 28 aura::Window* transient_parent = views::corewm::GetTransientParent(window);
28 while (transient_parent) { 29 while (transient_parent) {
29 transient_parent->parent()->StackChildAtTop(transient_parent); 30 transient_parent->parent()->StackChildAtTop(transient_parent);
30 transient_parent = transient_parent->transient_parent(); 31 transient_parent = views::corewm::GetTransientParent(transient_parent);
31 } 32 }
32 } 33 }
33 34
34 // Stack's |window|'s layer above |relative_to|'s layer. 35 // Stack's |window|'s layer above |relative_to|'s layer.
35 void StackWindowLayerAbove(aura::Window* window, aura::Window* relative_to) { 36 void StackWindowLayerAbove(aura::Window* window, aura::Window* relative_to) {
36 // Stack |window| above the last transient child of |relative_to| that shares 37 // Stack |window| above the last transient child of |relative_to| that shares
37 // the same parent. 38 // the same parent.
38 const aura::Window::Windows& window_transients( 39 const aura::Window::Windows& window_transients(
39 relative_to->transient_children()); 40 GetTransientChildren(relative_to));
40 for (aura::Window::Windows::const_iterator i = window_transients.begin(); 41 for (aura::Window::Windows::const_iterator i = window_transients.begin();
41 i != window_transients.end(); ++i) { 42 i != window_transients.end(); ++i) {
42 aura::Window* transient = *i; 43 aura::Window* transient = *i;
43 if (transient->parent() == relative_to->parent()) 44 if (transient->parent() == relative_to->parent())
44 relative_to = transient; 45 relative_to = transient;
45 } 46 }
46 if (window != relative_to) { 47 if (window != relative_to) {
47 window->layer()->parent()->StackAbove(window->layer(), 48 window->layer()->parent()->StackAbove(window->layer(),
48 relative_to->layer()); 49 relative_to->layer());
49 } 50 }
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 void FocusController::WindowFocusedFromInputEvent(aura::Window* window) { 344 void FocusController::WindowFocusedFromInputEvent(aura::Window* window) {
344 // Only focus |window| if it or any of its parents can be focused. Otherwise 345 // Only focus |window| if it or any of its parents can be focused. Otherwise
345 // FocusWindow() will focus the topmost window, which may not be the 346 // FocusWindow() will focus the topmost window, which may not be the
346 // currently focused one. 347 // currently focused one.
347 if (rules_->CanFocusWindow(GetToplevelWindow(window))) 348 if (rules_->CanFocusWindow(GetToplevelWindow(window)))
348 FocusWindow(window); 349 FocusWindow(window);
349 } 350 }
350 351
351 } // namespace corewm 352 } // namespace corewm
352 } // namespace views 353 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698