Chromium Code Reviews| Index: ash/wm/workspace_controller.cc |
| diff --git a/ash/wm/workspace_controller.cc b/ash/wm/workspace_controller.cc |
| index 80d1783dd7a4ff0bb3be8221efe2a0c86647c754..f3b8acf35d5bba579f54070cd1c46635b29648ff 100644 |
| --- a/ash/wm/workspace_controller.cc |
| +++ b/ash/wm/workspace_controller.cc |
| @@ -6,17 +6,16 @@ |
| #include <utility> |
| -#include "ash/aura/wm_window_aura.h" |
| +#include "ash/common/shelf/wm_shelf.h" |
| #include "ash/common/shell_window_ids.h" |
| +#include "ash/common/wm/dock/docked_window_layout_manager.h" |
| +#include "ash/common/wm/fullscreen_window_finder.h" |
| #include "ash/common/wm/window_state.h" |
| +#include "ash/common/wm/wm_window_animations.h" |
| #include "ash/common/wm/workspace/workspace_layout_manager.h" |
| #include "ash/common/wm/workspace/workspace_layout_manager_backdrop_delegate.h" |
| -#include "ash/root_window_controller.h" |
| -#include "ash/shelf/shelf_layout_manager.h" |
| -#include "ash/shell.h" |
| -#include "ash/wm/window_animations.h" |
| -#include "ash/wm/window_state_aura.h" |
| -#include "ash/wm/window_util.h" |
| +#include "ash/common/wm_root_window_controller.h" |
| +#include "ash/common/wm_window.h" |
| #include "ash/wm/workspace/workspace_event_handler.h" |
| #include "base/memory/ptr_util.h" |
| #include "ui/aura/client/aura_constants.h" |
| @@ -35,96 +34,80 @@ namespace { |
| // animation (when logging in). |
| const int kInitialPauseTimeMS = 750; |
| -// Returns true if there are visible docked windows in the same screen as the |
| -// |shelf|. |
| -bool IsDockedAreaVisible(const ShelfLayoutManager* shelf) { |
| - return shelf->dock_bounds().width() > 0; |
| -} |
| +// The duration of the animation that occurs on first login. |
| +const int kIntialAnimationDurationMS = 200; |
|
James Cook
2016/08/11 23:27:36
nit: Intial -> Initial
msw
2016/08/12 00:17:15
Done.
|
| } // namespace |
| -WorkspaceController::WorkspaceController(aura::Window* viewport) |
| +WorkspaceController::WorkspaceController(WmWindow* viewport) |
| : viewport_(viewport), |
| - shelf_(NULL), |
| event_handler_(new WorkspaceEventHandler), |
| - layout_manager_(new WorkspaceLayoutManager(WmWindowAura::Get(viewport))) { |
| - SetWindowVisibilityAnimationTransition(viewport_, ::wm::ANIMATE_NONE); |
| - |
| - WmWindowAura::Get(viewport_)->SetLayoutManager( |
| - base::WrapUnique(layout_manager_)); |
| - viewport_->AddPreTargetHandler(event_handler_.get()); |
| + layout_manager_(new WorkspaceLayoutManager(viewport)) { |
| + viewport_->SetVisibilityAnimationTransition(::wm::ANIMATE_NONE); |
| + viewport_->SetLayoutManager(base::WrapUnique(layout_manager_)); |
| + viewport_->AddLimitedPreTargetHandler(event_handler_.get()); |
| } |
| WorkspaceController::~WorkspaceController() { |
| - viewport_->SetLayoutManager(NULL); |
| - viewport_->RemovePreTargetHandler(event_handler_.get()); |
| + viewport_->SetLayoutManager(nullptr); |
| + viewport_->RemoveLimitedPreTargetHandler(event_handler_.get()); |
| } |
| wm::WorkspaceWindowState WorkspaceController::GetWindowState() const { |
| - if (!shelf_) |
| - return wm::WORKSPACE_WINDOW_STATE_DEFAULT; |
| - const aura::Window* topmost_fullscreen_window = |
| - GetRootWindowController(viewport_->GetRootWindow()) |
| - ->GetWindowForFullscreenMode(); |
| - if (topmost_fullscreen_window && |
| - !wm::GetWindowState(topmost_fullscreen_window)->ignored_by_shelf()) { |
| + const WmWindow* fullscreen = wm::GetWindowForFullscreenMode(viewport_); |
| + if (fullscreen && !fullscreen->GetWindowState()->ignored_by_shelf()) |
| return wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN; |
| - } |
| + |
| + if (!viewport_->GetRootWindowController()->HasShelf()) |
|
James Cook
2016/08/11 23:27:36
Q: Does this one have to go second? The previous c
msw
2016/08/12 00:17:15
Restored order.
|
| + return wm::WORKSPACE_WINDOW_STATE_DEFAULT; |
| // These are the container ids of containers which may contain windows that |
| // may overlap the launcher shelf and affect its transparency. |
| const int kWindowContainerIds[] = { |
| kShellWindowId_DefaultContainer, kShellWindowId_DockedContainer, |
| }; |
| - const gfx::Rect shelf_bounds(shelf_->GetIdealBounds()); |
| + const gfx::Rect shelf_bounds( |
| + viewport_->GetRootWindowController()->GetShelf()->GetIdealBounds()); |
| bool window_overlaps_launcher = false; |
| - for (size_t idx = 0; idx < arraysize(kWindowContainerIds); idx++) { |
| - const aura::Window* container = Shell::GetContainer( |
| - viewport_->GetRootWindow(), kWindowContainerIds[idx]); |
| - const aura::Window::Windows& windows(container->children()); |
| - for (aura::Window::Windows::const_iterator i = windows.begin(); |
| - i != windows.end(); ++i) { |
| - wm::WindowState* window_state = wm::GetWindowState(*i); |
| - if (window_state->ignored_by_shelf()) |
| + for (size_t i = 0; i < arraysize(kWindowContainerIds); i++) { |
| + WmWindow* container = viewport_->GetRootWindow()->GetChildByShellWindowId( |
| + kWindowContainerIds[i]); |
| + for (WmWindow* window : container->GetChildren()) { |
| + wm::WindowState* window_state = window->GetWindowState(); |
| + if ((window_state && window_state->ignored_by_shelf()) || |
|
James Cook
2016/08/11 23:27:36
Kinda weird that window_state can be null. The aur
msw
2016/08/12 00:17:15
This check isn't needed in the latest patch set; r
|
| + !window->GetLayer()->GetTargetVisibility()) { |
| continue; |
| - ui::Layer* layer = (*i)->layer(); |
| - if (!layer->GetTargetVisibility()) |
| - continue; |
| - if (window_state->IsMaximized()) { |
| - return wm::WORKSPACE_WINDOW_STATE_MAXIMIZED; |
| - } |
| - if (!window_overlaps_launcher && |
| - ((*i)->bounds().Intersects(shelf_bounds))) { |
| - window_overlaps_launcher = true; |
| } |
| + if (window_state && window_state->IsMaximized()) |
| + return wm::WORKSPACE_WINDOW_STATE_MAXIMIZED; |
| + window_overlaps_launcher |= window->GetBounds().Intersects(shelf_bounds); |
| } |
| } |
| - return (window_overlaps_launcher || IsDockedAreaVisible(shelf_)) |
| + // Check if there are visible docked windows in the same display. |
| + DockedWindowLayoutManager* dock = DockedWindowLayoutManager::Get(viewport_); |
| + const bool docked_area_visible = dock && !dock->docked_bounds().IsEmpty(); |
| + return (window_overlaps_launcher || docked_area_visible) |
| ? wm::WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF |
| : wm::WORKSPACE_WINDOW_STATE_DEFAULT; |
| } |
| -void WorkspaceController::SetShelf(ShelfLayoutManager* shelf) { |
| - shelf_ = shelf; |
| -} |
| - |
| void WorkspaceController::DoInitialAnimation() { |
| viewport_->Show(); |
| - viewport_->layer()->SetOpacity(0.0f); |
| - SetTransformForScaleAnimation(viewport_->layer(), |
| + viewport_->GetLayer()->SetOpacity(0.0f); |
|
James Cook
2016/08/11 23:27:36
For 7 calls, I would create a local for the Layer*
msw
2016/08/12 00:17:15
Done.
|
| + SetTransformForScaleAnimation(viewport_->GetLayer(), |
| LAYER_SCALE_ANIMATION_ABOVE); |
| // In order for pause to work we need to stop animations. |
| - viewport_->layer()->GetAnimator()->StopAnimating(); |
| + viewport_->GetLayer()->GetAnimator()->StopAnimating(); |
| { |
| ui::ScopedLayerAnimationSettings settings( |
| - viewport_->layer()->GetAnimator()); |
| + viewport_->GetLayer()->GetAnimator()); |
| settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION); |
| - viewport_->layer()->GetAnimator()->SchedulePauseForProperties( |
| + viewport_->GetLayer()->GetAnimator()->SchedulePauseForProperties( |
| base::TimeDelta::FromMilliseconds(kInitialPauseTimeMS), |
| ui::LayerAnimationElement::TRANSFORM | |
| ui::LayerAnimationElement::OPACITY | |
| @@ -132,9 +115,9 @@ void WorkspaceController::DoInitialAnimation() { |
| ui::LayerAnimationElement::VISIBILITY); |
| settings.SetTweenType(gfx::Tween::EASE_OUT); |
| settings.SetTransitionDuration( |
| - base::TimeDelta::FromMilliseconds(kCrossFadeDurationMS)); |
| - viewport_->layer()->SetTransform(gfx::Transform()); |
| - viewport_->layer()->SetOpacity(1.0f); |
| + base::TimeDelta::FromMilliseconds(kIntialAnimationDurationMS)); |
| + viewport_->GetLayer()->SetTransform(gfx::Transform()); |
| + viewport_->GetLayer()->SetOpacity(1.0f); |
| } |
| } |