| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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/window_mirror_view.h" | 5 #include "ash/wm/window_mirror_view.h" |
| 6 | 6 |
| 7 #include "ash/aura/wm_window_aura.h" | 7 #include "ash/aura/wm_window_aura.h" |
| 8 #include "ash/common/wm/forwarding_layer_delegate.h" | 8 #include "ash/common/wm/forwarding_layer_delegate.h" |
| 9 #include "ash/common/wm/window_state.h" | 9 #include "ash/common/wm/window_state.h" |
| 10 #include "ash/wm/window_state_aura.h" | 10 #include "ash/wm/window_state_aura.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 base::MakeUnique<ForwardingLayerDelegate>(new_layer, old_layer)); | 82 base::MakeUnique<ForwardingLayerDelegate>(new_layer, old_layer)); |
| 83 return delegates_.back().get(); | 83 return delegates_.back().get(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void WindowMirrorView::InitLayerOwner() { | 86 void WindowMirrorView::InitLayerOwner() { |
| 87 if (!layer_owner_) { | 87 if (!layer_owner_) { |
| 88 target_->aura_window()->SetProperty(aura::client::kMirroringEnabledKey, | 88 target_->aura_window()->SetProperty(aura::client::kMirroringEnabledKey, |
| 89 true); | 89 true); |
| 90 } | 90 } |
| 91 | 91 |
| 92 layer_owner_ = ::wm::RecreateLayers(target_->aura_window(), this); | 92 layer_owner_ = |
| 93 ::wm::MirrorLayers(target_->aura_window(), this, false /* sync_bounds */); |
| 93 | 94 |
| 94 GetMirrorLayer()->parent()->Remove(GetMirrorLayer()); | |
| 95 SetPaintToLayer(true); | 95 SetPaintToLayer(true); |
| 96 layer()->Add(GetMirrorLayer()); | 96 layer()->Add(GetMirrorLayer()); |
| 97 // This causes us to clip the non-client areas of the window. | 97 // This causes us to clip the non-client areas of the window. |
| 98 layer()->SetMasksToBounds(true); | 98 layer()->SetMasksToBounds(true); |
| 99 | 99 |
| 100 // Some extra work is needed when the target window is minimized. | 100 // Some extra work is needed when the target window is minimized. |
| 101 if (target_->GetWindowState()->IsMinimized()) { | 101 if (target_->GetWindowState()->IsMinimized()) { |
| 102 GetMirrorLayer()->SetOpacity(1); | 102 GetMirrorLayer()->SetOpacity(1); |
| 103 EnsureAllChildrenAreVisible(GetMirrorLayer()); | 103 EnsureAllChildrenAreVisible(GetMirrorLayer()); |
| 104 } | 104 } |
| 105 | 105 |
| 106 Layout(); | 106 Layout(); |
| 107 } | 107 } |
| 108 | 108 |
| 109 ui::Layer* WindowMirrorView::GetMirrorLayer() { | 109 ui::Layer* WindowMirrorView::GetMirrorLayer() { |
| 110 return layer_owner_->root(); | 110 return layer_owner_->root(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 gfx::Rect WindowMirrorView::GetClientAreaBounds() const { | 113 gfx::Rect WindowMirrorView::GetClientAreaBounds() const { |
| 114 // The target window may not have a widget in unit tests. | 114 // The target window may not have a widget in unit tests. |
| 115 if (!target_->GetInternalWidget()) | 115 if (!target_->GetInternalWidget()) |
| 116 return gfx::Rect(); | 116 return gfx::Rect(); |
| 117 views::View* client_view = target_->GetInternalWidget()->client_view(); | 117 views::View* client_view = target_->GetInternalWidget()->client_view(); |
| 118 return client_view->ConvertRectToWidget(client_view->GetLocalBounds()); | 118 return client_view->ConvertRectToWidget(client_view->GetLocalBounds()); |
| 119 } | 119 } |
| 120 | 120 |
| 121 } // namespace wm | 121 } // namespace wm |
| 122 } // namespace ash | 122 } // namespace ash |
| OLD | NEW |