Index: ash/wm/workspace/workspace_layout_manager.cc |
diff --git a/ash/wm/workspace/workspace_layout_manager.cc b/ash/wm/workspace/workspace_layout_manager.cc |
index 1f8847a72e6b689be9d61ef22eb917acd39f2043..45f98b62b2fe88ab1a1f69183ce636db800287ce 100644 |
--- a/ash/wm/workspace/workspace_layout_manager.cc |
+++ b/ash/wm/workspace/workspace_layout_manager.cc |
@@ -16,14 +16,12 @@ |
#include "ash/wm/window_properties.h" |
#include "ash/wm/window_state.h" |
#include "ash/wm/window_util.h" |
-#include "ash/wm/workspace/workspace_window_resizer.h" |
#include "ui/aura/client/activation_client.h" |
#include "ui/aura/client/aura_constants.h" |
#include "ui/aura/window.h" |
#include "ui/aura/window_observer.h" |
#include "ui/base/ui_base_types.h" |
#include "ui/compositor/layer.h" |
-#include "ui/compositor/scoped_layer_animation_settings.h" |
#include "ui/events/event.h" |
#include "ui/gfx/screen.h" |
#include "ui/views/corewm/window_util.h" |
@@ -40,49 +38,6 @@ namespace { |
// must be visible when the window is added to the workspace. |
const float kMinimumPercentOnScreenArea = 0.3f; |
-void MoveToDisplayForRestore(wm::WindowState* window_state) { |
- if (!window_state->HasRestoreBounds()) |
- return; |
- const gfx::Rect& restore_bounds = window_state->GetRestoreBoundsInScreen(); |
- |
- // Move only if the restore bounds is outside of |
- // the display. There is no information about in which |
- // display it should be restored, so this is best guess. |
- // TODO(oshima): Restore information should contain the |
- // work area information like WindowResizer does for the |
- // last window location. |
- gfx::Rect display_area = Shell::GetScreen()->GetDisplayNearestWindow( |
- window_state->window()).bounds(); |
- |
- if (!display_area.Intersects(restore_bounds)) { |
- const gfx::Display& display = |
- Shell::GetScreen()->GetDisplayMatching(restore_bounds); |
- DisplayController* display_controller = |
- Shell::GetInstance()->display_controller(); |
- aura::Window* new_root = |
- display_controller->GetRootWindowForDisplayId(display.id()); |
- if (new_root != window_state->window()->GetRootWindow()) { |
- aura::Window* new_container = |
- Shell::GetContainer(new_root, window_state->window()->parent()->id()); |
- new_container->AddChild(window_state->window()); |
- } |
- } |
-} |
- |
-gfx::Rect BoundsWithScreenEdgeVisible( |
- aura::Window* window, |
- const gfx::Rect& restore_bounds) { |
- gfx::Rect max_bounds = |
- ash::ScreenUtil::GetMaximizedWindowBoundsInParent(window); |
- // If the restore_bounds are more than 1 grid step away from the size the |
- // window would be when maximized, inset it. |
- max_bounds.Inset(ash::internal::WorkspaceWindowResizer::kScreenEdgeInset, |
- ash::internal::WorkspaceWindowResizer::kScreenEdgeInset); |
- if (restore_bounds.Contains(max_bounds)) |
- return max_bounds; |
- return restore_bounds; |
-} |
- |
} // namespace |
WorkspaceLayoutManager::WorkspaceLayoutManager(aura::Window* window) |
@@ -184,7 +139,7 @@ void WorkspaceLayoutManager::SetChildBounds( |
child_bounds.width())); |
child_bounds.set_height(std::min(work_area_in_parent_.height(), |
child_bounds.height())); |
- AdjustSnappedBounds(window_state, &child_bounds); |
+ window_state->AdjustSnappedBounds(&child_bounds); |
SetChildBoundsDirect(child, child_bounds); |
} |
UpdateShelfVisibility(); |
@@ -252,37 +207,9 @@ void WorkspaceLayoutManager::OnWindowActivated(aura::Window* gained_active, |
////////////////////////////////////////////////////////////////////////////// |
// WorkspaceLayoutManager, wm::WindowStateObserver implementation: |
-void WorkspaceLayoutManager::OnWindowShowTypeChanged( |
+void WorkspaceLayoutManager::OnPostWindowShowTypeChange( |
wm::WindowState* window_state, |
wm::WindowShowType old_type) { |
- if (old_type != wm::SHOW_TYPE_MINIMIZED && |
- !window_state->HasRestoreBounds() && |
- window_state->IsMaximizedOrFullscreen() && |
- !wm::IsMaximizedOrFullscreenWindowShowType(old_type)) { |
- window_state->SaveCurrentBoundsForRestore(); |
- } |
- // When restoring from a minimized state, we want to restore to the previous |
- // bounds. However, we want to maintain the restore bounds. (The restore |
- // bounds are set if a user maximized the window in one axis by double |
- // clicking the window border for example). |
- gfx::Rect restore; |
- if (old_type == wm::SHOW_TYPE_MINIMIZED && |
- window_state->IsNormalShowState() && |
- window_state->HasRestoreBounds() && |
- !window_state->unminimize_to_restore_bounds()) { |
- restore = window_state->GetRestoreBoundsInScreen(); |
- window_state->SaveCurrentBoundsForRestore(); |
- } |
- |
- UpdateBoundsFromShowType(window_state, old_type); |
- ShowTypeChanged(window_state, old_type); |
- |
- if (window_state->IsNormalShowState()) |
- window_state->ClearRestoreBounds(); |
- |
- // Set the restore rectangle to the previously set restore rectangle. |
- if (!restore.IsEmpty()) |
- window_state->SetRestoreBoundsInScreen(restore); |
// Notify observers that fullscreen state may be changing. |
if (window_state->IsFullscreen() || old_type == wm::SHOW_TYPE_FULLSCREEN) |
@@ -291,34 +218,6 @@ void WorkspaceLayoutManager::OnWindowShowTypeChanged( |
UpdateShelfVisibility(); |
} |
-void WorkspaceLayoutManager::ShowTypeChanged( |
- wm::WindowState* window_state, |
- wm::WindowShowType last_show_type) { |
- if (window_state->IsMinimized()) { |
- // Save the previous show state so that we can correctly restore it. |
- window_state->window()->SetProperty(aura::client::kRestoreShowStateKey, |
- wm::ToWindowShowState(last_show_type)); |
- views::corewm::SetWindowVisibilityAnimationType( |
- window_state->window(), WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE); |
- |
- // Hide the window. |
- window_state->window()->Hide(); |
- // Activate another window. |
- if (window_state->IsActive()) |
- window_state->Deactivate(); |
- } else if ((window_state->window()->TargetVisibility() || |
- last_show_type == wm::SHOW_TYPE_MINIMIZED) && |
- !window_state->window()->layer()->visible()) { |
- // The layer may be hidden if the window was previously minimized. Make |
- // sure it's visible. |
- window_state->window()->Show(); |
- if (last_show_type == wm::SHOW_TYPE_MINIMIZED && |
- !window_state->IsMaximizedOrFullscreen()) { |
- window_state->set_unminimize_to_restore_bounds(false); |
- } |
- } |
-} |
- |
////////////////////////////////////////////////////////////////////////////// |
// WorkspaceLayoutManager, private: |
@@ -380,9 +279,9 @@ void WorkspaceLayoutManager::AdjustWindowBoundsForWorkAreaChange( |
work_area_in_parent_, &bounds); |
break; |
} |
- //AdjustSnappedBounds(window_state, &bounds); |
+ window_state->AdjustSnappedBounds(&bounds); |
if (window_state->window()->bounds() != bounds) |
- SetChildBoundsAnimated(window_state->window(), bounds); |
+ window_state->SetBoundsDirectAnimated(bounds); |
} |
void WorkspaceLayoutManager::AdjustWindowBoundsWhenAdded( |
@@ -411,7 +310,7 @@ void WorkspaceLayoutManager::AdjustWindowBoundsWhenAdded( |
int min_height = bounds.height() * kMinimumPercentOnScreenArea; |
ash::wm::AdjustBoundsToEnsureWindowVisibility( |
display_area, min_width, min_height, &bounds); |
- AdjustSnappedBounds(window_state, &bounds); |
+ window_state->AdjustSnappedBounds(&bounds); |
if (window->bounds() != bounds) |
window->SetBounds(bounds); |
} |
@@ -431,66 +330,6 @@ void WorkspaceLayoutManager::UpdateFullscreenState() { |
} |
} |
-void WorkspaceLayoutManager::UpdateBoundsFromShowType( |
- wm::WindowState* window_state, |
- wm::WindowShowType old_show_type) { |
- aura::Window* window = window_state->window(); |
- if (window_state->IsMaximizedOrFullscreen()) |
- MoveToDisplayForRestore(window_state); |
- |
- wm::WindowShowType show_type = window_state->window_show_type(); |
- gfx::Rect bounds_in_parent; |
- switch (show_type) { |
- case wm::SHOW_TYPE_DEFAULT: |
- case wm::SHOW_TYPE_NORMAL: |
- case wm::SHOW_TYPE_LEFT_SNAPPED: |
- case wm::SHOW_TYPE_RIGHT_SNAPPED: |
- if (window_state->HasRestoreBounds()) |
- bounds_in_parent = window_state->GetRestoreBoundsInParent(); |
- else |
- bounds_in_parent = window->bounds(); |
- // Make sure that part of the window is always visible. |
- wm::AdjustBoundsToEnsureMinimumWindowVisibility( |
- work_area_in_parent_, &bounds_in_parent); |
- |
- if (show_type == wm::SHOW_TYPE_LEFT_SNAPPED || |
- show_type == wm::SHOW_TYPE_RIGHT_SNAPPED) { |
- AdjustSnappedBounds(window_state, &bounds_in_parent); |
- } else { |
- bounds_in_parent = BoundsWithScreenEdgeVisible( |
- window, |
- bounds_in_parent); |
- } |
- break; |
- |
- case wm::SHOW_TYPE_MAXIMIZED: |
- bounds_in_parent = ScreenUtil::GetMaximizedWindowBoundsInParent(window); |
- break; |
- |
- case wm::SHOW_TYPE_FULLSCREEN: |
- bounds_in_parent = ScreenUtil::GetDisplayBoundsInParent(window); |
- break; |
- |
- case wm::SHOW_TYPE_MINIMIZED: |
- case wm::SHOW_TYPE_INACTIVE: |
- case wm::SHOW_TYPE_DETACHED: |
- case wm::SHOW_TYPE_END: |
- case wm::SHOW_TYPE_AUTO_POSITIONED: |
- return; |
- } |
- |
- if (old_show_type == wm::SHOW_TYPE_MINIMIZED || |
- (window_state->IsFullscreen() && |
- !window_state->animate_to_fullscreen())) { |
- SetChildBoundsDirect(window, bounds_in_parent); |
- } else if (window_state->IsMaximizedOrFullscreen() || |
- IsMaximizedOrFullscreenWindowShowType(old_show_type)) { |
- CrossFadeToBounds(window, bounds_in_parent); |
- } else { |
- SetChildBoundsAnimated(window, bounds_in_parent); |
- } |
-} |
- |
bool WorkspaceLayoutManager::SetMaximizedOrFullscreenBounds( |
wm::WindowState* window_state) { |
DCHECK(!window_state->is_dragged()); |
@@ -510,33 +349,5 @@ bool WorkspaceLayoutManager::SetMaximizedOrFullscreenBounds( |
return false; |
} |
-void WorkspaceLayoutManager::AdjustSnappedBounds(wm::WindowState* window_state, |
- gfx::Rect* bounds) { |
- if (window_state->is_dragged() || !window_state->IsSnapped()) |
- return; |
- gfx::Rect maximized_bounds = ScreenUtil::GetMaximizedWindowBoundsInParent( |
- window_state->window()); |
- if (window_state->window_show_type() == wm::SHOW_TYPE_LEFT_SNAPPED) |
- bounds->set_x(maximized_bounds.x()); |
- else if (window_state->window_show_type() == wm::SHOW_TYPE_RIGHT_SNAPPED) |
- bounds->set_x(maximized_bounds.right() - bounds->width()); |
- bounds->set_y(maximized_bounds.y()); |
- // TODO(varkha): Set width to 50% here for snapped windows. |
- bounds->set_height(maximized_bounds.height()); |
-} |
- |
-void WorkspaceLayoutManager::SetChildBoundsAnimated(Window* child, |
- const gfx::Rect& bounds) { |
- const int kBoundsChangeSlideDurationMs = 120; |
- |
- ui::Layer* layer = child->layer(); |
- ui::ScopedLayerAnimationSettings slide_settings(layer->GetAnimator()); |
- slide_settings.SetPreemptionStrategy( |
- ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
- slide_settings.SetTransitionDuration( |
- base::TimeDelta::FromMilliseconds(kBoundsChangeSlideDurationMs)); |
- SetChildBoundsDirect(child, bounds); |
-} |
- |
} // namespace internal |
} // namespace ash |