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/system/status_area_layout_manager.h" | 5 #include "ash/system/status_area_layout_manager.h" |
6 | 6 |
7 #include "ash/shelf/shelf_layout_manager.h" | 7 #include "ash/shelf/shelf_layout_manager.h" |
8 #include "ash/shelf/shelf_widget.h" | 8 #include "ash/shelf/shelf_widget.h" |
9 #include "ash/system/status_area_widget.h" | 9 #include "ash/system/status_area_widget.h" |
10 #include "ash/wm_window.h" | |
11 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| 11 #include "ui/aura/window.h" |
12 | 12 |
13 namespace ash { | 13 namespace ash { |
14 | 14 |
15 //////////////////////////////////////////////////////////////////////////////// | 15 //////////////////////////////////////////////////////////////////////////////// |
16 // StatusAreaLayoutManager, public: | 16 // StatusAreaLayoutManager, public: |
17 | 17 |
18 StatusAreaLayoutManager::StatusAreaLayoutManager(ShelfWidget* shelf_widget) | 18 StatusAreaLayoutManager::StatusAreaLayoutManager(ShelfWidget* shelf_widget) |
19 : in_layout_(false), shelf_widget_(shelf_widget) {} | 19 : in_layout_(false), shelf_widget_(shelf_widget) {} |
20 | 20 |
21 StatusAreaLayoutManager::~StatusAreaLayoutManager() {} | 21 StatusAreaLayoutManager::~StatusAreaLayoutManager() {} |
22 | 22 |
23 //////////////////////////////////////////////////////////////////////////////// | 23 //////////////////////////////////////////////////////////////////////////////// |
24 // StatusAreaLayoutManager, aura::LayoutManager implementation: | 24 // StatusAreaLayoutManager, aura::LayoutManager implementation: |
25 | 25 |
26 void StatusAreaLayoutManager::OnWindowResized() { | 26 void StatusAreaLayoutManager::OnWindowResized() { |
27 LayoutStatusArea(); | 27 LayoutStatusArea(); |
28 } | 28 } |
29 | 29 |
30 void StatusAreaLayoutManager::SetChildBounds( | 30 void StatusAreaLayoutManager::SetChildBounds( |
31 WmWindow* child, | 31 aura::Window* child, |
32 const gfx::Rect& requested_bounds) { | 32 const gfx::Rect& requested_bounds) { |
33 // Only need to have the shelf do a layout if the child changing is the status | 33 // Only need to have the shelf do a layout if the child changing is the status |
34 // area and the shelf isn't in the process of doing a layout. | 34 // area and the shelf isn't in the process of doing a layout. |
35 if (child != WmWindow::Get( | 35 if (child != shelf_widget_->status_area_widget()->GetNativeWindow() || |
36 shelf_widget_->status_area_widget()->GetNativeWindow()) || | |
37 in_layout_) { | 36 in_layout_) { |
38 wm::WmSnapToPixelLayoutManager::SetChildBounds(child, requested_bounds); | 37 wm::WmSnapToPixelLayoutManager::SetChildBounds(child, requested_bounds); |
39 return; | 38 return; |
40 } | 39 } |
41 | 40 |
42 // If the bounds match, no need to do anything. Check for target bounds to | 41 // If the bounds match, no need to do anything. Check for target bounds to |
43 // ensure any active animation is retargeted. | 42 // ensure any active animation is retargeted. |
44 if (requested_bounds == child->GetTargetBounds()) | 43 if (requested_bounds == child->GetTargetBounds()) |
45 return; | 44 return; |
46 | 45 |
47 wm::WmSnapToPixelLayoutManager::SetChildBounds(child, requested_bounds); | 46 wm::WmSnapToPixelLayoutManager::SetChildBounds(child, requested_bounds); |
48 LayoutStatusArea(); | 47 LayoutStatusArea(); |
49 } | 48 } |
50 | 49 |
51 //////////////////////////////////////////////////////////////////////////////// | 50 //////////////////////////////////////////////////////////////////////////////// |
52 // StatusAreaLayoutManager, private: | 51 // StatusAreaLayoutManager, private: |
53 | 52 |
54 void StatusAreaLayoutManager::LayoutStatusArea() { | 53 void StatusAreaLayoutManager::LayoutStatusArea() { |
55 // Shelf layout manager may be already doing layout. | 54 // Shelf layout manager may be already doing layout. |
56 if (shelf_widget_->shelf_layout_manager()->updating_bounds()) | 55 if (shelf_widget_->shelf_layout_manager()->updating_bounds()) |
57 return; | 56 return; |
58 | 57 |
59 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true); | 58 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true); |
60 shelf_widget_->shelf_layout_manager()->LayoutShelf(); | 59 shelf_widget_->shelf_layout_manager()->LayoutShelf(); |
61 } | 60 } |
62 | 61 |
63 } // namespace ash | 62 } // namespace ash |
OLD | NEW |