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 "ash/wm/root_window_layout_manager.h" | 5 #include "ash/wm/root_window_layout_manager.h" |
6 | 6 |
7 #include "ash/wm_window.h" | 7 #include "ash/wm_window.h" |
8 #include "ui/aura/window.h" | 8 #include "ui/aura/window.h" |
9 #include "ui/aura/window_tracker.h" | 9 #include "ui/aura/window_tracker.h" |
10 | 10 |
11 namespace ash { | 11 namespace ash { |
| 12 |
| 13 namespace { |
| 14 |
| 15 // Resize all container windows that RootWindowLayoutManager is responsible for. |
| 16 // That includes all container windows up to three depth except that top level |
| 17 // window which has a delegate. We cannot simply check top level window, because |
| 18 // we need to skip other windows without a delegate, such as ScreenDimmer |
| 19 // windows. |
| 20 // TODO(wutao): The above logic is error prone. Consider using a Shell window id |
| 21 // to indentify such a container. |
| 22 void ResizeWindow(const aura::Window::Windows& children, |
| 23 const gfx::Rect& fullscreen_bounds, |
| 24 int depth) { |
| 25 if (depth > 2) |
| 26 return; |
| 27 const int child_depth = depth + 1; |
| 28 aura::WindowTracker children_tracker(children); |
| 29 while (!children_tracker.windows().empty()) { |
| 30 aura::Window* child = children_tracker.Pop(); |
| 31 if (child->GetToplevelWindow()) |
| 32 continue; |
| 33 child->SetBounds(fullscreen_bounds); |
| 34 ResizeWindow(child->children(), fullscreen_bounds, child_depth); |
| 35 } |
| 36 } |
| 37 |
| 38 } // namespace |
| 39 |
12 namespace wm { | 40 namespace wm { |
13 | 41 |
14 //////////////////////////////////////////////////////////////////////////////// | 42 //////////////////////////////////////////////////////////////////////////////// |
15 // RootWindowLayoutManager, public: | 43 // RootWindowLayoutManager, public: |
16 | 44 |
17 RootWindowLayoutManager::RootWindowLayoutManager(WmWindow* owner) | 45 RootWindowLayoutManager::RootWindowLayoutManager(WmWindow* owner) |
18 : owner_(owner) {} | 46 : owner_(owner) {} |
19 | 47 |
20 RootWindowLayoutManager::~RootWindowLayoutManager() {} | 48 RootWindowLayoutManager::~RootWindowLayoutManager() {} |
21 | 49 |
22 //////////////////////////////////////////////////////////////////////////////// | 50 //////////////////////////////////////////////////////////////////////////////// |
23 // RootWindowLayoutManager, aura::LayoutManager implementation: | 51 // RootWindowLayoutManager, aura::LayoutManager implementation: |
24 | 52 |
25 void RootWindowLayoutManager::OnWindowResized() { | 53 void RootWindowLayoutManager::OnWindowResized() { |
26 const gfx::Rect fullscreen_bounds = gfx::Rect(owner_->GetBounds().size()); | 54 ResizeWindow(owner_->aura_window()->children(), |
27 | 55 gfx::Rect(owner_->GetBounds().size()), 0); |
28 // Resize both our immediate children (the containers-of-containers animated | |
29 // by PowerButtonController) and their children (the actual containers). | |
30 aura::WindowTracker children_tracker(owner_->aura_window()->children()); | |
31 while (!children_tracker.windows().empty()) { | |
32 aura::Window* child = children_tracker.Pop(); | |
33 // Skip descendants of top-level windows, i.e. only resize containers and | |
34 // other windows without a delegate, such as ScreenDimmer windows. | |
35 if (child->GetToplevelWindow()) | |
36 continue; | |
37 | |
38 child->SetBounds(fullscreen_bounds); | |
39 aura::WindowTracker grandchildren_tracker(child->children()); | |
40 while (!grandchildren_tracker.windows().empty()) { | |
41 child = grandchildren_tracker.Pop(); | |
42 if (!child->GetToplevelWindow()) | |
43 child->SetBounds(fullscreen_bounds); | |
44 } | |
45 } | |
46 } | 56 } |
47 | 57 |
48 void RootWindowLayoutManager::OnWindowAddedToLayout(WmWindow* child) {} | 58 void RootWindowLayoutManager::OnWindowAddedToLayout(WmWindow* child) {} |
49 | 59 |
50 void RootWindowLayoutManager::OnWillRemoveWindowFromLayout(WmWindow* child) {} | 60 void RootWindowLayoutManager::OnWillRemoveWindowFromLayout(WmWindow* child) {} |
51 | 61 |
52 void RootWindowLayoutManager::OnWindowRemovedFromLayout(WmWindow* child) {} | 62 void RootWindowLayoutManager::OnWindowRemovedFromLayout(WmWindow* child) {} |
53 | 63 |
54 void RootWindowLayoutManager::OnChildWindowVisibilityChanged(WmWindow* child, | 64 void RootWindowLayoutManager::OnChildWindowVisibilityChanged(WmWindow* child, |
55 bool visible) {} | 65 bool visible) {} |
56 | 66 |
57 void RootWindowLayoutManager::SetChildBounds( | 67 void RootWindowLayoutManager::SetChildBounds( |
58 WmWindow* child, | 68 WmWindow* child, |
59 const gfx::Rect& requested_bounds) { | 69 const gfx::Rect& requested_bounds) { |
60 child->SetBoundsDirect(requested_bounds); | 70 child->SetBoundsDirect(requested_bounds); |
61 } | 71 } |
62 | 72 |
63 } // namespace wm | 73 } // namespace wm |
64 } // namespace ash | 74 } // namespace ash |
OLD | NEW |