| 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..e797dc9f1d7cccbafe8ebdf75ae293ddfd9fe81d 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,15 @@ 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() {
|
| + // If |layer_owner_| hasn't been initialized (|this| isn't on screen), no-op.
|
| + if (!layer_owner_)
|
| + return;
|
| +
|
| // Position at 0, 0.
|
| GetMirrorLayer()->SetBounds(gfx::Rect(GetMirrorLayer()->bounds().size()));
|
|
|
| @@ -68,6 +57,15 @@ void WindowMirrorView::Layout() {
|
| GetMirrorLayer()->SetTransform(mirror_transform);
|
| }
|
|
|
| +bool WindowMirrorView::GetNeedsNotificationWhenVisibleBoundsChange() const {
|
| + return true;
|
| +}
|
| +
|
| +void WindowMirrorView::OnVisibleBoundsChanged() {
|
| + if (!layer_owner_ && !GetVisibleBounds().IsEmpty())
|
| + InitLayerOwner();
|
| +}
|
| +
|
| ui::LayerDelegate* WindowMirrorView::CreateDelegate(
|
| ui::LayerDelegate* delegate) {
|
| if (!delegate)
|
| @@ -78,6 +76,24 @@ 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());
|
| + }
|
| +
|
| + Layout();
|
| +}
|
| +
|
| ui::Layer* WindowMirrorView::GetMirrorLayer() {
|
| return layer_owner_->root();
|
| }
|
|
|