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