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

Unified Diff: ash/wm/base_layout_manager.cc

Issue 10444014: ash: Improved window maximize/restore animations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix workspace mgr, remove ignore_window, cleanup Created 8 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/base_layout_manager.cc
diff --git a/ash/wm/base_layout_manager.cc b/ash/wm/base_layout_manager.cc
index 4f27115e81e160c7d72b3e301e51e1f00858583a..1cabafa7c2241a25863cd81037c038f0596ec11b 100644
--- a/ash/wm/base_layout_manager.cc
+++ b/ash/wm/base_layout_manager.cc
@@ -4,12 +4,14 @@
#include "ash/wm/base_layout_manager.h"
+#include "ash/ash_switches.h"
#include "ash/screen_ash.h"
#include "ash/shell.h"
#include "ash/wm/shelf_layout_manager.h"
#include "ash/wm/window_animations.h"
#include "ash/wm/window_properties.h"
#include "ash/wm/window_util.h"
+#include "base/command_line.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
@@ -75,7 +77,7 @@ void BaseLayoutManager::OnWindowAddedToLayout(aura::Window* child) {
// Only update the bounds if the window has a show state that depends on the
// workspace area.
if (wm::IsWindowMaximized(child) || wm::IsWindowFullscreen(child))
- UpdateBoundsFromShowState(child);
+ UpdateBoundsFromShowState(child, false);
}
void BaseLayoutManager::OnWillRemoveWindowFromLayout(aura::Window* child) {
@@ -98,14 +100,9 @@ void BaseLayoutManager::OnChildWindowVisibilityChanged(aura::Window* child,
void BaseLayoutManager::SetChildBounds(aura::Window* child,
const gfx::Rect& requested_bounds) {
- gfx::Rect child_bounds(requested_bounds);
- // Avoid a janky resize on startup by ensuring the initial bounds fill the
- // screen.
- if (wm::IsWindowMaximized(child))
- child_bounds = ScreenAsh::GetMaximizedWindowBounds(child);
- else if (wm::IsWindowFullscreen(child))
- child_bounds = gfx::Screen::GetMonitorNearestWindow(child).bounds();
- SetChildBoundsDirect(child, child_bounds);
+ // Just set the bounds immediately. We fix up maximized and fullscreen
+ // bounds in OnWindowAddedToLayout() above.
+ SetChildBoundsDirect(child, requested_bounds);
}
/////////////////////////////////////////////////////////////////////////////
@@ -130,7 +127,7 @@ void BaseLayoutManager::OnWindowPropertyChanged(aura::Window* window,
const void* key,
intptr_t old) {
if (key == aura::client::kShowStateKey) {
- UpdateBoundsFromShowState(window);
+ UpdateBoundsFromShowState(window, true);
ShowStateChanged(window, static_cast<ui::WindowShowState>(old));
}
}
@@ -167,13 +164,15 @@ void BaseLayoutManager::ShowStateChanged(aura::Window* window,
}
}
-void BaseLayoutManager::UpdateBoundsFromShowState(aura::Window* window) {
+void BaseLayoutManager::UpdateBoundsFromShowState(aura::Window* window,
+ bool animate) {
switch (window->GetProperty(aura::client::kShowStateKey)) {
case ui::SHOW_STATE_DEFAULT:
case ui::SHOW_STATE_NORMAL: {
const gfx::Rect* restore = GetRestoreBounds(window);
if (restore) {
- SetChildBoundsDirect(window,
+ MaybeAnimateToBounds(window,
+ animate,
BoundsWithScreenEdgeVisible(window, *restore));
}
window->ClearProperty(aura::client::kRestoreBoundsKey);
@@ -182,13 +181,17 @@ void BaseLayoutManager::UpdateBoundsFromShowState(aura::Window* window) {
case ui::SHOW_STATE_MAXIMIZED:
SetRestoreBoundsIfNotSet(window);
- SetChildBoundsDirect(window, ScreenAsh::GetMaximizedWindowBounds(window));
+ MaybeAnimateToBounds(window,
+ animate,
+ ScreenAsh::GetMaximizedWindowBounds(window));
break;
case ui::SHOW_STATE_FULLSCREEN:
SetRestoreBoundsIfNotSet(window);
- SetChildBoundsDirect(
- window, gfx::Screen::GetMonitorNearestWindow(window).bounds());
+ MaybeAnimateToBounds(
+ window,
+ animate,
+ gfx::Screen::GetMonitorNearestWindow(window).bounds());
break;
default:
@@ -196,6 +199,20 @@ void BaseLayoutManager::UpdateBoundsFromShowState(aura::Window* window) {
}
}
+void BaseLayoutManager::MaybeAnimateToBounds(aura::Window* window,
+ bool animate,
+ const gfx::Rect& new_bounds) {
+ // Only animate visible windows.
+ if (animate &&
+ window->TargetVisibility() &&
+ !CommandLine::ForCurrentProcess()->HasSwitch(
+ ash::switches::kAuraWindowAnimationsDisabled)) {
+ CrossFadeToBounds(window, new_bounds);
+ return;
+ }
+ SetChildBoundsDirect(window, new_bounds);
+}
+
void BaseLayoutManager::AdjustWindowSizesForScreenChange() {
// If a user plugs an external monitor into a laptop running Aura the
// monitor size will change. Maximized windows need to resize to match.

Powered by Google App Engine
This is Rietveld 408576698