| 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 bcc5e7ae03ddc4fb657f5929cb040e7f5ff6fc8e..ec787fa5f8c479c84c6b126a0d025d1c19991b65 100644
|
| --- a/ash/wm/overview/scoped_transform_overview_window.cc
|
| +++ b/ash/wm/overview/scoped_transform_overview_window.cc
|
| @@ -7,23 +7,16 @@
|
| #include <algorithm>
|
| #include <vector>
|
|
|
| -#include "ash/screen_util.h"
|
| -#include "ash/shell_window_ids.h"
|
| #include "ash/wm/common/window_state.h"
|
| +#include "ash/wm/common/wm_window.h"
|
| #include "ash/wm/overview/scoped_overview_animation_settings.h"
|
| +#include "ash/wm/overview/scoped_overview_animation_settings_factory.h"
|
| #include "ash/wm/overview/window_selector_item.h"
|
| -#include "ash/wm/window_state_aura.h"
|
| -#include "ash/wm/window_util.h"
|
| #include "base/macros.h"
|
| -#include "ui/aura/client/aura_constants.h"
|
| -#include "ui/aura/client/screen_position_client.h"
|
| -#include "ui/aura/window.h"
|
| -#include "ui/compositor/scoped_layer_animation_settings.h"
|
| -#include "ui/gfx/animation/tween.h"
|
| +#include "ui/gfx/geometry/rect.h"
|
| #include "ui/gfx/transform_util.h"
|
| -#include "ui/views/widget/widget.h"
|
| -#include "ui/wm/core/window_animations.h"
|
| -#include "ui/wm/core/window_util.h"
|
| +
|
| +using WmWindows = std::vector<ash::wm::WmWindow*>;
|
|
|
| namespace ash {
|
|
|
| @@ -32,13 +25,20 @@ namespace {
|
| // The opacity level that windows will be set to when they are restored.
|
| const float kRestoreWindowOpacity = 1.0f;
|
|
|
| -aura::Window* GetTransientRoot(aura::Window* window) {
|
| - while (::wm::GetTransientParent(window))
|
| - window = ::wm::GetTransientParent(window);
|
| +wm::WmWindow* GetTransientRoot(wm::WmWindow* window) {
|
| + while (window->GetTransientParent())
|
| + window = window->GetTransientParent();
|
| return window;
|
| }
|
|
|
| -// An iterator class that traverses an aura::Window and all of it's transient
|
| +std::unique_ptr<ScopedOverviewAnimationSettings>
|
| +CreateScopedOverviewAnimationSettings(OverviewAnimationType animation_type,
|
| + wm::WmWindow* window) {
|
| + return ScopedOverviewAnimationSettingsFactory::Get()
|
| + ->CreateOverviewAnimationSettings(animation_type, window);
|
| +}
|
| +
|
| +// An iterator class that traverses a wm::WmWindow and all of its transient
|
| // descendants.
|
| class TransientDescendantIterator {
|
| public:
|
| @@ -51,7 +51,7 @@ class TransientDescendantIterator {
|
|
|
| // Iterates over |root_window| and all of its transient descendants.
|
| // Note |root_window| must not have a transient parent.
|
| - explicit TransientDescendantIterator(aura::Window* root_window);
|
| + explicit TransientDescendantIterator(wm::WmWindow* root_window);
|
|
|
| // Prefix increment operator. This assumes there are more items (i.e.
|
| // *this != TransientDescendantIterator()).
|
| @@ -61,17 +61,17 @@ class TransientDescendantIterator {
|
| bool operator!=(const TransientDescendantIterator& other) const;
|
|
|
| // Dereference operator for STL-compatible iterators.
|
| - aura::Window* operator*() const;
|
| + wm::WmWindow* operator*() const;
|
|
|
| private:
|
| - // 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.
|
| - aura::Window* current_window_;
|
| -
|
| // Explicit assignment operator defined because an explicit copy constructor
|
| // is needed and therefore the DISALLOW_COPY_AND_ASSIGN macro cannot be used.
|
| TransientDescendantIterator& operator=(
|
| const TransientDescendantIterator& other) = default;
|
| +
|
| + // 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.
|
| + wm::WmWindow* current_window_;
|
| };
|
|
|
| // Provides a virtual container implementing begin() and end() for a sequence of
|
| @@ -89,13 +89,13 @@ class TransientDescendantIteratorRange {
|
| const TransientDescendantIterator& end() const { return end_; }
|
|
|
| private:
|
| - TransientDescendantIterator begin_;
|
| - TransientDescendantIterator end_;
|
| -
|
| // Explicit assignment operator defined because an explicit copy constructor
|
| // is needed and therefore the DISALLOW_COPY_AND_ASSIGN macro cannot be used.
|
| TransientDescendantIteratorRange& operator=(
|
| const TransientDescendantIteratorRange& other) = default;
|
| +
|
| + TransientDescendantIterator begin_;
|
| + TransientDescendantIterator end_;
|
| };
|
|
|
| TransientDescendantIterator::TransientDescendantIterator()
|
| @@ -103,9 +103,9 @@ TransientDescendantIterator::TransientDescendantIterator()
|
| }
|
|
|
| TransientDescendantIterator::TransientDescendantIterator(
|
| - aura::Window* root_window)
|
| + wm::WmWindow* root_window)
|
| : current_window_(root_window) {
|
| - DCHECK(!::wm::GetTransientParent(root_window));
|
| + DCHECK(!root_window->GetTransientParent());
|
| }
|
|
|
| // Performs a pre-order traversal of the transient descendants.
|
| @@ -113,30 +113,26 @@ const TransientDescendantIterator&
|
| TransientDescendantIterator::operator++() {
|
| DCHECK(current_window_);
|
|
|
| - const aura::Window::Windows& transient_children =
|
| - ::wm::GetTransientChildren(current_window_);
|
| + const WmWindows transient_children = current_window_->GetTransientChildren();
|
|
|
| - if (transient_children.size() > 0) {
|
| + if (!transient_children.empty()) {
|
| current_window_ = transient_children.front();
|
| } else {
|
| while (current_window_) {
|
| - aura::Window* parent = ::wm::GetTransientParent(current_window_);
|
| + wm::WmWindow* parent = current_window_->GetTransientParent();
|
| if (!parent) {
|
| current_window_ = nullptr;
|
| break;
|
| }
|
| - const aura::Window::Windows& transient_siblings =
|
| - ::wm::GetTransientChildren(parent);
|
| - aura::Window::Windows::const_iterator iter = std::find(
|
| - transient_siblings.begin(),
|
| - transient_siblings.end(),
|
| - current_window_);
|
| + const WmWindows transient_siblings = parent->GetTransientChildren();
|
| + auto iter = std::find(transient_siblings.begin(),
|
| + transient_siblings.end(), current_window_);
|
| ++iter;
|
| if (iter != transient_siblings.end()) {
|
| current_window_ = *iter;
|
| break;
|
| }
|
| - current_window_ = ::wm::GetTransientParent(current_window_);
|
| + current_window_ = current_window_->GetTransientParent();
|
| }
|
| }
|
| return *this;
|
| @@ -147,7 +143,7 @@ bool TransientDescendantIterator::operator!=(
|
| return current_window_ != other.current_window_;
|
| }
|
|
|
| -aura::Window* TransientDescendantIterator::operator*() const {
|
| +wm::WmWindow* TransientDescendantIterator::operator*() const {
|
| return current_window_;
|
| }
|
|
|
| @@ -157,7 +153,7 @@ TransientDescendantIteratorRange::TransientDescendantIteratorRange(
|
| }
|
|
|
| TransientDescendantIteratorRange GetTransientTreeIterator(
|
| - aura::Window* window) {
|
| + wm::WmWindow* window) {
|
| return TransientDescendantIteratorRange(
|
| TransientDescendantIterator(GetTransientRoot(window)));
|
| }
|
| @@ -165,16 +161,13 @@ TransientDescendantIteratorRange GetTransientTreeIterator(
|
| } // namespace
|
|
|
| ScopedTransformOverviewWindow::ScopedTransformOverviewWindow(
|
| - aura::Window* window)
|
| + wm::WmWindow* window)
|
| : window_(window),
|
| - minimized_(window->GetProperty(aura::client::kShowStateKey) ==
|
| - ui::SHOW_STATE_MINIMIZED),
|
| - ignored_by_shelf_(wm::GetWindowState(window)->ignored_by_shelf()),
|
| + minimized_(window->GetShowState() == ui::SHOW_STATE_MINIMIZED),
|
| + ignored_by_shelf_(window->GetWindowState()->ignored_by_shelf()),
|
| overview_started_(false),
|
| - original_transform_(window->layer()->GetTargetTransform()),
|
| - original_opacity_(window->layer()->GetTargetOpacity()) {
|
| - DCHECK(window_);
|
| -}
|
| + original_transform_(window->GetTargetTransform()),
|
| + original_opacity_(window->GetTargetOpacity()) {}
|
|
|
| ScopedTransformOverviewWindow::~ScopedTransformOverviewWindow() {
|
| }
|
| @@ -186,12 +179,12 @@ void ScopedTransformOverviewWindow::RestoreWindow() {
|
| &animation_settings_list);
|
| SetTransform(window()->GetRootWindow(), original_transform_);
|
|
|
| - ScopedOverviewAnimationSettings animation_settings(
|
| - OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS,
|
| - window_);
|
| + std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings =
|
| + CreateScopedOverviewAnimationSettings(
|
| + OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS,
|
| + window_);
|
| gfx::Transform transform;
|
| - if (minimized_ && window_->GetProperty(aura::client::kShowStateKey) !=
|
| - ui::SHOW_STATE_MINIMIZED) {
|
| + if (minimized_ && window_->GetShowState() != ui::SHOW_STATE_MINIMIZED) {
|
| // Setting opacity 0 and visible false ensures that the property change
|
| // to SHOW_STATE_MINIMIZED will not animate the window from its original
|
| // bounds to the minimized position.
|
| @@ -199,10 +192,10 @@ void ScopedTransformOverviewWindow::RestoreWindow() {
|
| // otherwise the layer's visibility will not be updated
|
| // (See VisibilityController::UpdateLayerVisibility).
|
| window_->Hide();
|
| - window_->layer()->SetOpacity(0);
|
| - window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
|
| + window_->SetOpacity(0);
|
| + window_->SetShowState(ui::SHOW_STATE_MINIMIZED);
|
| }
|
| - wm::GetWindowState(window_)->set_ignored_by_shelf(ignored_by_shelf_);
|
| + window_->GetWindowState()->set_ignored_by_shelf(ignored_by_shelf_);
|
| SetOpacity(original_opacity_);
|
| }
|
|
|
| @@ -211,11 +204,11 @@ void ScopedTransformOverviewWindow::BeginScopedAnimation(
|
| ScopedAnimationSettings* animation_settings) {
|
| for (const auto& window : GetTransientTreeIterator(window_)) {
|
| animation_settings->push_back(
|
| - new ScopedOverviewAnimationSettings(animation_type, window));
|
| + CreateScopedOverviewAnimationSettings(animation_type, window));
|
| }
|
| }
|
|
|
| -bool ScopedTransformOverviewWindow::Contains(const aura::Window* target) const {
|
| +bool ScopedTransformOverviewWindow::Contains(const wm::WmWindow* target) const {
|
| for (const auto& window : GetTransientTreeIterator(window_)) {
|
| if (window->Contains(target))
|
| return true;
|
| @@ -228,21 +221,19 @@ gfx::Rect ScopedTransformOverviewWindow::GetTargetBoundsInScreen() const {
|
| for (const auto& window : GetTransientTreeIterator(window_)) {
|
| // Ignore other window types when computing bounding box of window
|
| // selector target item.
|
| - if (window != window_ && window->type() != ui::wm::WINDOW_TYPE_NORMAL &&
|
| - window->type() != ui::wm::WINDOW_TYPE_PANEL) {
|
| + if (window != window_ && window->GetType() != ui::wm::WINDOW_TYPE_NORMAL &&
|
| + window->GetType() != ui::wm::WINDOW_TYPE_PANEL) {
|
| continue;
|
| }
|
| - bounds.Union(ScreenUtil::ConvertRectToScreen(window->parent(),
|
| - window->GetTargetBounds()));
|
| + bounds.Union(
|
| + window->GetParent()->ConvertRectToScreen(window->GetTargetBounds()));
|
| }
|
| return bounds;
|
| }
|
|
|
| void ScopedTransformOverviewWindow::ShowWindowIfMinimized() {
|
| - if (minimized_ && window_->GetProperty(aura::client::kShowStateKey) ==
|
| - ui::SHOW_STATE_MINIMIZED) {
|
| + if (minimized_ && window_->GetShowState() == ui::SHOW_STATE_MINIMIZED)
|
| window_->Show();
|
| - }
|
| }
|
|
|
| void ScopedTransformOverviewWindow::ShowWindowOnExit() {
|
| @@ -290,16 +281,16 @@ gfx::Transform ScopedTransformOverviewWindow::GetTransformForRect(
|
| }
|
|
|
| void ScopedTransformOverviewWindow::SetTransform(
|
| - aura::Window* root_window,
|
| + wm::WmWindow* root_window,
|
| const gfx::Transform& transform) {
|
| DCHECK(overview_started_);
|
|
|
| gfx::Point target_origin(GetTargetBoundsInScreen().origin());
|
|
|
| for (const auto& window : GetTransientTreeIterator(window_)) {
|
| - aura::Window* parent_window = window->parent();
|
| - gfx::Point original_origin = ScreenUtil::ConvertRectToScreen(
|
| - parent_window, window->GetTargetBounds()).origin();
|
| + wm::WmWindow* parent_window = window->GetParent();
|
| + gfx::Point original_origin =
|
| + parent_window->ConvertRectToScreen(window->GetTargetBounds()).origin();
|
| gfx::Transform new_transform = TransformAboutPivot(
|
| gfx::Point(target_origin.x() - original_origin.x(),
|
| target_origin.y() - original_origin.y()),
|
| @@ -310,19 +301,18 @@ void ScopedTransformOverviewWindow::SetTransform(
|
|
|
| void ScopedTransformOverviewWindow::SetOpacity(float opacity) {
|
| for (const auto& window : GetTransientTreeIterator(window_)) {
|
| - window->layer()->SetOpacity(opacity);
|
| + window->SetOpacity(opacity);
|
| }
|
| }
|
|
|
| void ScopedTransformOverviewWindow::Close() {
|
| - aura::Window* window = GetTransientRoot(window_);
|
| - views::Widget::GetWidgetForNativeView(window)->Close();
|
| + GetTransientRoot(window_)->CloseWidget();
|
| }
|
|
|
| void ScopedTransformOverviewWindow::PrepareForOverview() {
|
| DCHECK(!overview_started_);
|
| overview_started_ = true;
|
| - wm::GetWindowState(window_)->set_ignored_by_shelf(true);
|
| + window_->GetWindowState()->set_ignored_by_shelf(true);
|
| ShowWindowIfMinimized();
|
| }
|
|
|
|
|