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/desktop_background/desktop_background_widget_controller.h" | |
8 #include "ui/aura/window.h" | 7 #include "ui/aura/window.h" |
9 #include "ui/compositor/layer.h" | 8 #include "ui/compositor/layer.h" |
10 #include "ui/views/widget/widget.h" | 9 #include "ui/views/widget/widget.h" |
11 | 10 |
12 namespace ash { | 11 namespace ash { |
13 namespace internal { | 12 namespace internal { |
14 | 13 |
15 //////////////////////////////////////////////////////////////////////////////// | 14 //////////////////////////////////////////////////////////////////////////////// |
16 // RootWindowLayoutManager, public: | 15 // RootWindowLayoutManager, public: |
17 | 16 |
18 RootWindowLayoutManager::RootWindowLayoutManager(aura::Window* owner) | 17 RootWindowLayoutManager::RootWindowLayoutManager(aura::Window* owner) |
19 : owner_(owner) { | 18 : owner_(owner), |
| 19 background_widget_(NULL) { |
20 } | 20 } |
21 | 21 |
22 RootWindowLayoutManager::~RootWindowLayoutManager() { | 22 RootWindowLayoutManager::~RootWindowLayoutManager() { |
23 } | 23 } |
24 | 24 |
| 25 void RootWindowLayoutManager::SetBackgroundWidget(views::Widget* widget) { |
| 26 if (widget == background_widget_) |
| 27 return; |
| 28 // Close now so that the focus manager will be deleted before shutdown. |
| 29 if (background_widget_) |
| 30 background_widget_->CloseNow(); |
| 31 background_widget_ = widget; |
| 32 } |
| 33 |
| 34 void RootWindowLayoutManager::SetBackgroundLayer(ui::Layer* layer) { |
| 35 background_layer_.reset(layer); |
| 36 } |
25 | 37 |
26 //////////////////////////////////////////////////////////////////////////////// | 38 //////////////////////////////////////////////////////////////////////////////// |
27 // RootWindowLayoutManager, aura::LayoutManager implementation: | 39 // RootWindowLayoutManager, aura::LayoutManager implementation: |
28 | 40 |
29 void RootWindowLayoutManager::OnWindowResized() { | 41 void RootWindowLayoutManager::OnWindowResized() { |
30 gfx::Rect fullscreen_bounds = | 42 gfx::Rect fullscreen_bounds = |
31 gfx::Rect(owner_->bounds().width(), owner_->bounds().height()); | 43 gfx::Rect(owner_->bounds().width(), owner_->bounds().height()); |
32 | 44 |
33 // Resize both our immediate children (the containers-of-containers animated | 45 // Resize both our immediate children (the containers-of-containers animated |
34 // by PowerButtonController) and their children (the actual containers). | 46 // by PowerButtonController) and their children (the actual containers). |
35 aura::Window::Windows::const_iterator i; | 47 aura::Window::Windows::const_iterator i; |
36 for (i = owner_->children().begin(); i != owner_->children().end(); ++i) { | 48 for (i = owner_->children().begin(); i != owner_->children().end(); ++i) { |
37 (*i)->SetBounds(fullscreen_bounds); | 49 (*i)->SetBounds(fullscreen_bounds); |
38 aura::Window::Windows::const_iterator j; | 50 aura::Window::Windows::const_iterator j; |
39 for (j = (*i)->children().begin(); j != (*i)->children().end(); ++j) | 51 for (j = (*i)->children().begin(); j != (*i)->children().end(); ++j) |
40 (*j)->SetBounds(fullscreen_bounds); | 52 (*j)->SetBounds(fullscreen_bounds); |
41 } | 53 } |
42 internal::DesktopBackgroundWidgetController* background = | 54 |
43 owner_->GetProperty(internal::kWindowDesktopComponent); | 55 if (background_widget_) |
44 if (background) | 56 background_widget_->SetBounds(fullscreen_bounds); |
45 background->SetBounds(fullscreen_bounds); | 57 if (background_layer_.get()) |
| 58 background_layer_->SetBounds(fullscreen_bounds); |
46 } | 59 } |
47 | 60 |
48 void RootWindowLayoutManager::OnWindowAddedToLayout(aura::Window* child) { | 61 void RootWindowLayoutManager::OnWindowAddedToLayout(aura::Window* child) { |
49 } | 62 } |
50 | 63 |
51 void RootWindowLayoutManager::OnWillRemoveWindowFromLayout( | 64 void RootWindowLayoutManager::OnWillRemoveWindowFromLayout( |
52 aura::Window* child) { | 65 aura::Window* child) { |
53 } | 66 } |
54 | 67 |
55 void RootWindowLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) { | 68 void RootWindowLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) { |
56 } | 69 } |
57 | 70 |
58 void RootWindowLayoutManager::OnChildWindowVisibilityChanged( | 71 void RootWindowLayoutManager::OnChildWindowVisibilityChanged( |
59 aura::Window* child, | 72 aura::Window* child, |
60 bool visible) { | 73 bool visible) { |
61 } | 74 } |
62 | 75 |
63 void RootWindowLayoutManager::SetChildBounds( | 76 void RootWindowLayoutManager::SetChildBounds( |
64 aura::Window* child, | 77 aura::Window* child, |
65 const gfx::Rect& requested_bounds) { | 78 const gfx::Rect& requested_bounds) { |
66 SetChildBoundsDirect(child, requested_bounds); | 79 SetChildBoundsDirect(child, requested_bounds); |
67 } | 80 } |
68 | 81 |
69 } // namespace internal | 82 } // namespace internal |
70 } // namespace ash | 83 } // namespace ash |
OLD | NEW |