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

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

Issue 2458833003: Revert of [M55] Generalize layer mirroring for phantom windows (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « ash/wm/window_mirror_view.h ('k') | cc/layers/surface_layer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/window_state.h" 9 #include "ash/common/wm/window_state.h"
9 #include "ash/wm/window_state_aura.h" 10 #include "ash/wm/window_state_aura.h"
10 #include "ui/aura/client/aura_constants.h" 11 #include "ui/aura/client/aura_constants.h"
11 #include "ui/aura/window.h" 12 #include "ui/aura/window.h"
12 #include "ui/compositor/layer.h" 13 #include "ui/compositor/layer.h"
13 #include "ui/compositor/layer_tree_owner.h" 14 #include "ui/compositor/layer_tree_owner.h"
14 #include "ui/views/widget/widget.h" 15 #include "ui/views/widget/widget.h"
15 #include "ui/wm/core/window_util.h"
16 16
17 namespace ash { 17 namespace ash {
18 namespace wm { 18 namespace wm {
19 namespace { 19 namespace {
20 20
21 void EnsureAllChildrenAreVisible(ui::Layer* layer) { 21 void EnsureAllChildrenAreVisible(ui::Layer* layer) {
22 std::list<ui::Layer*> layers; 22 std::list<ui::Layer*> layers;
23 layers.push_back(layer); 23 layers.push_back(layer);
24 while (!layers.empty()) { 24 while (!layers.empty()) {
25 for (auto* child : layers.front()->children()) 25 for (auto* child : layers.front()->children())
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(ui::Layer* new_layer,
78 ui::Layer* old_layer) {
79 if (!old_layer || !old_layer->delegate())
80 return nullptr;
81 delegates_.push_back(
82 base::MakeUnique<ForwardingLayerDelegate>(new_layer, old_layer));
83 return delegates_.back().get();
84 }
85
77 void WindowMirrorView::InitLayerOwner() { 86 void WindowMirrorView::InitLayerOwner() {
78 if (!layer_owner_) { 87 if (!layer_owner_) {
79 target_->aura_window()->SetProperty(aura::client::kMirroringEnabledKey, 88 target_->aura_window()->SetProperty(aura::client::kMirroringEnabledKey,
80 true); 89 true);
81 } 90 }
82 91
83 layer_owner_ = 92 layer_owner_ = ::wm::RecreateLayers(target_->aura_window(), this);
84 ::wm::MirrorLayers(target_->aura_window(), false /* sync_bounds */);
85 93
94 GetMirrorLayer()->parent()->Remove(GetMirrorLayer());
86 SetPaintToLayer(true); 95 SetPaintToLayer(true);
87 layer()->Add(GetMirrorLayer()); 96 layer()->Add(GetMirrorLayer());
88 // 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.
89 layer()->SetMasksToBounds(true); 98 layer()->SetMasksToBounds(true);
90 99
91 // Some extra work is needed when the target window is minimized. 100 // Some extra work is needed when the target window is minimized.
92 if (target_->GetWindowState()->IsMinimized()) { 101 if (target_->GetWindowState()->IsMinimized()) {
93 GetMirrorLayer()->SetOpacity(1); 102 GetMirrorLayer()->SetOpacity(1);
94 EnsureAllChildrenAreVisible(GetMirrorLayer()); 103 EnsureAllChildrenAreVisible(GetMirrorLayer());
95 } 104 }
96 105
97 Layout(); 106 Layout();
98 } 107 }
99 108
100 ui::Layer* WindowMirrorView::GetMirrorLayer() { 109 ui::Layer* WindowMirrorView::GetMirrorLayer() {
101 return layer_owner_->root(); 110 return layer_owner_->root();
102 } 111 }
103 112
104 gfx::Rect WindowMirrorView::GetClientAreaBounds() const { 113 gfx::Rect WindowMirrorView::GetClientAreaBounds() const {
105 // The target window may not have a widget in unit tests. 114 // The target window may not have a widget in unit tests.
106 if (!target_->GetInternalWidget()) 115 if (!target_->GetInternalWidget())
107 return gfx::Rect(); 116 return gfx::Rect();
108 views::View* client_view = target_->GetInternalWidget()->client_view(); 117 views::View* client_view = target_->GetInternalWidget()->client_view();
109 return client_view->ConvertRectToWidget(client_view->GetLocalBounds()); 118 return client_view->ConvertRectToWidget(client_view->GetLocalBounds());
110 } 119 }
111 120
112 } // namespace wm 121 } // namespace wm
113 } // namespace ash 122 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/window_mirror_view.h ('k') | cc/layers/surface_layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698