Commit 6193472c authored by Mitsuru Oshima's avatar Mitsuru Oshima Committed by Commit Bot

Do not animate new Wallpaper when locked.

This also fixes the blur on this new wallpaper.

Plus, change AddRemoveDisplay to use the same display id
for added display.

Fixed: 1126186
Test: covered by unittest

Change-Id: I2698d8f073f58edb18e29e84e7e16c4296ea48a4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2425431
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Reviewed-by: default avatarSammie Quon <sammiequon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810275}
parent cdd2cdd8
...@@ -880,11 +880,8 @@ void RootWindowController::Init(RootWindowType root_window_type) { ...@@ -880,11 +880,8 @@ void RootWindowController::Init(RootWindowType root_window_type) {
base::BindOnce(&RootWindowController::OnFirstWallpaperWidgetSet, base::BindOnce(&RootWindowController::OnFirstWallpaperWidgetSet,
base::Unretained(this))); base::Unretained(this)));
int container = Shell::Get()->session_controller()->IsUserSessionBlocked() wallpaper_widget_controller_->Init(
? kShellWindowId_LockScreenWallpaperContainer Shell::Get()->session_controller()->IsUserSessionBlocked());
: kShellWindowId_WallpaperContainer;
wallpaper_widget_controller_->Init(container);
root_window_layout_manager_->OnWindowResized(); root_window_layout_manager_->OnWindowResized();
// Explicitly update the desks controller before notifying the ShellObservers. // Explicitly update the desks controller before notifying the ShellObservers.
......
...@@ -1379,7 +1379,8 @@ void WallpaperControllerImpl::OnRootWindowAdded(aura::Window* root_window) { ...@@ -1379,7 +1379,8 @@ void WallpaperControllerImpl::OnRootWindowAdded(aura::Window* root_window) {
ReloadWallpaper(/*clear_cache=*/true); ReloadWallpaper(/*clear_cache=*/true);
} }
UpdateWallpaperForRootWindow(root_window, /*lock_state_changed=*/false); UpdateWallpaperForRootWindow(root_window, /*lock_state_changed=*/false,
/*new_root=*/true);
} }
void WallpaperControllerImpl::OnShellInitialized() { void WallpaperControllerImpl::OnShellInitialized() {
...@@ -1471,7 +1472,8 @@ void WallpaperControllerImpl::ReloadWallpaperForTesting(bool clear_cache) { ...@@ -1471,7 +1472,8 @@ void WallpaperControllerImpl::ReloadWallpaperForTesting(bool clear_cache) {
void WallpaperControllerImpl::UpdateWallpaperForRootWindow( void WallpaperControllerImpl::UpdateWallpaperForRootWindow(
aura::Window* root_window, aura::Window* root_window,
bool lock_state_changed) { bool lock_state_changed,
bool new_root) {
DCHECK_EQ(WALLPAPER_IMAGE, wallpaper_mode_); DCHECK_EQ(WALLPAPER_IMAGE, wallpaper_mode_);
auto* wallpaper_widget_controller = auto* wallpaper_widget_controller =
...@@ -1480,7 +1482,7 @@ void WallpaperControllerImpl::UpdateWallpaperForRootWindow( ...@@ -1480,7 +1482,7 @@ void WallpaperControllerImpl::UpdateWallpaperForRootWindow(
WallpaperProperty property = WallpaperProperty property =
wallpaper_widget_controller->GetWallpaperProperty(); wallpaper_widget_controller->GetWallpaperProperty();
if (lock_state_changed) { if (lock_state_changed || new_root) {
const bool is_wallpaper_blurred_for_lock_state = const bool is_wallpaper_blurred_for_lock_state =
Shell::Get()->session_controller()->IsUserSessionBlocked() && Shell::Get()->session_controller()->IsUserSessionBlocked() &&
IsBlurAllowedForLockState(); IsBlurAllowedForLockState();
...@@ -1501,13 +1503,13 @@ void WallpaperControllerImpl::UpdateWallpaperForRootWindow( ...@@ -1501,13 +1503,13 @@ void WallpaperControllerImpl::UpdateWallpaperForRootWindow(
wallpaper_widget_controller->wallpaper_view()->ClearCachedImage(); wallpaper_widget_controller->wallpaper_view()->ClearCachedImage();
wallpaper_widget_controller->SetWallpaperProperty( wallpaper_widget_controller->SetWallpaperProperty(
property, kWallpaperLoadAnimationDuration); property, new_root ? base::TimeDelta() : kWallpaperLoadAnimationDuration);
} }
void WallpaperControllerImpl::UpdateWallpaperForAllRootWindows( void WallpaperControllerImpl::UpdateWallpaperForAllRootWindows(
bool lock_state_changed) { bool lock_state_changed) {
for (aura::Window* root : Shell::GetAllRootWindows()) for (aura::Window* root : Shell::GetAllRootWindows())
UpdateWallpaperForRootWindow(root, lock_state_changed); UpdateWallpaperForRootWindow(root, lock_state_changed, /*new_root=*/false);
current_max_display_size_ = GetMaxDisplaySizeInNative(); current_max_display_size_ = GetMaxDisplaySizeInNative();
} }
......
...@@ -347,7 +347,8 @@ class ASH_EXPORT WallpaperControllerImpl ...@@ -347,7 +347,8 @@ class ASH_EXPORT WallpaperControllerImpl
// Update a Wallpaper for |root_window|. // Update a Wallpaper for |root_window|.
void UpdateWallpaperForRootWindow(aura::Window* root_window, void UpdateWallpaperForRootWindow(aura::Window* root_window,
bool lock_state_changed); bool lock_state_changed,
bool new_root);
// Update a Wallpaper for all root windows. // Update a Wallpaper for all root windows.
void UpdateWallpaperForAllRootWindows(bool lock_state_changed); void UpdateWallpaperForAllRootWindows(bool lock_state_changed);
......
...@@ -2785,4 +2785,20 @@ TEST_F(WallpaperControllerPrefTest, InitWithPrefs) { ...@@ -2785,4 +2785,20 @@ TEST_F(WallpaperControllerPrefTest, InitWithPrefs) {
EXPECT_EQ(root_window->bounds().size(), wallpaper_view->bounds().size()); EXPECT_EQ(root_window->bounds().size(), wallpaper_view->bounds().size());
} }
TEST_F(WallpaperControllerTest, NoAnimationForNewRootWindowWhenLocked) {
ui::ScopedAnimationDurationScaleMode test_duration_mode(
ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
SetSessionState(SessionState::LOCKED);
UpdateDisplay("800x600, 800x600");
auto* secondary_root_window_controller =
Shell::Get()->GetAllRootWindowControllers()[1];
EXPECT_FALSE(secondary_root_window_controller->wallpaper_widget_controller()
->IsAnimating());
EXPECT_FALSE(secondary_root_window_controller->wallpaper_widget_controller()
->GetWidget()
->GetLayer()
->GetAnimator()
->is_animating());
}
} // namespace ash } // namespace ash
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "ash/wallpaper/wallpaper_view.h" #include "ash/wallpaper/wallpaper_view.h"
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/public/cpp/window_animation_types.h" #include "ash/public/cpp/window_animation_types.h"
#include "ash/root_window_controller.h" #include "ash/root_window_controller.h"
#include "ash/session/session_controller_impl.h" #include "ash/session/session_controller_impl.h"
...@@ -208,9 +209,11 @@ void WallpaperView::DrawWallpaper(const gfx::ImageSkia& wallpaper, ...@@ -208,9 +209,11 @@ void WallpaperView::DrawWallpaper(const gfx::ImageSkia& wallpaper,
std::unique_ptr<views::Widget> CreateWallpaperWidget( std::unique_ptr<views::Widget> CreateWallpaperWidget(
aura::Window* root_window, aura::Window* root_window,
int container_id,
const WallpaperProperty& property, const WallpaperProperty& property,
bool locked,
WallpaperView** out_wallpaper_view) { WallpaperView** out_wallpaper_view) {
int container_id = locked ? kShellWindowId_LockScreenWallpaperContainer
: kShellWindowId_WallpaperContainer;
auto* controller = Shell::Get()->wallpaper_controller(); auto* controller = Shell::Get()->wallpaper_controller();
auto wallpaper_widget = std::make_unique<views::Widget>(); auto wallpaper_widget = std::make_unique<views::Widget>();
...@@ -238,11 +241,13 @@ std::unique_ptr<views::Widget> CreateWallpaperWidget( ...@@ -238,11 +241,13 @@ std::unique_ptr<views::Widget> CreateWallpaperWidget(
// 2. Wallpaper fades in from a non empty background. // 2. Wallpaper fades in from a non empty background.
// 3. From an empty background, chrome transit to a logged in user session. // 3. From an empty background, chrome transit to a logged in user session.
// 4. From an empty background, guest user logged in. // 4. From an empty background, guest user logged in.
if (controller->ShouldShowInitialAnimation() || // except for the lock state.
RootWindowController::ForWindow(root_window) if (!locked &&
->wallpaper_widget_controller() (controller->ShouldShowInitialAnimation() ||
->IsAnimating() || RootWindowController::ForWindow(root_window)
Shell::Get()->session_controller()->NumberOfLoggedInUsers()) { ->wallpaper_widget_controller()
->IsAnimating() ||
Shell::Get()->session_controller()->NumberOfLoggedInUsers())) {
::wm::SetWindowVisibilityAnimationTransition(wallpaper_window, ::wm::SetWindowVisibilityAnimationTransition(wallpaper_window,
::wm::ANIMATE_SHOW); ::wm::ANIMATE_SHOW);
base::TimeDelta animation_duration = controller->animation_duration(); base::TimeDelta animation_duration = controller->animation_duration();
......
...@@ -68,8 +68,8 @@ class WallpaperView : public WallpaperBaseView, ...@@ -68,8 +68,8 @@ class WallpaperView : public WallpaperBaseView,
std::unique_ptr<views::Widget> CreateWallpaperWidget( std::unique_ptr<views::Widget> CreateWallpaperWidget(
aura::Window* root_window, aura::Window* root_window,
int container_id,
const WallpaperProperty& property, const WallpaperProperty& property,
bool locked,
WallpaperView** out_wallpaper_view); WallpaperView** out_wallpaper_view);
} // namespace ash } // namespace ash
......
...@@ -34,9 +34,9 @@ WallpaperWidgetController::~WallpaperWidgetController() { ...@@ -34,9 +34,9 @@ WallpaperWidgetController::~WallpaperWidgetController() {
widget_->CloseNow(); widget_->CloseNow();
} }
void WallpaperWidgetController::Init(int container) { void WallpaperWidgetController::Init(bool locked) {
widget_ = CreateWallpaperWidget( widget_ = CreateWallpaperWidget(root_window_, wallpaper_constants::kClear,
root_window_, container, wallpaper_constants::kClear, &wallpaper_view_); locked, &wallpaper_view_);
} }
views::Widget* WallpaperWidgetController::GetWidget() { views::Widget* WallpaperWidgetController::GetWidget() {
......
...@@ -39,9 +39,9 @@ class ASH_EXPORT WallpaperWidgetController ...@@ -39,9 +39,9 @@ class ASH_EXPORT WallpaperWidgetController
base::OnceClosure wallpaper_set_callback); base::OnceClosure wallpaper_set_callback);
~WallpaperWidgetController() override; ~WallpaperWidgetController() override;
// Initialize the widget. |container| specifies the id of the parent container // Initialize the widget. |lock| specifies if the wallpaper should be created
// the window will be added to. // for the locked state.
void Init(int container); void Init(bool locked);
views::Widget* GetWidget(); views::Widget* GetWidget();
......
...@@ -1414,11 +1414,13 @@ void DisplayManager::AddRemoveDisplay( ...@@ -1414,11 +1414,13 @@ void DisplayManager::AddRemoveDisplay(
const int kVerticalOffsetPx = 100; const int kVerticalOffsetPx = 100;
// Layout the 2nd display below the primary as with the real device. // Layout the 2nd display below the primary as with the real device.
ManagedDisplayInfo display = ManagedDisplayInfo::CreateFromSpec( ManagedDisplayInfo display = ManagedDisplayInfo::CreateFromSpecWithID(
base::StringPrintf("%d+%d-%dx%d", host_bounds.x(), base::StringPrintf("%d+%d-%dx%d", host_bounds.x(),
host_bounds.bottom() + kVerticalOffsetPx, host_bounds.bottom() + kVerticalOffsetPx,
native_display_mode->size().width(), native_display_mode->size().width(),
native_display_mode->size().height())); native_display_mode->size().height()),
first_display.id() + 1);
display.SetManagedDisplayModes(std::move(display_modes)); display.SetManagedDisplayModes(std::move(display_modes));
new_display_info_list.push_back(std::move(display)); new_display_info_list.push_back(std::move(display));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment