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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 67 |
68 bool WindowMirrorView::GetNeedsNotificationWhenVisibleBoundsChange() const { | 68 bool WindowMirrorView::GetNeedsNotificationWhenVisibleBoundsChange() const { |
69 return true; | 69 return true; |
70 } | 70 } |
71 | 71 |
72 void WindowMirrorView::OnVisibleBoundsChanged() { | 72 void WindowMirrorView::OnVisibleBoundsChanged() { |
73 if (!layer_owner_ && !GetVisibleBounds().IsEmpty()) | 73 if (!layer_owner_ && !GetVisibleBounds().IsEmpty()) |
74 InitLayerOwner(); | 74 InitLayerOwner(); |
75 } | 75 } |
76 | 76 |
77 ui::LayerDelegate* WindowMirrorView::CreateDelegate( | 77 ui::LayerDelegate* WindowMirrorView::CreateDelegate(ui::Layer* new_layer, |
78 ui::LayerDelegate* delegate) { | 78 ui::Layer* old_layer) { |
79 if (!delegate) | 79 if (!old_layer || !old_layer->delegate()) |
80 return nullptr; | 80 return nullptr; |
81 delegates_.push_back( | 81 delegates_.push_back( |
82 base::MakeUnique<ForwardingLayerDelegate>(target_, delegate)); | 82 base::MakeUnique<ForwardingLayerDelegate>(new_layer, old_layer)); |
83 | |
84 return delegates_.back().get(); | 83 return delegates_.back().get(); |
85 } | 84 } |
86 | 85 |
87 void WindowMirrorView::InitLayerOwner() { | 86 void WindowMirrorView::InitLayerOwner() { |
88 if (!layer_owner_) { | 87 if (!layer_owner_) { |
89 target_->aura_window()->SetProperty(aura::client::kMirroringEnabledKey, | 88 target_->aura_window()->SetProperty(aura::client::kMirroringEnabledKey, |
90 true); | 89 true); |
91 } | 90 } |
92 | 91 |
93 layer_owner_ = ::wm::RecreateLayers(target_->aura_window(), this); | 92 layer_owner_ = ::wm::RecreateLayers(target_->aura_window(), this); |
(...skipping 20 matching lines...) Expand all Loading... |
114 gfx::Rect WindowMirrorView::GetClientAreaBounds() const { | 113 gfx::Rect WindowMirrorView::GetClientAreaBounds() const { |
115 // The target window may not have a widget in unit tests. | 114 // The target window may not have a widget in unit tests. |
116 if (!target_->GetInternalWidget()) | 115 if (!target_->GetInternalWidget()) |
117 return gfx::Rect(); | 116 return gfx::Rect(); |
118 views::View* client_view = target_->GetInternalWidget()->client_view(); | 117 views::View* client_view = target_->GetInternalWidget()->client_view(); |
119 return client_view->ConvertRectToWidget(client_view->GetLocalBounds()); | 118 return client_view->ConvertRectToWidget(client_view->GetLocalBounds()); |
120 } | 119 } |
121 | 120 |
122 } // namespace wm | 121 } // namespace wm |
123 } // namespace ash | 122 } // namespace ash |
OLD | NEW |