Commit 7d441a0a authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

chromeos: renames WindowMirrorView::target to source

When mirroring I think of the source as the source of the
mirror, and the target where the mirror is being displayed.
That isn't the case here.

BUG=none
TEST=none

Change-Id: Id55075cee0f96871bb6d8b6f47257a4cafad2d09
Reviewed-on: https://chromium-review.googlesource.com/c/1354576Reviewed-by: default avatarMalay Keshav <malaykeshav@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612037}
parent ff7b6c5e
......@@ -112,12 +112,12 @@ bool WindowPreview::OnMousePressed(const ui::MouseEvent& event) {
if (!mirror_->bounds().Contains(event.location()))
return false;
aura::Window* target = mirror_->target();
if (target) {
aura::Window* source = mirror_->source();
if (source) {
// The window might have been closed in the mean time.
// TODO: Use WindowObserver to listen to when previewed windows are
// being closed and remove this condition.
wm::ActivateWindow(target);
wm::ActivateWindow(source);
// This will have the effect of deleting this view.
delegate_->OnPreviewActivated(this);
......@@ -128,14 +128,14 @@ bool WindowPreview::OnMousePressed(const ui::MouseEvent& event) {
void WindowPreview::ButtonPressed(views::Button* sender,
const ui::Event& event) {
// The close button was pressed.
aura::Window* target = mirror_->target();
aura::Window* source = mirror_->source();
// The window might have been closed in the mean time.
// TODO: Use WindowObserver to listen to when previewed windows are
// being closed and remove this condition.
if (!target)
if (!source)
return;
wm::CloseWidgetForWindow(target);
wm::CloseWidgetForWindow(source);
// This will have the effect of deleting this view.
delegate_->OnPreviewDismissed(this);
......
......@@ -30,18 +30,18 @@ void EnsureAllChildrenAreVisible(ui::Layer* layer) {
} // namespace
WindowMirrorView::WindowMirrorView(aura::Window* window,
WindowMirrorView::WindowMirrorView(aura::Window* source,
bool trilinear_filtering_on_init)
: target_(window),
: source_(source),
trilinear_filtering_on_init_(trilinear_filtering_on_init) {
DCHECK(window);
DCHECK(source);
}
WindowMirrorView::~WindowMirrorView() {
// Make sure |target_| has outlived |this|. See crbug.com/681207
DCHECK(target_->layer());
// Make sure |source_| has outlived |this|. See crbug.com/681207
DCHECK(source_->layer());
if (layer_owner_)
target_->ClearProperty(aura::client::kMirroringEnabledKey);
source_->ClearProperty(aura::client::kMirroringEnabledKey);
}
void WindowMirrorView::RecreateMirrorLayers() {
......@@ -66,7 +66,7 @@ void WindowMirrorView::Layout() {
gfx::Transform transform;
gfx::Rect client_area_bounds = GetClientAreaBounds();
// Scale down if necessary.
if (size() != target_->bounds().size()) {
if (size() != source_->bounds().size()) {
const float scale =
width() / static_cast<float>(client_area_bounds.width());
transform.Scale(scale, scale);
......@@ -87,9 +87,9 @@ void WindowMirrorView::OnVisibleBoundsChanged() {
void WindowMirrorView::InitLayerOwner() {
if (!layer_owner_)
target_->SetProperty(aura::client::kMirroringEnabledKey, true);
source_->SetProperty(aura::client::kMirroringEnabledKey, true);
layer_owner_ = ::wm::MirrorLayers(target_, false /* sync_bounds */);
layer_owner_ = ::wm::MirrorLayers(source_, false /* sync_bounds */);
SetPaintToLayer();
......@@ -98,8 +98,8 @@ void WindowMirrorView::InitLayerOwner() {
// This causes us to clip the non-client areas of the window.
layer()->SetMasksToBounds(true);
// Some extra work is needed when the target window is minimized.
if (wm::GetWindowState(target_)->IsMinimized()) {
// Some extra work is needed when the source window is minimized.
if (wm::GetWindowState(source_)->IsMinimized()) {
mirror_layer->SetOpacity(1);
EnsureAllChildrenAreVisible(mirror_layer);
}
......@@ -117,14 +117,14 @@ ui::Layer* WindowMirrorView::GetMirrorLayer() {
}
gfx::Rect WindowMirrorView::GetClientAreaBounds() const {
int inset = target_->GetProperty(aura::client::kTopViewInset);
int inset = source_->GetProperty(aura::client::kTopViewInset);
if (inset > 0) {
gfx::Rect bounds(target_->bounds().size());
gfx::Rect bounds(source_->bounds().size());
bounds.Inset(0, inset, 0, 0);
return bounds;
}
// The target window may not have a widget in unit tests.
views::Widget* widget = GetInternalWidgetForWindow(target_);
// The source window may not have a widget in unit tests.
views::Widget* widget = GetInternalWidgetForWindow(source_);
if (!widget)
return gfx::Rect();
views::View* client_view = widget->client_view();
......
......@@ -23,14 +23,14 @@ namespace ash {
namespace wm {
// A view that mirrors the client area of a single window.
// A view that mirrors the client area of a single (source) window.
class WindowMirrorView : public views::View {
public:
WindowMirrorView(aura::Window* window, bool trilinear_filtering_on_init);
WindowMirrorView(aura::Window* source, bool trilinear_filtering_on_init);
~WindowMirrorView() override;
// Returns the |target_| window.
aura::Window* target() { return target_; }
// Returns the source of the mirror.
aura::Window* source() { return source_; }
// Recreates |layer_owner_|.
void RecreateMirrorLayers();
......@@ -44,7 +44,7 @@ class WindowMirrorView : public views::View {
private:
void InitLayerOwner();
// Gets the root of the layer tree that was lifted from |target_| (and is now
// Gets the root of the layer tree that was lifted from |source_| (and is now
// a child of |this->layer()|).
ui::Layer* GetMirrorLayer();
......@@ -53,7 +53,7 @@ class WindowMirrorView : public views::View {
gfx::Rect GetClientAreaBounds() const;
// The original window that is being represented by |this|.
aura::Window* target_;
aura::Window* source_;
// Retains ownership of the mirror layer tree. This is lazily initialized
// the first time the view becomes visible.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment