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

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

Issue 180273025: Keep dedicated layers for hiding animation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months 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"
(...skipping 15 matching lines...) Expand all
26 if (window->GetProperty(aura::client::kModalKey) != ui::MODAL_TYPE_WINDOW) 26 if (window->GetProperty(aura::client::kModalKey) != ui::MODAL_TYPE_WINDOW)
27 return; 27 return;
28 28
29 aura::Window* transient_parent = views::corewm::GetTransientParent(window); 29 aura::Window* transient_parent = views::corewm::GetTransientParent(window);
30 while (transient_parent) { 30 while (transient_parent) {
31 transient_parent->parent()->StackChildAtTop(transient_parent); 31 transient_parent->parent()->StackChildAtTop(transient_parent);
32 transient_parent = views::corewm::GetTransientParent(transient_parent); 32 transient_parent = views::corewm::GetTransientParent(transient_parent);
33 } 33 }
34 } 34 }
35 35
36 // Stack's |window|'s layer above |relative_to|'s layer.
37 void StackWindowLayerAbove(aura::Window* window, aura::Window* relative_to) {
38 // Stack |window| above the last transient child of |relative_to| that shares
39 // the same parent.
40 const aura::Window::Windows& window_transients(
41 GetTransientChildren(relative_to));
42 for (aura::Window::Windows::const_iterator i = window_transients.begin();
43 i != window_transients.end(); ++i) {
44 aura::Window* transient = *i;
45 if (transient->parent() == relative_to->parent())
46 relative_to = transient;
47 }
48 if (window != relative_to) {
49 window->layer()->parent()->StackAbove(window->layer(),
50 relative_to->layer());
51 }
52 }
53
54 } // namespace 36 } // namespace
55 37
56 //////////////////////////////////////////////////////////////////////////////// 38 ////////////////////////////////////////////////////////////////////////////////
57 // FocusController, public: 39 // FocusController, public:
58 40
59 FocusController::FocusController(FocusRules* rules) 41 FocusController::FocusController(FocusRules* rules)
60 : active_window_(NULL), 42 : active_window_(NULL),
61 focused_window_(NULL), 43 focused_window_(NULL),
62 updating_focus_(false), 44 updating_focus_(false),
63 updating_activation_(false), 45 updating_activation_(false),
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 event->details().touch_points() == 1) { 184 event->details().touch_points() == 1) {
203 WindowFocusedFromInputEvent(static_cast<aura::Window*>(event->target())); 185 WindowFocusedFromInputEvent(static_cast<aura::Window*>(event->target()));
204 } 186 }
205 } 187 }
206 188
207 //////////////////////////////////////////////////////////////////////////////// 189 ////////////////////////////////////////////////////////////////////////////////
208 // FocusController, aura::WindowObserver implementation: 190 // FocusController, aura::WindowObserver implementation:
209 191
210 void FocusController::OnWindowVisibilityChanged(aura::Window* window, 192 void FocusController::OnWindowVisibilityChanged(aura::Window* window,
211 bool visible) { 193 bool visible) {
212 if (!visible) { 194 if (!visible)
213 WindowLostFocusFromDispositionChange(window, window->parent()); 195 WindowLostFocusFromDispositionChange(window, window->parent());
214 // 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.
216 aura::Window* next_window = GetActiveWindow();
217 if (next_window && next_window->parent() == window->parent())
218 StackWindowLayerAbove(window, next_window);
219 }
220 } 196 }
221 197
222 void FocusController::OnWindowDestroying(aura::Window* window) { 198 void FocusController::OnWindowDestroying(aura::Window* window) {
223 WindowLostFocusFromDispositionChange(window, window->parent()); 199 WindowLostFocusFromDispositionChange(window, window->parent());
224 } 200 }
225 201
226 void FocusController::OnWindowHierarchyChanging( 202 void FocusController::OnWindowHierarchyChanging(
227 const HierarchyChangeParams& params) { 203 const HierarchyChangeParams& params) {
228 if (params.receiver == active_window_ && 204 if (params.receiver == active_window_ &&
229 params.target->Contains(params.receiver) && (!params.new_parent || 205 params.target->Contains(params.receiver) && (!params.new_parent ||
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 void FocusController::WindowFocusedFromInputEvent(aura::Window* window) { 346 void FocusController::WindowFocusedFromInputEvent(aura::Window* window) {
371 // Only focus |window| if it or any of its parents can be focused. Otherwise 347 // 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 348 // FocusWindow() will focus the topmost window, which may not be the
373 // currently focused one. 349 // currently focused one.
374 if (rules_->CanFocusWindow(GetToplevelWindow(window))) 350 if (rules_->CanFocusWindow(GetToplevelWindow(window)))
375 FocusWindow(window); 351 FocusWindow(window);
376 } 352 }
377 353
378 } // namespace corewm 354 } // namespace corewm
379 } // namespace views 355 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698