Skip to content

Commit

Permalink
Add a semi-opaque backdrop mode
Browse files Browse the repository at this point in the history
Change black background to semi-opaque (60% #202124) for 'Add Account'
dialog. This is a short term fix until crbug/1016828 is resolved.

Bug: 997479, 1016828
Change-Id: I4741e2847f25b30a5ca3ee295569ea0c1c81cf4f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1847274
Commit-Queue: Anastasiia Nikolaienko <anastasiian@chromium.org>
Reviewed-by: Steven Bennetts <stevenjb@chromium.org>
Reviewed-by: Mitsuru Oshima (slow) <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709109}
  • Loading branch information
Anastasiia Nikolaienko authored and Commit Bot committed Oct 24, 2019
1 parent 6c71623 commit 98ec252
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 16 deletions.
2 changes: 1 addition & 1 deletion ash/home_screen/drag_window_from_shelf_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class DragWindowFromShelfController : public aura::WindowObserver {
gfx::Point initial_location_in_screen_;
gfx::Point previous_location_in_screen_;
bool drag_started_ = false;
BackdropWindowMode original_backdrop_mode_ = BackdropWindowMode::kAuto;
BackdropWindowMode original_backdrop_mode_ = BackdropWindowMode::kAutoOpaque;

// Hide all eligible windows during window dragging. Depends on different
// scenarios, we may or may not reshow there windows when drag ends.
Expand Down
2 changes: 1 addition & 1 deletion ash/public/cpp/window_properties.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(std::string, kAppIDKey, nullptr)
DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(std::string, kArcPackageNameKey, nullptr)
DEFINE_UI_CLASS_PROPERTY_KEY(BackdropWindowMode,
kBackdropWindowMode,
BackdropWindowMode::kAuto)
BackdropWindowMode::kAutoOpaque)
DEFINE_UI_CLASS_PROPERTY_KEY(bool, kBlockedForAssistantSnapshotKey, false)
DEFINE_UI_CLASS_PROPERTY_KEY(bool, kCanAttachToAnotherWindowKey, true)
DEFINE_UI_CLASS_PROPERTY_KEY(bool, kCanConsumeSystemKeysKey, false)
Expand Down
8 changes: 5 additions & 3 deletions ash/public/cpp/window_properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ enum class WindowPinType;
enum class WindowStateType;

enum class BackdropWindowMode {
kEnabled, // The window needs a backdrop shown behind it.
kDisabled, // The window should never have a backdrop.
kAuto, // The window manager decides if the window should have a backdrop.
kEnabled, // The window needs a backdrop shown behind it.
kDisabled, // The window should never have a backdrop.
kAutoOpaque, // The window manager decides if the window should have a fully
// opaque backdrop.
kAutoSemiOpaque, // The window needs a semi-opaque backdrop shown behind it.
};

// Shell-specific window property keys for use by ash and its clients.
Expand Down
4 changes: 2 additions & 2 deletions ash/wm/splitview/split_view_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2740,7 +2740,7 @@ TEST_P(SplitViewTabDraggingTest, NoBackDropDuringDragging) {
std::unique_ptr<aura::Window> window(
CreateWindowWithType(bounds, AppType::BROWSER));
EXPECT_EQ(window->GetProperty(kBackdropWindowMode),
BackdropWindowMode::kAuto);
BackdropWindowMode::kAutoOpaque);

std::unique_ptr<WindowResizer> resizer =
StartDrag(window.get(), window.get());
Expand All @@ -2754,7 +2754,7 @@ TEST_P(SplitViewTabDraggingTest, NoBackDropDuringDragging) {

resizer->CompleteDrag();
EXPECT_EQ(window->GetProperty(kBackdropWindowMode),
BackdropWindowMode::kAuto);
BackdropWindowMode::kAutoOpaque);
}

// Test that in tablet mode, the window that is in tab-dragging process should
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class TabletModeBrowserWindowDragDelegate::WindowsHider

// The original backdrop mode of the source window. Should be disabled during
// dragging.
BackdropWindowMode source_window_backdrop_ = BackdropWindowMode::kAuto;
BackdropWindowMode source_window_backdrop_ = BackdropWindowMode::kAutoOpaque;

