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) {
base::BindOnce(&RootWindowController::OnFirstWallpaperWidgetSet,
base::Unretained(this)));
int container = Shell::Get()->session_controller()->IsUserSessionBlocked()
? kShellWindowId_LockScreenWallpaperContainer
: kShellWindowId_WallpaperContainer;
wallpaper_widget_controller_->Init(container);
wallpaper_widget_controller_->Init(
Shell::Get()->session_controller()->IsUserSessionBlocked());
root_window_layout_manager_->OnWindowResized();
// Explicitly update the desks controller before notifying the ShellObservers.
......
......@@ -1379,7 +1379,8 @@ void WallpaperControllerImpl::OnRootWindowAdded(aura::Window* root_window) {
ReloadWallpaper(/*clear_cache=*/true);
}
UpdateWallpaperForRootWindow(root_window, /*lock_state_changed=*/false);
UpdateWallpaperForRootWindow(root_window, /*lock_state_changed=*/false,
/*new_root=*/true);
}
void WallpaperControllerImpl::OnShellInitialized() {
......@@ -1471,7 +1472,8 @@ void WallpaperControllerImpl::ReloadWallpaperForTesting(bool clear_cache) {
void WallpaperControllerImpl::UpdateWallpaperForRootWindow(
aura::Window* root_window,
bool lock_state_changed) {
bool lock_state_changed,
bool new_root) {
DCHECK_EQ(WALLPAPER_IMAGE, wallpaper_mode_);
auto* wallpaper_widget_controller =
......@@ -1480,7 +1482,7 @@ void WallpaperControllerImpl::UpdateWallpaperForRootWindow(
WallpaperProperty property =
wallpaper_widget_controller->GetWallpaperProperty();
if (lock_state_changed) {
if (lock_state_changed || new_root) {
const bool is_wallpaper_blurred_for_lock_state =
Shell::Get()->session_controller()->IsUserSessionBlocked() &&
IsBlurAllowedForLockState();
......@@ -1501,13 +1503,13 @@ void WallpaperControllerImpl::UpdateWallpaperForRootWindow(
wallpaper_widget_controller->wallpaper_view()->ClearCachedImage();
wallpaper_widget_controller->SetWallpaperProperty(
property, kWallpaperLoadAnimationDuration);
property, new_root ? base::TimeDelta() : kWallpaperLoadAnimationDuration);
}
void WallpaperControllerImpl::UpdateWallpaperForAllRootWindows(
bool lock_state_changed) {
for (aura::Window* root : Shell::GetAllRootWindows())
UpdateWallpaperForRootWindow(root, lock_state_changed);
UpdateWallpaperForRootWindow(root, lock_state_changed, /*new_root=*/false);
current_max_display_size_ = GetMaxDisplaySizeInNative();
}
......
......@@ -347,7 +347,8 @@ class ASH_EXPORT WallpaperControllerImpl
// Update a Wallpaper for |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.
void UpdateWallpaperForAllRootWindows(bool lock_state_changed);
......
......@@ -2785,4 +2785,20 @@ TEST_F(WallpaperControllerPrefTest, InitWithPrefs) {
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
......@@ -4,6 +4,7 @@
#include "ash/wallpaper/wallpaper_view.h"
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/public/cpp/window_animation_types.h"
#include "ash/root_window_controller.h"
#include "ash/session/session_controller_impl.h"
......@@ -208,9 +209,11 @@ void WallpaperView::DrawWallpaper(const gfx::ImageSkia& wallpaper,
std::unique_ptr<views::Widget> CreateWallpaperWidget(
aura::Window* root_window,
int container_id,
const WallpaperProperty& property,
bool locked,
WallpaperView** out_wallpaper_view) {
int container_id = locked ? kShellWindowId_LockScreenWallpaperContainer
: kShellWindowId_WallpaperContainer;
auto* controller = Shell::Get()->wallpaper_controller();
auto wallpaper_widget = std::make_unique<views::Widget>();
......@@ -238,11 +241,13 @@ std::unique_ptr<views::Widget> CreateWallpaperWidget(
// 2. Wallpaper fades in from a non empty background.
// 3. From an empty background, chrome transit to a logged in user session.
// 4. From an empty background, guest user logged in.
if (controller->ShouldShowInitialAnimation() ||
// except for the lock state.
if (!locked &&
(controller->ShouldShowInitialAnimation() ||
RootWindowController::ForWindow(root_window)
->wallpaper_widget_controller()
->IsAnimating() ||
Shell::Get()->session_controller()->NumberOfLoggedInUsers()) {
Shell::Get()->session_controller()->NumberOfLoggedInUsers())) {
::wm::SetWindowVisibilityAnimationTransition(wallpaper_window,
::wm::ANIMATE_SHOW);
base::TimeDelta animation_duration = controller->animation_duration();
......
......@@ -68,8 +68,8 @@ class WallpaperView : public WallpaperBaseView,
std::unique_ptr<views::Widget> CreateWallpaperWidget(
aura::Window* root_window,
int container_id,
const WallpaperProperty& property,
bool locked,
WallpaperView** out_wallpaper_view);
} // namespace ash
......
......@@ -34,9 +34,9 @@ WallpaperWidgetController::~WallpaperWidgetController() {
widget_->CloseNow();
}
void WallpaperWidgetController::Init(int container) {
widget_ = CreateWallpaperWidget(
root_window_, container, wallpaper_constants::kClear, &wallpaper_view_);
void WallpaperWidgetController::Init(bool locked) {
widget_ = CreateWallpaperWidget(root_window_, wallpaper_constants::kClear,
locked, &wallpaper_view_);
}
views::Widget* WallpaperWidgetController::GetWidget() {
......
......@@ -39,9 +39,9 @@ class ASH_EXPORT WallpaperWidgetController
base::OnceClosure wallpaper_set_callback);
~WallpaperWidgetController() override;
// Initialize the widget. |container| specifies the id of the parent container
// the window will be added to.
void Init(int container);
// Initialize the widget. |lock| specifies if the wallpaper should be created
// for the locked state.
void Init(bool locked);
views::Widget* GetWidget();
......
......@@ -1414,11 +1414,13 @@ void DisplayManager::AddRemoveDisplay(
const int kVerticalOffsetPx = 100;
// 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(),
host_bounds.bottom() + kVerticalOffsetPx,
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));
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