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

Unified Diff: ash/wm/overview/scoped_transform_overview_window.cc

Issue 2895713002: [mus+ash] Removes WmWindow from ash/wm/mru_window_tracker and overview mode (Closed)
Patch Set: Address nits, unit_tests target compiles Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: ash/wm/overview/scoped_transform_overview_window.cc
diff --git a/ash/wm/overview/scoped_transform_overview_window.cc b/ash/wm/overview/scoped_transform_overview_window.cc
index 39a50cc0a36dfcdc2b38539d01fbc084e0645bc6..003134a6ae51d5e7149501134be9e764b368fcaa 100644
--- a/ash/wm/overview/scoped_transform_overview_window.cc
+++ b/ash/wm/overview/scoped_transform_overview_window.cc
@@ -13,19 +13,21 @@
#include "ash/wm/overview/window_selector_item.h"
#include "ash/wm/window_mirror_view.h"
#include "ash/wm/window_state.h"
+#include "ash/wm/window_util.h"
#include "ash/wm_window.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "ui/aura/client/aura_constants.h"
+#include "ui/aura/window.h"
#include "ui/compositor/layer.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/safe_integer_conversions.h"
#include "ui/gfx/transform_util.h"
#include "ui/views/widget/widget.h"
-
-using WmWindows = std::vector<ash::WmWindow*>;
+#include "ui/wm/core/coordinate_conversion.h"
+#include "ui/wm/core/window_util.h"
namespace ash {
@@ -37,20 +39,20 @@ bool immediate_close_for_tests = false;
// Delay closing window to allow it to shrink and fade out.
const int kCloseWindowDelayInMilliseconds = 150;
-WmWindow* GetTransientRoot(WmWindow* window) {
- while (window && window->GetTransientParent())
- window = window->GetTransientParent();
+aura::Window* GetTransientRoot(aura::Window* window) {
+ while (window && ::wm::GetTransientParent(window))
+ window = ::wm::GetTransientParent(window);
return window;
}
std::unique_ptr<ScopedOverviewAnimationSettings>
CreateScopedOverviewAnimationSettings(OverviewAnimationType animation_type,
- WmWindow* window) {
+ aura::Window* window) {
return ScopedOverviewAnimationSettingsFactory::Get()
->CreateOverviewAnimationSettings(animation_type, window);
}
-// An iterator class that traverses a WmWindow and all of its transient
+// An iterator class that traverses an aura::Window and all of its transient
// descendants.
class TransientDescendantIterator {
public:
@@ -63,7 +65,7 @@ class TransientDescendantIterator {
// Iterates over |root_window| and all of its transient descendants.
// Note |root_window| must not have a transient parent.
- explicit TransientDescendantIterator(WmWindow* root_window);
+ explicit TransientDescendantIterator(aura::Window* root_window);
// Prefix increment operator. This assumes there are more items (i.e.
// *this != TransientDescendantIterator()).
@@ -73,7 +75,7 @@ class TransientDescendantIterator {
bool operator!=(const TransientDescendantIterator& other) const;
// Dereference operator for STL-compatible iterators.
- WmWindow* operator*() const;
+ aura::Window* operator*() const;
private:
// Explicit assignment operator defined because an explicit copy constructor
@@ -83,7 +85,7 @@ class TransientDescendantIterator {
// The current window that |this| refers to. A null |current_window_| denotes
// an empty iterator and is used as the last possible value in the traversal.
- WmWindow* current_window_;
+ aura::Window* current_window_;
};
// Provides a virtual container implementing begin() and end() for a sequence of
@@ -113,27 +115,30 @@ class TransientDescendantIteratorRange {
TransientDescendantIterator::TransientDescendantIterator()
: current_window_(nullptr) {}
-TransientDescendantIterator::TransientDescendantIterator(WmWindow* root_window)
+TransientDescendantIterator::TransientDescendantIterator(
+ aura::Window* root_window)
: current_window_(root_window) {
- DCHECK(!root_window->GetTransientParent());
+ DCHECK(!::wm::GetTransientParent(root_window));
}
// Performs a pre-order traversal of the transient descendants.
const TransientDescendantIterator& TransientDescendantIterator::operator++() {
DCHECK(current_window_);
- const WmWindows transient_children = current_window_->GetTransientChildren();
+ const aura::Window::Windows transient_children =
+ ::wm::GetTransientChildren(current_window_);
if (!transient_children.empty()) {
current_window_ = transient_children.front();
} else {
while (current_window_) {
- WmWindow* parent = current_window_->GetTransientParent();
+ aura::Window* parent = ::wm::GetTransientParent(current_window_);
if (!parent) {
current_window_ = nullptr;
break;
}
- const WmWindows transient_siblings = parent->GetTransientChildren();
+ const aura::Window::Windows transient_siblings =
+ ::wm::GetTransientChildren(parent);
auto iter = std::find(transient_siblings.begin(),
transient_siblings.end(), current_window_);
++iter;
@@ -141,7 +146,7 @@ const TransientDescendantIterator& TransientDescendantIterator::operator++() {
current_window_ = *iter;
break;
}
- current_window_ = current_window_->GetTransientParent();
+ current_window_ = ::wm::GetTransientParent(current_window_);
}
}
return *this;
@@ -152,7 +157,7 @@ bool TransientDescendantIterator::operator!=(
return current_window_ != other.current_window_;
}
-WmWindow* TransientDescendantIterator::operator*() const {
+aura::Window* TransientDescendantIterator::operator*() const {
return current_window_;
}
@@ -160,20 +165,22 @@ TransientDescendantIteratorRange::TransientDescendantIteratorRange(
const TransientDescendantIterator& begin)
: begin_(begin) {}
-TransientDescendantIteratorRange GetTransientTreeIterator(WmWindow* window) {
+TransientDescendantIteratorRange GetTransientTreeIterator(
+ aura::Window* window) {
return TransientDescendantIteratorRange(
TransientDescendantIterator(GetTransientRoot(window)));
}
} // namespace
-ScopedTransformOverviewWindow::ScopedTransformOverviewWindow(WmWindow* window)
+ScopedTransformOverviewWindow::ScopedTransformOverviewWindow(
+ aura::Window* window)
: window_(window),
determined_original_window_shape_(false),
- ignored_by_shelf_(window->GetWindowState()->ignored_by_shelf()),
+ ignored_by_shelf_(wm::GetWindowState(window)->ignored_by_shelf()),
overview_started_(false),
- original_transform_(window->GetTargetTransform()),
- original_opacity_(window->GetTargetOpacity()),
+ original_transform_(window->layer()->GetTargetTransform()),
+ original_opacity_(window->layer()->GetTargetOpacity()),
weak_ptr_factory_(this) {}
ScopedTransformOverviewWindow::~ScopedTransformOverviewWindow() {}
@@ -194,7 +201,7 @@ void ScopedTransformOverviewWindow::RestoreWindow() {
CreateScopedOverviewAnimationSettings(
OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS,
window_);
- window_->GetWindowState()->set_ignored_by_shelf(ignored_by_shelf_);
+ wm::GetWindowState(window_)->set_ignored_by_shelf(ignored_by_shelf_);
SetOpacity(original_opacity_);
}
@@ -207,28 +214,29 @@ void ScopedTransformOverviewWindow::BeginScopedAnimation(
}
}
-bool ScopedTransformOverviewWindow::Contains(const WmWindow* target) const {
+bool ScopedTransformOverviewWindow::Contains(const aura::Window* target) const {
for (auto* window : GetTransientTreeIterator(window_)) {
if (window->Contains(target))
return true;
}
- WmWindow* mirror = GetOverviewWindowForMinimizedState();
+ aura::Window* mirror = GetOverviewWindowForMinimizedState();
return mirror && mirror->Contains(target);
}
gfx::Rect ScopedTransformOverviewWindow::GetTargetBoundsInScreen() const {
gfx::Rect bounds;
- WmWindow* overview_window = GetOverviewWindow();
+ aura::Window* overview_window = GetOverviewWindow();
for (auto* window : GetTransientTreeIterator(overview_window)) {
// Ignore other window types when computing bounding box of window
// selector target item.
if (window != overview_window &&
- window->GetType() != ui::wm::WINDOW_TYPE_NORMAL &&
- window->GetType() != ui::wm::WINDOW_TYPE_PANEL) {
+ window->type() != ui::wm::WINDOW_TYPE_NORMAL &&
+ window->type() != ui::wm::WINDOW_TYPE_PANEL) {
continue;
}
- bounds.Union(
- window->GetParent()->ConvertRectToScreen(window->GetTargetBounds()));
+ gfx::Rect target_bounds = window->GetTargetBounds();
+ ::wm::ConvertRectToScreen(window->parent(), &target_bounds);
+ bounds.Union(target_bounds);
}
return bounds;
}
@@ -236,19 +244,19 @@ gfx::Rect ScopedTransformOverviewWindow::GetTargetBoundsInScreen() const {
gfx::Rect ScopedTransformOverviewWindow::GetTransformedBounds() const {
const int top_inset = GetTopInset();
gfx::Rect bounds;
- WmWindow* overview_window = GetOverviewWindow();
+ aura::Window* overview_window = GetOverviewWindow();
for (auto* window : GetTransientTreeIterator(overview_window)) {
// Ignore other window types when computing bounding box of window
// selector target item.
if (window != overview_window &&
- (window->GetType() != ui::wm::WINDOW_TYPE_NORMAL &&
- window->GetType() != ui::wm::WINDOW_TYPE_PANEL)) {
+ (window->type() != ui::wm::WINDOW_TYPE_NORMAL &&
+ window->type() != ui::wm::WINDOW_TYPE_PANEL)) {
continue;
}
gfx::RectF window_bounds(window->GetTargetBounds());
gfx::Transform new_transform =
TransformAboutPivot(gfx::Point(window_bounds.x(), window_bounds.y()),
- window->GetTargetTransform());
+ window->layer()->GetTargetTransform());
new_transform.TransformRect(&window_bounds);
// The preview title is shown above the preview window. Hide the window
@@ -260,8 +268,9 @@ gfx::Rect ScopedTransformOverviewWindow::GetTransformedBounds() const {
new_transform.TransformRect(&header_bounds);
window_bounds.Inset(0, gfx::ToCeiledInt(header_bounds.height()), 0, 0);
}
- bounds.Union(window->GetParent()->ConvertRectToScreen(
- ToEnclosingRect(window_bounds)));
+ gfx::Rect enclosing_bounds = ToEnclosingRect(window_bounds);
+ ::wm::ConvertRectToScreen(window->parent(), &enclosing_bounds);
+ bounds.Union(enclosing_bounds);
}
return bounds;
}
@@ -270,12 +279,12 @@ SkColor ScopedTransformOverviewWindow::GetTopColor() const {
for (auto* window : GetTransientTreeIterator(window_)) {
// If there are regular windows in the transient ancestor tree, all those
// windows are shown in the same overview item and the header is not masked.
- if (window != window_ && (window->GetType() == ui::wm::WINDOW_TYPE_NORMAL ||
- window->GetType() == ui::wm::WINDOW_TYPE_PANEL)) {
+ if (window != window_ && (window->type() == ui::wm::WINDOW_TYPE_NORMAL ||
+ window->type() == ui::wm::WINDOW_TYPE_PANEL)) {
return SK_ColorTRANSPARENT;
}
}
- return window_->aura_window()->GetProperty(aura::client::kTopViewColor);
+ return window_->GetProperty(aura::client::kTopViewColor);
}
int ScopedTransformOverviewWindow::GetTopInset() const {
@@ -285,12 +294,12 @@ int ScopedTransformOverviewWindow::GetTopInset() const {
for (auto* window : GetTransientTreeIterator(window_)) {
// If there are regular windows in the transient ancestor tree, all those
// windows are shown in the same overview item and the header is not masked.
- if (window != window_ && (window->GetType() == ui::wm::WINDOW_TYPE_NORMAL ||
- window->GetType() == ui::wm::WINDOW_TYPE_PANEL)) {
+ if (window != window_ && (window->type() == ui::wm::WINDOW_TYPE_NORMAL ||
+ window->type() == ui::wm::WINDOW_TYPE_PANEL)) {
return 0;
}
}
- return window_->aura_window()->GetProperty(aura::client::kTopViewInset);
+ return window_->GetProperty(aura::client::kTopViewInset);
}
void ScopedTransformOverviewWindow::OnWindowDestroyed() {
@@ -337,35 +346,34 @@ gfx::Transform ScopedTransformOverviewWindow::GetTransformForRect(
}
void ScopedTransformOverviewWindow::SetTransform(
- WmWindow* root_window,
+ aura::Window* root_window,
const gfx::Transform& transform) {
DCHECK(overview_started_);
if (&transform != &original_transform_ &&
!determined_original_window_shape_) {
determined_original_window_shape_ = true;
- SkRegion* window_shape = window()->GetLayer()->alpha_shape();
+ SkRegion* window_shape = window()->layer()->alpha_shape();
if (!original_window_shape_ && window_shape)
original_window_shape_.reset(new SkRegion(*window_shape));
}
gfx::Point target_origin(GetTargetBoundsInScreen().origin());
for (auto* window : GetTransientTreeIterator(GetOverviewWindow())) {
- WmWindow* parent_window = window->GetParent();
- gfx::Point original_origin =
- parent_window->ConvertRectToScreen(window->GetTargetBounds()).origin();
+ aura::Window* parent_window = window->parent();
+ gfx::Rect original_bounds(window->GetTargetBounds());
+ ::wm::ConvertRectToScreen(parent_window, &original_bounds);
gfx::Transform new_transform =
- TransformAboutPivot(gfx::Point(target_origin.x() - original_origin.x(),
- target_origin.y() - original_origin.y()),
+ TransformAboutPivot(gfx::Point(target_origin.x() - original_bounds.x(),
+ target_origin.y() - original_bounds.y()),
transform);
window->SetTransform(new_transform);
}
}
void ScopedTransformOverviewWindow::SetOpacity(float opacity) {
- for (auto* window : GetTransientTreeIterator(GetOverviewWindow())) {
- window->SetOpacity(opacity);
- }
+ for (auto* window : GetTransientTreeIterator(GetOverviewWindow()))
+ window->layer()->SetOpacity(opacity);
}
void ScopedTransformOverviewWindow::HideHeader() {
@@ -381,26 +389,27 @@ void ScopedTransformOverviewWindow::HideHeader() {
region->setRect(RectToSkIRect(bounds));
if (original_window_shape_)
region->op(*original_window_shape_, SkRegion::kIntersect_Op);
- WmWindow* window = GetOverviewWindow();
- window->GetLayer()->SetAlphaShape(std::move(region));
- window->SetMasksToBounds(true);
+ aura::Window* window = GetOverviewWindow();
+ window->layer()->SetAlphaShape(std::move(region));
+ window->layer()->SetMasksToBounds(true);
}
}
void ScopedTransformOverviewWindow::ShowHeader() {
- ui::Layer* layer = window()->GetLayer();
+ ui::Layer* layer = window()->layer();
if (original_window_shape_) {
layer->SetAlphaShape(
base::MakeUnique<SkRegion>(*original_window_shape_.get()));
} else {
layer->SetAlphaShape(nullptr);
}
- window()->SetMasksToBounds(false);
+ layer->SetMasksToBounds(false);
}
void ScopedTransformOverviewWindow::UpdateMirrorWindowForMinimizedState() {
// TODO(oshima): Disable animation.
- if (window_->GetShowState() == ui::SHOW_STATE_MINIMIZED) {
+ if (window_->GetProperty(aura::client::kShowStateKey) ==
+ ui::SHOW_STATE_MINIMIZED) {
if (!minimized_widget_)
CreateMirrorWindowForMinimizedState();
} else {
@@ -423,13 +432,15 @@ void ScopedTransformOverviewWindow::Close() {
void ScopedTransformOverviewWindow::PrepareForOverview() {
DCHECK(!overview_started_);
overview_started_ = true;
- window_->GetWindowState()->set_ignored_by_shelf(true);
- if (window_->GetShowState() == ui::SHOW_STATE_MINIMIZED)
+ wm::GetWindowState(window_)->set_ignored_by_shelf(true);
+ if (window_->GetProperty(aura::client::kShowStateKey) ==
+ ui::SHOW_STATE_MINIMIZED) {
CreateMirrorWindowForMinimizedState();
+ }
}
void ScopedTransformOverviewWindow::CloseWidget() {
- WmWindow* parent_window = GetTransientRoot(window_);
+ WmWindow* parent_window = WmWindow::Get(GetTransientRoot(window_));
if (parent_window)
parent_window->CloseWidget();
}
@@ -439,7 +450,7 @@ void ScopedTransformOverviewWindow::SetImmediateCloseForTests() {
immediate_close_for_tests = true;
}
-WmWindow* ScopedTransformOverviewWindow::GetOverviewWindow() const {
+aura::Window* ScopedTransformOverviewWindow::GetOverviewWindow() const {
if (minimized_widget_)
return GetOverviewWindowForMinimizedState();
return window_;
@@ -453,7 +464,7 @@ void ScopedTransformOverviewWindow::OnGestureEvent(ui::GestureEvent* event) {
if (event->type() == ui::ET_GESTURE_TAP) {
EnsureVisible();
window_->Show();
- window_->Activate();
+ wm::ActivateWindow(window_);
}
}
@@ -461,14 +472,13 @@ void ScopedTransformOverviewWindow::OnMouseEvent(ui::MouseEvent* event) {
if (event->type() == ui::ET_MOUSE_PRESSED && event->IsOnlyLeftMouseButton()) {
EnsureVisible();
window_->Show();
- window_->Activate();
+ wm::ActivateWindow(window_);
}
}
-WmWindow* ScopedTransformOverviewWindow::GetOverviewWindowForMinimizedState()
- const {
- return minimized_widget_ ? WmWindow::Get(minimized_widget_->GetNativeWindow())
- : nullptr;
+aura::Window*
+ScopedTransformOverviewWindow::GetOverviewWindowForMinimizedState() const {
+ return minimized_widget_ ? minimized_widget_->GetNativeWindow() : nullptr;
}
void ScopedTransformOverviewWindow::CreateMirrorWindowForMinimizedState() {
@@ -481,15 +491,13 @@ void ScopedTransformOverviewWindow::CreateMirrorWindowForMinimizedState() {
params.activatable = views::Widget::InitParams::Activatable::ACTIVATABLE_NO;
params.accept_events = true;
minimized_widget_.reset(new views::Widget);
- window_->GetRootWindow()
- ->GetRootWindowController()
- ->ConfigureWidgetInitParamsForContainer(
- minimized_widget_.get(), window_->GetParent()->aura_window()->id(),
- &params);
+ RootWindowController::ForWindow(window_->GetRootWindow())
+ ->ConfigureWidgetInitParamsForContainer(minimized_widget_.get(),
+ window_->parent()->id(), &params);
minimized_widget_->set_focus_on_creation(false);
minimized_widget_->Init(params);
- views::View* mirror_view = new wm::WindowMirrorView(window_->aura_window());
+ views::View* mirror_view = new wm::WindowMirrorView(window_);
mirror_view->SetVisible(true);
mirror_view->SetTargetHandler(this);
minimized_widget_->SetContentsView(mirror_view);

Powered by Google App Engine
This is Rietveld 408576698