Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: ash/wm/window_mirror_view.cc

Issue 2254733003: Add ui::LayerObserver and use it to update Alt+Tab previews as needed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: layer owner Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 bool WindowMirrorView::GetNeedsNotificationWhenVisibleBoundsChange() const { 63 bool WindowMirrorView::GetNeedsNotificationWhenVisibleBoundsChange() const {
64 return true; 64 return true;
65 } 65 }
66 66
67 void WindowMirrorView::OnVisibleBoundsChanged() { 67 void WindowMirrorView::OnVisibleBoundsChanged() {
68 if (!layer_owner_ && !GetVisibleBounds().IsEmpty()) 68 if (!layer_owner_ && !GetVisibleBounds().IsEmpty())
69 InitLayerOwner(); 69 InitLayerOwner();
70 } 70 }
71 71
72 ui::LayerDelegate* WindowMirrorView::CreateDelegate( 72 ui::LayerDelegate* WindowMirrorView::CreateDelegate(ui::Layer* new_layer,
73 ui::LayerDelegate* delegate) { 73 ui::Layer* old_layer) {
74 if (!delegate) 74 if (!old_layer || !old_layer->delegate())
75 return nullptr; 75 return nullptr;
76
76 delegates_.push_back( 77 delegates_.push_back(
77 base::WrapUnique(new ForwardingLayerDelegate(target_, delegate))); 78 base::WrapUnique(new ForwardingLayerDelegate(new_layer, old_layer)));
78
79 return delegates_.back().get(); 79 return delegates_.back().get();
80 } 80 }
81 81
82 void WindowMirrorView::InitLayerOwner() { 82 void WindowMirrorView::InitLayerOwner() {
83 SetPaintToLayer(true); 83 SetPaintToLayer(true);
84 84
85 layer_owner_ = ::wm::RecreateLayers(target_->aura_window(), this); 85 layer_owner_ = ::wm::RecreateLayers(target_->aura_window(), this);
86 86
87 GetMirrorLayer()->parent()->Remove(GetMirrorLayer()); 87 GetMirrorLayer()->parent()->Remove(GetMirrorLayer());
88 layer()->Add(GetMirrorLayer()); 88 layer()->Add(GetMirrorLayer());
89 // This causes us to clip the non-client areas of the window. 89 // This causes us to clip the non-client areas of the window.
90 layer()->SetMasksToBounds(true); 90 layer()->SetMasksToBounds(true);
91 91
92 // Some extra work is needed when the target window is minimized. 92 // Some extra work is needed when the target window is minimized.
93 if (target_->GetWindowState()->IsMinimized()) { 93 if (target_->GetWindowState()->IsMinimized()) {
94 GetMirrorLayer()->SetVisible(true);
95 GetMirrorLayer()->SetOpacity(1); 94 GetMirrorLayer()->SetOpacity(1);
96 EnsureAllChildrenAreVisible(GetMirrorLayer()); 95 EnsureAllChildrenAreVisible(GetMirrorLayer());
97 } 96 }
98 97
99 Layout(); 98 Layout();
100 } 99 }
101 100
102 ui::Layer* WindowMirrorView::GetMirrorLayer() { 101 ui::Layer* WindowMirrorView::GetMirrorLayer() {
103 return layer_owner_->root(); 102 return layer_owner_->root();
104 } 103 }
105 104
106 gfx::Rect WindowMirrorView::GetClientAreaBounds() const { 105 gfx::Rect WindowMirrorView::GetClientAreaBounds() const {
107 // The target window may not have a widget in unit tests. 106 // The target window may not have a widget in unit tests.
108 if (!target_->GetInternalWidget()) 107 if (!target_->GetInternalWidget())
109 return gfx::Rect(); 108 return gfx::Rect();
110 views::View* client_view = target_->GetInternalWidget()->client_view(); 109 views::View* client_view = target_->GetInternalWidget()->client_view();
111 return client_view->ConvertRectToWidget(client_view->GetLocalBounds()); 110 return client_view->ConvertRectToWidget(client_view->GetLocalBounds());
112 } 111 }
113 112
114 } // namespace wm 113 } // namespace wm
115 } // namespace ash 114 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698