Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "mash/wm/bridge/mus_layout_manager_adapter.h" | |
| 6 | |
| 7 #include "ash/wm/common/wm_layout_manager.h" | |
| 8 #include "components/mus/public/cpp/window.h" | |
| 9 #include "mash/wm/bridge/wm_window_mus.h" | |
| 10 | |
| 11 namespace mash { | |
| 12 namespace wm { | |
| 13 | |
| 14 MusLayoutManagerAdapter::ChildWindowObserver::ChildWindowObserver( | |
| 15 MusLayoutManagerAdapter* adapter) | |
| 16 : adapter_(adapter) {} | |
| 17 | |
| 18 MusLayoutManagerAdapter::ChildWindowObserver::~ChildWindowObserver() {} | |
| 19 | |
| 20 void MusLayoutManagerAdapter::ChildWindowObserver::OnWindowVisibilityChanged( | |
| 21 mus::Window* window) { | |
| 22 adapter_->layout_manager_->OnChildWindowVisibilityChanged( | |
| 23 WmWindowMus::Get(window), window->visible()); | |
| 24 } | |
| 25 | |
| 26 MusLayoutManagerAdapter::MusLayoutManagerAdapter( | |
| 27 mus::Window* window, | |
| 28 std::unique_ptr<ash::wm::WmLayoutManager> layout_manager) | |
| 29 : window_(window), | |
| 30 child_window_observer_(this), | |
| 31 layout_manager_(std::move(layout_manager)) { | |
| 32 window_->AddObserver(this); | |
| 33 for (mus::Window* child : window_->children()) | |
| 34 child->AddObserver(&child_window_observer_); | |
| 35 } | |
| 36 | |
| 37 MusLayoutManagerAdapter::~MusLayoutManagerAdapter() { | |
| 38 for (mus::Window* child : window_->children()) | |
| 39 child->RemoveObserver(&child_window_observer_); | |
| 40 | |
| 41 window_->RemoveObserver(this); | |
| 42 } | |
| 43 | |
| 44 void MusLayoutManagerAdapter::OnTreeChanging(const TreeChangeParams& params) { | |
| 45 if (params.old_parent == window_) { | |
| 46 layout_manager_->OnWillRemoveWindowFromLayout( | |
| 47 WmWindowMus::Get(params.target)); | |
| 48 } | |
| 49 } | |
| 50 | |
| 51 void MusLayoutManagerAdapter::OnTreeChanged(const TreeChangeParams& params) { | |
| 52 if (params.new_parent == window_) { | |
| 53 layout_manager_->OnWindowAddedToLayout(WmWindowMus::Get(params.target)); | |
| 54 } else if (params.old_parent == window_) { | |
| 55 params.target->RemoveObserver(&child_window_observer_); | |
| 56 layout_manager_->OnWindowRemovedFromLayout(WmWindowMus::Get(params.target)); | |
| 57 } | |
| 58 } | |
| 59 | |
| 60 void MusLayoutManagerAdapter::OnWindowBoundsChanged( | |
| 61 mus::Window* window, | |
| 62 const gfx::Rect& old_bounds, | |
| 63 const gfx::Rect& new_bounds) { | |
| 64 layout_manager_->OnWindowResized(); | |
|
James Cook
2016/05/06 19:46:46
Is this the place where the SetChildBounds() call
sky
2016/05/06 22:12:57
This call is different. This call is to tell the l
| |
| 65 } | |
| 66 | |
| 67 } // namespace wm | |
| 68 } // namespace mash | |
| OLD | NEW |