Chromium Code Reviews| Index: ash/wm/window_mirror_view.cc |
| diff --git a/ash/wm/window_mirror_view.cc b/ash/wm/window_mirror_view.cc |
| index 1c50ecb5a2e7ed5a4c87b8bfb2eaf67644541ac6..00d426ffc50bc027369113e18db6fb303500486f 100644 |
| --- a/ash/wm/window_mirror_view.cc |
| +++ b/ash/wm/window_mirror_view.cc |
| @@ -11,6 +11,7 @@ |
| #include "ui/aura/window.h" |
| #include "ui/compositor/layer.h" |
| #include "ui/compositor/layer_tree_owner.h" |
| +#include "ui/views/widget/widget.h" |
| namespace ash { |
| namespace wm { |
| @@ -34,27 +35,24 @@ WindowMirrorView::WindowMirrorView(WmWindowAura* window) : target_(window) { |
| } |
| WindowMirrorView::~WindowMirrorView() {} |
| -void WindowMirrorView::Init() { |
| - SetPaintToLayer(true); |
| - |
| - layer_owner_ = ::wm::RecreateLayers(target_->aura_window(), this); |
| - |
| - GetMirrorLayer()->parent()->Remove(GetMirrorLayer()); |
| - layer()->Add(GetMirrorLayer()); |
| - |
| - // Some extra work is needed when the target window is minimized. |
| - if (target_->GetWindowState()->IsMinimized()) { |
| - GetMirrorLayer()->SetVisible(true); |
| - GetMirrorLayer()->SetOpacity(1); |
| - EnsureAllChildrenAreVisible(GetMirrorLayer()); |
| - } |
| -} |
| - |
| gfx::Size WindowMirrorView::GetPreferredSize() const { |
| return target_->GetBounds().size(); |
| } |
| void WindowMirrorView::Layout() { |
| + // Ensure the layer owner exists, but only if |this| is actually visible. |
| + if (!layer_owner_) { |
| + if (!GetVisibleBounds().IsEmpty()) { |
| + InitLayerOwner(); |
| + } else { |
| + // If |this| isn't on screen, no-op. We call InvalidateLayout() so |
| + // Layout() will get called again next time even if the bounds haven't |
| + // changed. |
| + InvalidateLayout(); |
|
sky
2016/08/01 20:55:57
Are you sure you want that and not overriding GetN
Evan Stade
2016/08/01 22:11:14
a) We don't really want notifications after the in
sky
2016/08/02 16:21:27
That's no different than the if (!layer_owner_) he
Evan Stade
2016/08/02 18:22:55
OK, I'll try it the other way because it's easier
|
| + return; |
| + } |
| + } |
| + |
| // Position at 0, 0. |
| GetMirrorLayer()->SetBounds(gfx::Rect(GetMirrorLayer()->bounds().size())); |
| @@ -78,6 +76,22 @@ ui::LayerDelegate* WindowMirrorView::CreateDelegate( |
| return delegates_.back().get(); |
| } |
| +void WindowMirrorView::InitLayerOwner() { |
| + SetPaintToLayer(true); |
| + |
| + layer_owner_ = ::wm::RecreateLayers(target_->aura_window(), this); |
| + |
| + GetMirrorLayer()->parent()->Remove(GetMirrorLayer()); |
| + layer()->Add(GetMirrorLayer()); |
| + |
| + // Some extra work is needed when the target window is minimized. |
| + if (target_->GetWindowState()->IsMinimized()) { |
| + GetMirrorLayer()->SetVisible(true); |
| + GetMirrorLayer()->SetOpacity(1); |
| + EnsureAllChildrenAreVisible(GetMirrorLayer()); |
| + } |
| +} |
| + |
| ui::Layer* WindowMirrorView::GetMirrorLayer() { |
| return layer_owner_->root(); |
| } |