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

Side by Side Diff: ui/wm/core/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
« no previous file with comments | « ash/wm/workspace_controller_unittest.cc ('k') | ui/wm/core/focus_controller_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/wm/core/focus_controller.h" 5 #include "ui/wm/core/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 14 matching lines...) Expand all
25 if (window->GetProperty(aura::client::kModalKey) != ui::MODAL_TYPE_WINDOW) 25 if (window->GetProperty(aura::client::kModalKey) != ui::MODAL_TYPE_WINDOW)
26 return; 26 return;
27 27
28 aura::Window* transient_parent = wm::GetTransientParent(window); 28 aura::Window* transient_parent = wm::GetTransientParent(window);
29 while (transient_parent) { 29 while (transient_parent) {
30 transient_parent->parent()->StackChildAtTop(transient_parent); 30 transient_parent->parent()->StackChildAtTop(transient_parent);
31 transient_parent = wm::GetTransientParent(transient_parent); 31 transient_parent = wm::GetTransientParent(transient_parent);
32 } 32 }
33 } 33 }
34 34
35 // Stack's |window|'s layer above |relative_to|'s layer.
36 void StackWindowLayerAbove(aura::Window* window, aura::Window* relative_to) {
37 // Stack |window| above the last transient child of |relative_to| that shares
38 // the same parent.
39 const aura::Window::Windows& window_transients(
40 GetTransientChildren(relative_to));
41 for (aura::Window::Windows::const_iterator i = window_transients.begin();
42 i != window_transients.end(); ++i) {
43 aura::Window* transient = *i;
44 if (transient->parent() == relative_to->parent())
45 relative_to = transient;
46 }
47 if (window != relative_to) {
48 window->layer()->parent()->StackAbove(window->layer(),
49 relative_to->layer());
50 }
51 }
52
53 } // namespace 35 } // namespace
54 36
55 //////////////////////////////////////////////////////////////////////////////// 37 ////////////////////////////////////////////////////////////////////////////////
56 // FocusController, public: 38 // FocusController, public:
57 39
58 FocusController::FocusController(FocusRules* rules) 40 FocusController::FocusController(FocusRules* rules)
59 : active_window_(NULL), 41 : active_window_(NULL),
60 focused_window_(NULL), 42 focused_window_(NULL),
61 updating_focus_(false), 43 updating_focus_(false),
62 updating_activation_(false), 44 updating_activation_(false),
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 event->details().touch_points() == 1) { 183 event->details().touch_points() == 1) {
202 WindowFocusedFromInputEvent(static_cast<aura::Window*>(event->target())); 184 WindowFocusedFromInputEvent(static_cast<aura::Window*>(event->target()));
203 } 185 }
204 } 186 }
205 187
206 //////////////////////////////////////////////////////////////////////////////// 188 ////////////////////////////////////////////////////////////////////////////////
207 // FocusController, aura::WindowObserver implementation: 189 // FocusController, aura::WindowObserver implementation:
208 190
209 void FocusController::OnWindowVisibilityChanged(aura::Window* window, 191 void FocusController::OnWindowVisibilityChanged(aura::Window* window,
210 bool visible) { 192 bool visible) {
211 if (!visible) { 193 if (!visible)
212 WindowLostFocusFromDispositionChange(window, window->parent()); 194 WindowLostFocusFromDispositionChange(window, window->parent());
213 // Despite the focus change, we need to keep the window being hidden
214 // stacked above the new window so it stays open on top as it animates away.
215 aura::Window* next_window = GetActiveWindow();
216 if (next_window && next_window->parent() == window->parent())
217 StackWindowLayerAbove(window, next_window);
218 }
219 } 195 }
220 196
221 void FocusController::OnWindowDestroying(aura::Window* window) { 197 void FocusController::OnWindowDestroying(aura::Window* window) {
222 WindowLostFocusFromDispositionChange(window, window->parent()); 198 WindowLostFocusFromDispositionChange(window, window->parent());
223 } 199 }
224 200
225 void FocusController::OnWindowHierarchyChanging( 201 void FocusController::OnWindowHierarchyChanging(
226 const HierarchyChangeParams& params) { 202 const HierarchyChangeParams& params) {
227 if (params.receiver == active_window_ && 203 if (params.receiver == active_window_ &&
228 params.target->Contains(params.receiver) && (!params.new_parent || 204 params.target->Contains(params.receiver) && (!params.new_parent ||
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 344
369 void FocusController::WindowFocusedFromInputEvent(aura::Window* window) { 345 void FocusController::WindowFocusedFromInputEvent(aura::Window* window) {
370 // Only focus |window| if it or any of its parents can be focused. Otherwise 346 // Only focus |window| if it or any of its parents can be focused. Otherwise
371 // FocusWindow() will focus the topmost window, which may not be the 347 // FocusWindow() will focus the topmost window, which may not be the
372 // currently focused one. 348 // currently focused one.
373 if (rules_->CanFocusWindow(GetToplevelWindow(window))) 349 if (rules_->CanFocusWindow(GetToplevelWindow(window)))
374 FocusWindow(window); 350 FocusWindow(window);
375 } 351 }
376 352
377 } // namespace wm 353 } // namespace wm
OLDNEW
« no previous file with comments | « ash/wm/workspace_controller_unittest.cc ('k') | ui/wm/core/focus_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698