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

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

Issue 115453004: Moves management of transients out of Window (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove unneeded parens Created 6 years, 11 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 | « ui/views/corewm/window_util.h ('k') | ui/views/corewm/wm_state.h » ('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/views/corewm/window_util.h" 5 #include "ui/views/corewm/window_util.h"
6 6
7 #include "ui/aura/client/activation_client.h" 7 #include "ui/aura/client/activation_client.h"
8 #include "ui/aura/root_window.h" 8 #include "ui/aura/root_window.h"
9 #include "ui/aura/window.h" 9 #include "ui/aura/window.h"
10 #include "ui/compositor/layer.h" 10 #include "ui/compositor/layer.h"
11 #include "ui/views/corewm/transient_window_manager.h"
11 #include "ui/views/view.h" 12 #include "ui/views/view.h"
12 #include "ui/views/widget/widget.h" 13 #include "ui/views/widget/widget.h"
13 14
14 namespace { 15 namespace {
15 16
16 // Helper method for RecreateWindowLayers() which adds all the existing layers 17 // Helper method for RecreateWindowLayers() which adds all the existing layers
17 // for |view| and its descendants to |parent_layer|. New layers are created for 18 // for |view| and its descendants to |parent_layer|. New layers are created for
18 // |view| (if it previously had a layer) and any descendants which previously 19 // |view| (if it previously had a layer) and any descendants which previously
19 // had layers. The new layers are blank, so nothing has been painted to them 20 // had layers. The new layers are blank, so nothing has been painted to them
20 // yet. Returns true if this method added at least one layer to |parent_layer|. 21 // yet. Returns true if this method added at least one layer to |parent_layer|.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 if (it != old_layer->children().end()) 131 if (it != old_layer->children().end())
131 old_layer->StackAtTop(layer); 132 old_layer->StackAtTop(layer);
132 } 133 }
133 } 134 }
134 135
135 if (set_bounds) 136 if (set_bounds)
136 window->SetBounds(bounds); 137 window->SetBounds(bounds);
137 return old_layer; 138 return old_layer;
138 } 139 }
139 140
141 aura::Window* GetTransientParent(aura::Window* window) {
142 return const_cast<aura::Window*>(GetTransientParent(
143 const_cast<const aura::Window*>(window)));
144 }
145
146 const aura::Window* GetTransientParent(const aura::Window* window) {
147 const TransientWindowManager* manager = TransientWindowManager::Get(window);
148 return manager ? manager->transient_parent() : NULL;
149 }
150
151 const std::vector<aura::Window*>& GetTransientChildren(
152 const aura::Window* window) {
153 const TransientWindowManager* manager = TransientWindowManager::Get(window);
154 if (manager)
155 return manager->transient_children();
156
157 static std::vector<aura::Window*>* shared = new std::vector<aura::Window*>;
158 return *shared;
159 }
160
161 void AddTransientChild(aura::Window* parent, aura::Window* child) {
162 TransientWindowManager::Get(parent)->AddTransientChild(child);
163 }
164
165 void RemoveTransientChild(aura::Window* parent, aura::Window* child) {
166 TransientWindowManager::Get(parent)->RemoveTransientChild(child);
167 }
168
169 bool HasTransientAncestor(const aura::Window* window,
170 const aura::Window* ancestor) {
171 const aura::Window* transient_parent = GetTransientParent(window);
172 if (transient_parent == ancestor)
173 return true;
174 return transient_parent ?
175 HasTransientAncestor(transient_parent, ancestor) : false;
176 }
177
140 } // namespace corewm 178 } // namespace corewm
141 } // namespace views 179 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/corewm/window_util.h ('k') | ui/views/corewm/wm_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698