| Index: ash/wm/screen_dimmer.cc
|
| diff --git a/ash/wm/screen_dimmer.cc b/ash/wm/screen_dimmer.cc
|
| index 25bf266cf552570abeb854288931d0f9d882d323..3d89039722e9daa2978ab22fc25f7d9aac9b3367 100644
|
| --- a/ash/wm/screen_dimmer.cc
|
| +++ b/ash/wm/screen_dimmer.cc
|
| @@ -4,66 +4,27 @@
|
|
|
| #include "ash/wm/screen_dimmer.h"
|
|
|
| -#include "ash/aura/wm_window_aura.h"
|
| +#include "ash/common/shell_window_ids.h"
|
| #include "ash/common/wm/container_finder.h"
|
| #include "ash/common/wm/window_dimmer.h"
|
| #include "ash/common/wm_shell.h"
|
| #include "ash/common/wm_window.h"
|
| #include "ash/common/wm_window_user_data.h"
|
| #include "base/memory/ptr_util.h"
|
| -#include "ui/aura/window.h"
|
| -#include "ui/aura/window_property.h"
|
| -
|
| -DECLARE_WINDOW_PROPERTY_TYPE(ash::ScreenDimmer*);
|
|
|
| namespace ash {
|
| namespace {
|
| -DEFINE_OWNED_WINDOW_PROPERTY_KEY(ScreenDimmer, kScreenDimmerKey, nullptr);
|
|
|
| // Opacity when it's dimming the entire screen.
|
| const float kDimmingLayerOpacityForRoot = 0.4f;
|
|
|
| -// Id used to indicate the root window.
|
| -const int kRootWindowMagicId = -100;
|
| -
|
| -std::vector<WmWindow*> GetAllContainers(int container_id) {
|
| - return container_id == kRootWindowMagicId
|
| - ? WmShell::Get()->GetAllRootWindows()
|
| - : wm::GetContainersFromAllRootWindows(container_id);
|
| -}
|
| -
|
| -WmWindow* FindContainer(int container_id) {
|
| - WmWindow* primary = WmShell::Get()->GetPrimaryRootWindow();
|
| - return container_id == kRootWindowMagicId
|
| - ? primary
|
| - : primary->GetChildByShellWindowId(container_id);
|
| -}
|
| +// Opacity for lock screen.
|
| +const float kDimmingLayerOpacityForLockScreen = 0.5f;
|
|
|
| } // namespace
|
|
|
| -// static
|
| -ScreenDimmer* ScreenDimmer::GetForContainer(int container_id) {
|
| - aura::Window* primary_container =
|
| - WmWindowAura::GetAuraWindow(FindContainer(container_id));
|
| - ScreenDimmer* dimmer = primary_container->GetProperty(kScreenDimmerKey);
|
| - if (!dimmer) {
|
| - dimmer = new ScreenDimmer(container_id);
|
| - primary_container->SetProperty(kScreenDimmerKey, dimmer);
|
| - }
|
| - return dimmer;
|
| -}
|
| -
|
| -// static
|
| -ScreenDimmer* ScreenDimmer::GetForRoot() {
|
| - ScreenDimmer* dimmer = GetForContainer(kRootWindowMagicId);
|
| - // Root window's dimmer
|
| - dimmer->target_opacity_ = kDimmingLayerOpacityForRoot;
|
| - return dimmer;
|
| -}
|
| -
|
| -ScreenDimmer::ScreenDimmer(int container_id)
|
| - : container_id_(container_id),
|
| - target_opacity_(0.5f),
|
| +ScreenDimmer::ScreenDimmer(Container container)
|
| + : container_(container),
|
| is_dimming_(false),
|
| at_bottom_(false),
|
| window_dimmers_(base::MakeUnique<WmWindowUserData<WindowDimmer>>()) {
|
| @@ -82,10 +43,11 @@ void ScreenDimmer::SetDimming(bool should_dim) {
|
| Update(should_dim);
|
| }
|
|
|
| -// static
|
| -ScreenDimmer* ScreenDimmer::FindForTest(int container_id) {
|
| - return WmWindowAura::GetAuraWindow(FindContainer(container_id))
|
| - ->GetProperty(kScreenDimmerKey);
|
| +std::vector<WmWindow*> ScreenDimmer::GetAllContainers() {
|
| + return container_ == Container::ROOT
|
| + ? WmShell::Get()->GetAllRootWindows()
|
| + : wm::GetContainersFromAllRootWindows(
|
| + ash::kShellWindowId_LockScreenContainersContainer);
|
| }
|
|
|
| void ScreenDimmer::OnRootWindowAdded(WmWindow* root_window) {
|
| @@ -93,14 +55,16 @@ void ScreenDimmer::OnRootWindowAdded(WmWindow* root_window) {
|
| }
|
|
|
| void ScreenDimmer::Update(bool should_dim) {
|
| - for (WmWindow* container : GetAllContainers(container_id_)) {
|
| + for (WmWindow* container : GetAllContainers()) {
|
| WindowDimmer* window_dimmer = window_dimmers_->Get(container);
|
| if (should_dim) {
|
| if (!window_dimmer) {
|
| window_dimmers_->Set(container,
|
| base::MakeUnique<WindowDimmer>(container));
|
| window_dimmer = window_dimmers_->Get(container);
|
| - window_dimmer->SetDimOpacity(target_opacity_);
|
| + window_dimmer->SetDimOpacity(container_ == Container::ROOT
|
| + ? kDimmingLayerOpacityForRoot
|
| + : kDimmingLayerOpacityForLockScreen);
|
| }
|
| if (at_bottom_)
|
| container->StackChildAtBottom(window_dimmer->window());
|
|
|