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/wm/core/window_util.h" | 5 #include "ui/wm/core/window_util.h" |
6 | 6 |
7 #include "ui/aura/window.h" | 7 #include "ui/aura/window.h" |
8 #include "ui/compositor/layer.h" | 8 #include "ui/compositor/layer.h" |
9 #include "ui/compositor/layer_tree_owner.h" | 9 #include "ui/compositor/layer_tree_owner.h" |
10 #include "ui/wm/core/transient_window_manager.h" | 10 #include "ui/wm/core/transient_window_manager.h" |
(...skipping 19 matching lines...) Expand all Loading... | |
30 old_layer->set_delegate( | 30 old_layer->set_delegate( |
31 factory->CreateDelegate(old_layer, owner->layer())); | 31 factory->CreateDelegate(old_layer, owner->layer())); |
32 parent->Add(old_layer); | 32 parent->Add(old_layer); |
33 // RecreateLayer() moves the existing children to the new layer. Create a | 33 // RecreateLayer() moves the existing children to the new layer. Create a |
34 // copy of those. | 34 // copy of those. |
35 CloneChildren(owner->layer(), old_layer, factory); | 35 CloneChildren(owner->layer(), old_layer, factory); |
36 } | 36 } |
37 } | 37 } |
38 } | 38 } |
39 | 39 |
40 // Invokes Mirror() on all the children of |to_mirror|, adding the newly cloned | |
41 // children to |parent|. | |
42 // | |
43 // WARNING: It is assumed that |parent| is ultimately owned by a LayerTreeOwner. | |
44 void MirrorChildren(ui::Layer* to_mirror, | |
45 ui::Layer* parent, | |
46 wm::LayerDelegateFactory* factory) { | |
47 for (auto* child : to_mirror->children()) { | |
48 ui::Layer* mirror = child->Mirror().release(); | |
49 mirror->set_sync_bounds(true); | |
50 if (factory && child->delegate()) | |
51 mirror->set_delegate(factory->CreateDelegate(mirror, child)); | |
52 parent->Add(mirror); | |
53 MirrorChildren(child, mirror, factory); | |
54 } | |
55 } | |
56 | |
40 } // namespace | 57 } // namespace |
41 | 58 |
42 namespace wm { | 59 namespace wm { |
43 | 60 |
44 void ActivateWindow(aura::Window* window) { | 61 void ActivateWindow(aura::Window* window) { |
45 DCHECK(window); | 62 DCHECK(window); |
46 DCHECK(window->GetRootWindow()); | 63 DCHECK(window->GetRootWindow()); |
47 aura::client::GetActivationClient(window->GetRootWindow())->ActivateWindow( | 64 aura::client::GetActivationClient(window->GetRootWindow())->ActivateWindow( |
48 window); | 65 window); |
49 } | 66 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
93 if (old_layer->root()) { | 110 if (old_layer->root()) { |
94 if (factory) { | 111 if (factory) { |
95 old_layer->root()->set_delegate( | 112 old_layer->root()->set_delegate( |
96 factory->CreateDelegate(old_layer->root(), root->layer())); | 113 factory->CreateDelegate(old_layer->root(), root->layer())); |
97 } | 114 } |
98 CloneChildren(root->layer(), old_layer->root(), factory); | 115 CloneChildren(root->layer(), old_layer->root(), factory); |
99 } | 116 } |
100 return old_layer; | 117 return old_layer; |
101 } | 118 } |
102 | 119 |
120 std::unique_ptr<ui::LayerTreeOwner> MirrorLayers( | |
121 ui::LayerOwner* root, | |
122 LayerDelegateFactory* factory) { | |
123 std::unique_ptr<ui::LayerTreeOwner> mirror( | |
124 new ui::LayerTreeOwner(root->layer()->Mirror().release())); | |
sky
2016/10/13 19:21:33
MakeUnique.
optional: using the release here is aw
Dominik Laskowski
2016/10/13 22:19:39
Done.
| |
125 if (factory) { | |
126 mirror->root()->set_delegate( | |
127 factory->CreateDelegate(mirror->root(), root->layer())); | |
128 } | |
129 MirrorChildren(root->layer(), mirror->root(), factory); | |
130 return mirror; | |
131 } | |
132 | |
103 aura::Window* GetTransientParent(aura::Window* window) { | 133 aura::Window* GetTransientParent(aura::Window* window) { |
104 return const_cast<aura::Window*>(GetTransientParent( | 134 return const_cast<aura::Window*>(GetTransientParent( |
105 const_cast<const aura::Window*>(window))); | 135 const_cast<const aura::Window*>(window))); |
106 } | 136 } |
107 | 137 |
108 const aura::Window* GetTransientParent(const aura::Window* window) { | 138 const aura::Window* GetTransientParent(const aura::Window* window) { |
109 const TransientWindowManager* manager = TransientWindowManager::Get(window); | 139 const TransientWindowManager* manager = TransientWindowManager::Get(window); |
110 return manager ? manager->transient_parent() : NULL; | 140 return manager ? manager->transient_parent() : NULL; |
111 } | 141 } |
112 | 142 |
(...skipping 18 matching lines...) Expand all Loading... | |
131 bool HasTransientAncestor(const aura::Window* window, | 161 bool HasTransientAncestor(const aura::Window* window, |
132 const aura::Window* ancestor) { | 162 const aura::Window* ancestor) { |
133 const aura::Window* transient_parent = GetTransientParent(window); | 163 const aura::Window* transient_parent = GetTransientParent(window); |
134 if (transient_parent == ancestor) | 164 if (transient_parent == ancestor) |
135 return true; | 165 return true; |
136 return transient_parent ? | 166 return transient_parent ? |
137 HasTransientAncestor(transient_parent, ancestor) : false; | 167 HasTransientAncestor(transient_parent, ancestor) : false; |
138 } | 168 } |
139 | 169 |
140 } // namespace wm | 170 } // namespace wm |
OLD | NEW |