| Index: ash/wm/dock/docked_window_layout_manager.cc
|
| diff --git a/ash/wm/dock/docked_window_layout_manager.cc b/ash/wm/dock/docked_window_layout_manager.cc
|
| index 71b8929049eb3f28e52be144343ac1d0b666d5af..87144109f02156d9698577bb155dd16477caf21e 100644
|
| --- a/ash/wm/dock/docked_window_layout_manager.cc
|
| +++ b/ash/wm/dock/docked_window_layout_manager.cc
|
| @@ -8,7 +8,6 @@
|
| #include "ash/shelf/shelf.h"
|
| #include "ash/shelf/shelf_constants.h"
|
| #include "ash/shelf/shelf_layout_manager.h"
|
| -#include "ash/shelf/shelf_layout_manager_observer.h"
|
| #include "ash/shelf/shelf_types.h"
|
| #include "ash/shelf/shelf_widget.h"
|
| #include "ash/shell.h"
|
| @@ -58,8 +57,7 @@
|
| const int kMinimizeDurationMs = 720;
|
|
|
| class DockedBackgroundWidget : public views::Widget,
|
| - public BackgroundAnimatorDelegate,
|
| - public ShelfLayoutManagerObserver {
|
| + public BackgroundAnimatorDelegate {
|
| public:
|
| explicit DockedBackgroundWidget(aura::Window* container)
|
| : alignment_(DOCKED_ALIGNMENT_NONE),
|
| @@ -68,17 +66,7 @@
|
| opaque_background_(ui::LAYER_SOLID_COLOR),
|
| visible_background_type_(SHELF_BACKGROUND_DEFAULT),
|
| visible_background_change_type_(BACKGROUND_CHANGE_IMMEDIATE) {
|
| - Shelf* shelf = Shelf::ForWindow(container);
|
| - visible_background_type_ = shelf->shelf_widget()->GetBackgroundType();
|
| - shelf->shelf_layout_manager()->AddObserver(this);
|
| -
|
| InitWidget(container);
|
| - }
|
| -
|
| - ~DockedBackgroundWidget() override {
|
| - Shelf* shelf = Shelf::ForWindow(GetNativeWindow());
|
| - if (shelf && shelf->shelf_layout_manager())
|
| - shelf->shelf_layout_manager()->RemoveObserver(this);
|
| }
|
|
|
| // Sets widget bounds and sizes opaque background layer to fill the widget.
|
| @@ -88,7 +76,17 @@
|
| alignment_ = alignment;
|
| }
|
|
|
| - private:
|
| + // Sets the background type. Starts an animation to transition to
|
| + // |background_type| if the widget is visible. If the widget is not visible,
|
| + // the animation is postponed till the widget becomes visible.
|
| + void SetBackgroundType(ShelfBackgroundType background_type,
|
| + BackgroundAnimatorChangeType change_type) {
|
| + visible_background_type_ = background_type;
|
| + visible_background_change_type_ = change_type;
|
| + if (IsVisible())
|
| + UpdateBackground();
|
| + }
|
| +
|
| // views::Widget:
|
| void OnNativeWidgetVisibilityChanged(bool visible) override {
|
| views::Widget::OnNativeWidgetVisibilityChanged(visible);
|
| @@ -126,18 +124,7 @@
|
| SchedulePaintInRect(gfx::Rect(GetWindowBoundsInScreen().size()));
|
| }
|
|
|
| - // ShelfLayoutManagerObserver:
|
| - void OnBackgroundUpdated(ShelfBackgroundType background_type,
|
| - BackgroundAnimatorChangeType change_type) override {
|
| - // Sets the background type. Starts an animation to transition to
|
| - // |background_type| if the widget is visible. If the widget is not visible,
|
| - // the animation is postponed till the widget becomes visible.
|
| - visible_background_type_ = background_type;
|
| - visible_background_change_type_ = change_type;
|
| - if (IsVisible())
|
| - UpdateBackground();
|
| - }
|
| -
|
| + private:
|
| void InitWidget(aura::Window* parent) {
|
| views::Widget::InitParams params;
|
| params.type = views::Widget::InitParams::TYPE_POPUP;
|
| @@ -154,6 +141,7 @@
|
| opaque_background_.SetBounds(gfx::Rect(GetWindowBoundsInScreen().size()));
|
| opaque_background_.SetOpacity(0.0f);
|
| GetNativeWindow()->layer()->Add(&opaque_background_);
|
| + Hide();
|
|
|
| ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
|
| gfx::ImageSkia shelf_background =
|
| @@ -162,9 +150,6 @@
|
| shelf_background, SkBitmapOperations::ROTATION_90_CW);
|
| shelf_background_right_ = gfx::ImageSkiaOperations::CreateRotatedImage(
|
| shelf_background, SkBitmapOperations::ROTATION_270_CW);
|
| -
|
| - // Stack the background below any windows already in the dock container.
|
| - parent->StackChildAtBottom(GetNativeWindow());
|
| }
|
|
|
| // Transitions to |visible_background_type_| if the widget is visible and to
|
| @@ -416,10 +401,10 @@
|
| : SnapToPixelLayoutManager(dock_container),
|
| dock_container_(dock_container),
|
| in_layout_(false),
|
| - dragged_window_(nullptr),
|
| + dragged_window_(NULL),
|
| is_dragged_window_docked_(false),
|
| is_dragged_from_dock_(false),
|
| - shelf_(nullptr),
|
| + shelf_(NULL),
|
| workspace_controller_(workspace_controller),
|
| in_fullscreen_(workspace_controller_->GetWindowState() ==
|
| WORKSPACE_WINDOW_STATE_FULL_SCREEN),
|
| @@ -427,9 +412,9 @@
|
| alignment_(DOCKED_ALIGNMENT_NONE),
|
| preferred_alignment_(DOCKED_ALIGNMENT_NONE),
|
| event_source_(DOCKED_ACTION_SOURCE_UNKNOWN),
|
| - last_active_window_(nullptr),
|
| + last_active_window_(NULL),
|
| last_action_time_(base::Time::Now()),
|
| - background_widget_(nullptr) {
|
| + background_widget_(new DockedBackgroundWidget(dock_container_)) {
|
| DCHECK(dock_container);
|
| aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())->
|
| AddObserver(this);
|
| @@ -441,9 +426,11 @@
|
| }
|
|
|
| void DockedWindowLayoutManager::Shutdown() {
|
| - background_widget_.reset();
|
| - shelf_observer_.reset();
|
| - shelf_ = nullptr;
|
| + if (shelf_ && shelf_->shelf_layout_manager()) {
|
| + shelf_->shelf_layout_manager()->RemoveObserver(this);
|
| + shelf_observer_.reset();
|
| + }
|
| + shelf_ = NULL;
|
| for (size_t i = 0; i < dock_container_->children().size(); ++i) {
|
| aura::Window* child = dock_container_->children()[i];
|
| child->RemoveObserver(this);
|
| @@ -530,7 +517,7 @@
|
| dragged_window_->RemoveObserver(this);
|
| wm::GetWindowState(dragged_window_)->RemoveObserver(this);
|
| if (last_active_window_ == dragged_window_)
|
| - last_active_window_ = nullptr;
|
| + last_active_window_ = NULL;
|
| } else {
|
| // If this is the first window that got docked by a move update alignment.
|
| if (alignment_ == DOCKED_ALIGNMENT_NONE)
|
| @@ -541,7 +528,7 @@
|
| // count limit so do it here.
|
| MaybeMinimizeChildrenExcept(dragged_window_);
|
| }
|
| - dragged_window_ = nullptr;
|
| + dragged_window_ = NULL;
|
| dragged_bounds_ = gfx::Rect();
|
| Relayout();
|
| UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED);
|
| @@ -551,7 +538,10 @@
|
| void DockedWindowLayoutManager::SetShelf(Shelf* shelf) {
|
| DCHECK(!shelf_);
|
| shelf_ = shelf;
|
| - shelf_observer_.reset(new ShelfWindowObserver(this));
|
| + if (shelf_->shelf_layout_manager()) {
|
| + shelf_->shelf_layout_manager()->AddObserver(this);
|
| + shelf_observer_.reset(new ShelfWindowObserver(this));
|
| + }
|
| }
|
|
|
| DockedAlignment DockedWindowLayoutManager::GetAlignmentOfWindow(
|
| @@ -724,7 +714,7 @@
|
| UpdateDockedWidth(0);
|
| }
|
| if (last_active_window_ == child)
|
| - last_active_window_ = nullptr;
|
| + last_active_window_ = NULL;
|
| child->RemoveObserver(this);
|
| wm::GetWindowState(child)->RemoveObserver(this);
|
| Relayout();
|
| @@ -831,6 +821,14 @@
|
| }
|
|
|
| /////////////////////////////////////////////////////////////////////////////
|
| +// DockedWindowLayoutManager, ShelfLayoutManagerObserver implementation:
|
| +void DockedWindowLayoutManager::OnBackgroundUpdated(
|
| + ShelfBackgroundType background_type,
|
| + BackgroundAnimatorChangeType change_type) {
|
| + background_widget_->SetBackgroundType(background_type, change_type);
|
| +}
|
| +
|
| +/////////////////////////////////////////////////////////////////////////////
|
| // DockedWindowLayoutManager, WindowStateObserver implementation:
|
|
|
| void DockedWindowLayoutManager::OnPreWindowStateTypeChange(
|
| @@ -894,9 +892,10 @@
|
| DCHECK(!is_dragged_window_docked_);
|
| }
|
| if (window == last_active_window_)
|
| - last_active_window_ = nullptr;
|
| + last_active_window_ = NULL;
|
| RecordUmaAction(DOCKED_ACTION_CLOSE, event_source_);
|
| }
|
| +
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| // DockedWindowLayoutManager, aura::client::ActivationChangeObserver
|
| @@ -909,7 +908,7 @@
|
| if (gained_active && IsPopupOrTransient(gained_active))
|
| return;
|
| // Ignore if the window that is not managed by this was activated.
|
| - aura::Window* ancestor = nullptr;
|
| + aura::Window* ancestor = NULL;
|
| for (aura::Window* parent = gained_active;
|
| parent; parent = parent->parent()) {
|
| if (parent->parent() == dock_container_) {
|
| @@ -1076,7 +1075,7 @@
|
| base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true);
|
|
|
| gfx::Rect dock_bounds = dock_container_->GetBoundsInScreen();
|
| - aura::Window* active_window = nullptr;
|
| + aura::Window* active_window = NULL;
|
| std::vector<WindowWithHeight> visible_windows;
|
| for (size_t i = 0; i < dock_container_->children().size(); ++i) {
|
| aura::Window* window(dock_container_->children()[i]);
|
| @@ -1207,8 +1206,9 @@
|
| // Sort windows by their center positions and fan out overlapping
|
| // windows.
|
| std::sort(visible_windows->begin(), visible_windows->end(),
|
| - CompareWindowPos(is_dragged_from_dock_ ? dragged_window_ : nullptr,
|
| - dock_container_, delta));
|
| + CompareWindowPos(is_dragged_from_dock_ ? dragged_window_ : NULL,
|
| + dock_container_,
|
| + delta));
|
| for (std::vector<WindowWithHeight>::iterator iter = visible_windows->begin();
|
| iter != visible_windows->end(); ++iter) {
|
| aura::Window* window = iter->window();
|
| @@ -1292,14 +1292,11 @@
|
| gfx::Rect background_bounds(docked_bounds_);
|
| if (shelf_observer_)
|
| background_bounds.Subtract(shelf_observer_->shelf_bounds_in_screen());
|
| - if (docked_width_ > 0) {
|
| - if (!background_widget_)
|
| - background_widget_.reset(new DockedBackgroundWidget(dock_container_));
|
| - background_widget_->SetBackgroundBounds(background_bounds, alignment_);
|
| + background_widget_->SetBackgroundBounds(background_bounds, alignment_);
|
| + if (docked_width_ > 0)
|
| background_widget_->Show();
|
| - } else if (background_widget_) {
|
| + else
|
| background_widget_->Hide();
|
| - }
|
| }
|
|
|
| void DockedWindowLayoutManager::UpdateStacking(aura::Window* active_window) {
|
| @@ -1335,7 +1332,7 @@
|
| }
|
| int active_center_y = active_window->bounds().CenterPoint().y();
|
|
|
| - aura::Window* previous_window = nullptr;
|
| + aura::Window* previous_window = NULL;
|
| for (std::map<int, aura::Window*>::const_iterator it =
|
| window_ordering.begin();
|
| it != window_ordering.end() && it->first < active_center_y; ++it) {
|
|
|