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/common/wm/root_window_layout_manager.h" | 5 #include "ash/common/wm/root_window_layout_manager.h" |
6 | 6 |
7 #include "ash/common/wm_window.h" | 7 #include "ash/common/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 namespace wm { | |
13 | 12 |
14 //////////////////////////////////////////////////////////////////////////////// | 13 namespace { |
15 // RootWindowLayoutManager, public: | |
16 | 14 |
17 RootWindowLayoutManager::RootWindowLayoutManager(WmWindow* owner) | 15 void ResizeWindow(const aura::Window::Windows& children, |
18 : owner_(owner) {} | 16 const gfx::Rect& fullscreen_bounds, |
19 | 17 int depth) { |
20 RootWindowLayoutManager::~RootWindowLayoutManager() {} | 18 // Stop to prevent resizing non top level window such as tooltip. |
21 | 19 if (depth > 3) |
22 //////////////////////////////////////////////////////////////////////////////// | 20 return; |
oshima
2017/04/06 16:34:15
I think this is ok in this CL, but we should make
wutao
2017/04/08 02:07:10
Acknowledged.
| |
23 // RootWindowLayoutManager, aura::LayoutManager implementation: | |
24 | |
25 void RootWindowLayoutManager::OnWindowResized() { | |
26 const gfx::Rect fullscreen_bounds = gfx::Rect(owner_->GetBounds().size()); | |
27 | 21 |
28 // Resize both our immediate children (the containers-of-containers animated | 22 // Resize both our immediate children (the containers-of-containers animated |
29 // by PowerButtonController) and their children (the actual containers). | 23 // by PowerButtonController) and their children (the actual containers). |
30 aura::WindowTracker children_tracker(owner_->aura_window()->children()); | 24 aura::WindowTracker children_tracker(children); |
31 while (!children_tracker.windows().empty()) { | 25 while (!children_tracker.windows().empty()) { |
32 aura::Window* child = children_tracker.Pop(); | 26 aura::Window* child = children_tracker.Pop(); |
33 // Skip descendants of top-level windows, i.e. only resize containers and | 27 // Skip descendants of top-level windows, i.e. only resize containers and |
34 // other windows without a delegate, such as ScreenDimmer windows. | 28 // other windows without a delegate, such as ScreenDimmer windows. |
35 if (child->GetToplevelWindow()) | 29 if (child->GetToplevelWindow()) |
36 continue; | 30 continue; |
37 | 31 |
38 child->SetBounds(fullscreen_bounds); | 32 child->SetBounds(fullscreen_bounds); |
39 aura::WindowTracker grandchildren_tracker(child->children()); | 33 ResizeWindow(child->children(), fullscreen_bounds, depth + 1); |
oshima
2017/04/06 16:34:15
can you define child_depth instead of adding every
wutao
2017/04/08 02:07:10
Done.
| |
40 while (!grandchildren_tracker.windows().empty()) { | |
41 child = grandchildren_tracker.Pop(); | |
42 if (!child->GetToplevelWindow()) | |
43 child->SetBounds(fullscreen_bounds); | |
44 } | |
45 } | 34 } |
46 } | 35 } |
47 | 36 |
37 } // namespace | |
38 | |
39 namespace wm { | |
40 | |
41 //////////////////////////////////////////////////////////////////////////////// | |
42 // RootWindowLayoutManager, public: | |
43 | |
44 RootWindowLayoutManager::RootWindowLayoutManager(WmWindow* owner) | |
45 : owner_(owner) {} | |
46 | |
47 RootWindowLayoutManager::~RootWindowLayoutManager() {} | |
48 | |
49 //////////////////////////////////////////////////////////////////////////////// | |
50 // RootWindowLayoutManager, aura::LayoutManager implementation: | |
51 | |
52 void RootWindowLayoutManager::OnWindowResized() { | |
53 ResizeWindow(owner_->aura_window()->children(), | |
54 gfx::Rect(owner_->GetBounds().size()), 1); | |
oshima
2017/04/06 16:34:15
optional: it's probably easier for us to start wit
wutao
2017/04/08 02:07:10
Done.
| |
55 } | |
56 | |
48 void RootWindowLayoutManager::OnWindowAddedToLayout(WmWindow* child) {} | 57 void RootWindowLayoutManager::OnWindowAddedToLayout(WmWindow* child) {} |
49 | 58 |
50 void RootWindowLayoutManager::OnWillRemoveWindowFromLayout(WmWindow* child) {} | 59 void RootWindowLayoutManager::OnWillRemoveWindowFromLayout(WmWindow* child) {} |
51 | 60 |
52 void RootWindowLayoutManager::OnWindowRemovedFromLayout(WmWindow* child) {} | 61 void RootWindowLayoutManager::OnWindowRemovedFromLayout(WmWindow* child) {} |
53 | 62 |
54 void RootWindowLayoutManager::OnChildWindowVisibilityChanged(WmWindow* child, | 63 void RootWindowLayoutManager::OnChildWindowVisibilityChanged(WmWindow* child, |
55 bool visible) {} | 64 bool visible) {} |
56 | 65 |
57 void RootWindowLayoutManager::SetChildBounds( | 66 void RootWindowLayoutManager::SetChildBounds( |
58 WmWindow* child, | 67 WmWindow* child, |
59 const gfx::Rect& requested_bounds) { | 68 const gfx::Rect& requested_bounds) { |
60 child->SetBoundsDirect(requested_bounds); | 69 child->SetBoundsDirect(requested_bounds); |
61 } | 70 } |
62 | 71 |
63 } // namespace wm | 72 } // namespace wm |
64 } // namespace ash | 73 } // namespace ash |
OLD | NEW |