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

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 lock screen, app windows Created 8 years, 6 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
« no previous file with comments | « ash/wm/base_layout_manager.h ('k') | ash/wm/window_animations.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..f2de19351ff84b2644482d4eb58938887cddac65 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) {
@@ -99,8 +101,7 @@ 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.
+ // Some windows rely on this to set their initial bounds.
if (wm::IsWindowMaximized(child))
child_bounds = ScreenAsh::GetMaximizedWindowBounds(child);
else if (wm::IsWindowFullscreen(child))
@@ -130,7 +131,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 +168,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,11 +185,15 @@ 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);
+ // Don't animate the full-screen window transition.
+ // TODO(jamescook): Use animation here. Be sure the lock screen works.
SetChildBoundsDirect(
window, gfx::Screen::GetMonitorNearestWindow(window).bounds());
break;
@@ -196,6 +203,21 @@ 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() &&
+ !window->GetProperty(aura::client::kAnimationsDisabledKey) &&
+ !CommandLine::ForCurrentProcess()->HasSwitch(
+ ash::switches::kAshWindowAnimationsDisabled)) {
+ 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.
« no previous file with comments | « ash/wm/base_layout_manager.h ('k') | ash/wm/window_animations.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698