DISALLOW_COPY_AND_ASSIGN(WindowsHider);
};
Expand Down
2 changes: 1 addition & 1 deletion ash/wm/tablet_mode/tablet_mode_window_drag_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class TabletModeWindowDragDelegate {
aura::Window* dragged_window_ = nullptr; // not owned.

// The backdrop should be disabled during dragging and resumed after dragging.
BackdropWindowMode original_backdrop_mode_ = BackdropWindowMode::kAuto;
BackdropWindowMode original_backdrop_mode_ = BackdropWindowMode::kAutoOpaque;

// The dragged window should have the active window shadow elevation during
// dragging.
Expand Down
26 changes: 21 additions & 5 deletions ash/wm/workspace/backdrop_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "ash/public/cpp/app_types.h"
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/public/cpp/window_animation_types.h"
#include "ash/public/cpp/window_properties.h"
#include "ash/screen_util.h"
#include "ash/shell.h"
#include "ash/wallpaper/wallpaper_controller_impl.h"
Expand All @@ -32,8 +31,21 @@
#include "ui/wm/core/window_util.h"

namespace ash {

namespace {

constexpr SkColor kSemiOpaqueBackdropColor =
SkColorSetARGB(0x99, 0x20, 0x21, 0x24);

SkColor GetBackdropColorByMode(BackdropWindowMode mode) {
if (mode == BackdropWindowMode::kAutoSemiOpaque)
return kSemiOpaqueBackdropColor;

DCHECK(mode == BackdropWindowMode::kAutoOpaque ||
mode == BackdropWindowMode::kEnabled);
return SK_ColorBLACK;
}

class BackdropEventHandler : public ui::EventHandler {
public:
BackdropEventHandler() = default;
Expand Down Expand Up @@ -275,7 +287,7 @@ void BackdropController::UpdateBackdropInternal() {
return;
}

EnsureBackdropWidget();
EnsureBackdropWidget(window->GetProperty(kBackdropWindowMode));
UpdateAccessibilityMode();

if (window == backdrop_window_ && backdrop_->IsVisible()) {
Expand All @@ -299,9 +311,13 @@ void BackdropController::UpdateBackdropInternal() {
container_->StackChildBelow(backdrop_window_, window);
}

void BackdropController::EnsureBackdropWidget() {
if (backdrop_)
void BackdropController::EnsureBackdropWidget(BackdropWindowMode mode) {
if (backdrop_) {
SkColor backdrop_color = GetBackdropColorByMode(mode);
if (backdrop_window_->layer()->GetTargetColor() != backdrop_color)
backdrop_window_->layer()->SetColor(backdrop_color);
return;
}

backdrop_ = std::make_unique<views::Widget>();
views::Widget::InitParams params(
Expand All @@ -321,7 +337,7 @@ void BackdropController::EnsureBackdropWidget() {
// The backdrop window in always on top container can be reparented without
// this when the window is set to fullscreen.
AlwaysOnTopController::SetDisallowReparent(backdrop_window_);
backdrop_window_->layer()->SetColor(SK_ColorBLACK);
backdrop_window_->layer()->SetColor(GetBackdropColorByMode(mode));

WindowState::Get(backdrop_window_)->set_allow_set_bounds_direct(true);
}
Expand Down
3 changes: 2 additions & 1 deletion ash/wm/workspace/backdrop_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "ash/ash_export.h"
#include "ash/public/cpp/tablet_mode_observer.h"
#include "ash/public/cpp/wallpaper_controller_observer.h"
#include "ash/public/cpp/window_properties.h"
#include "ash/wm/overview/overview_observer.h"
#include "ash/wm/splitview/split_view_controller.h"
#include "ash/wm/splitview/split_view_observer.h"
Expand Down Expand Up @@ -94,7 +95,7 @@ class ASH_EXPORT BackdropController : public AccessibilityObserver,

void UpdateBackdropInternal();

void EnsureBackdropWidget();
void EnsureBackdropWidget(BackdropWindowMode mode);

void UpdateAccessibilityMode();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <algorithm>
#include <string>

#include "ash/public/cpp/window_properties.h"
#include "base/logging.h"
#include "base/macros.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
Expand Down Expand Up @@ -66,6 +67,11 @@ void InlineLoginHandlerDialogChromeOS::Show(const std::string& email) {
// Will be deleted by |SystemWebDialogDelegate::OnDialogClosed|.
dialog = new InlineLoginHandlerDialogChromeOS(url);
dialog->ShowSystemDialog();

// TODO(crbug.com/1016828): Remove/update this after the dialog behavior on
// Chrome OS is defined.
dialog->dialog_window()->SetProperty(
ash::kBackdropWindowMode, ash::BackdropWindowMode::kAutoSemiOpaque);
}

void InlineLoginHandlerDialogChromeOS::AdjustWidgetInitParams(
Expand Down
2 changes: 1 addition & 1 deletion components/exo/client_controlled_shell_surface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ void ClientControlledShellSurface::UpdateBackdrop() {

ash::BackdropWindowMode target_backdrop_mode =
enable_backdrop ? ash::BackdropWindowMode::kEnabled
: ash::BackdropWindowMode::kAuto;
: ash::BackdropWindowMode::kAutoOpaque;

if (window->GetProperty(ash::kBackdropWindowMode) != target_backdrop_mode)
window->SetProperty(ash::kBackdropWindowMode, target_backdrop_mode);
Expand Down

0 comments on commit 98ec252

Please sign in to comment.