| Index: components/exo/shell_surface.cc
|
| diff --git a/components/exo/shell_surface.cc b/components/exo/shell_surface.cc
|
| index 6fb1e63e25cfde7d102b672b2bff73b84112d983..57460ab96544ec622870c9679739a458ef5dcbef 100644
|
| --- a/components/exo/shell_surface.cc
|
| +++ b/components/exo/shell_surface.cc
|
| @@ -596,7 +596,7 @@ void ShellSurface::SetGeometry(const gfx::Rect& geometry) {
|
| void ShellSurface::SetRectangularShadowEnabled(bool enabled) {
|
| TRACE_EVENT1("exo", "ShellSurface::SetRectangularShadowEnabled", "enabled",
|
| enabled);
|
| - shadow_underlay_in_surface_ = false;
|
| + pending_shadow_underlay_in_surface_ = false;
|
| shadow_enabled_ = enabled;
|
| }
|
|
|
| @@ -604,7 +604,7 @@ void ShellSurface::SetRectangularShadow_DEPRECATED(
|
| const gfx::Rect& content_bounds) {
|
| TRACE_EVENT1("exo", "ShellSurface::SetRectangularShadow_DEPRECATED",
|
| "content_bounds", content_bounds.ToString());
|
| - shadow_underlay_in_surface_ = false;
|
| + pending_shadow_underlay_in_surface_ = false;
|
| shadow_content_bounds_ = content_bounds;
|
| shadow_enabled_ = !content_bounds.IsEmpty();
|
| }
|
| @@ -613,7 +613,7 @@ void ShellSurface::SetRectangularSurfaceShadow(
|
| const gfx::Rect& content_bounds) {
|
| TRACE_EVENT1("exo", "ShellSurface::SetRectangularSurfaceShadow",
|
| "content_bounds", content_bounds.ToString());
|
| - shadow_underlay_in_surface_ = true;
|
| + pending_shadow_underlay_in_surface_ = true;
|
| shadow_content_bounds_ = content_bounds;
|
| shadow_enabled_ = !content_bounds.IsEmpty();
|
| }
|
| @@ -867,8 +867,6 @@ void ShellSurface::WindowClosing() {
|
| EndDrag(true /* revert */);
|
| SetEnabled(false);
|
| widget_ = nullptr;
|
| - shadow_overlay_ = nullptr;
|
| - shadow_underlay_ = nullptr;
|
| }
|
|
|
| views::Widget* ShellSurface::GetWidget() {
|
| @@ -1463,8 +1461,23 @@ void ShellSurface::UpdateSurfaceBounds() {
|
| void ShellSurface::UpdateShadow() {
|
| if (!widget_ || !surface_)
|
| return;
|
| + if (shadow_underlay_in_surface_ != pending_shadow_underlay_in_surface_) {
|
| + shadow_underlay_in_surface_ = pending_shadow_underlay_in_surface_;
|
| + shadow_overlay_.reset();
|
| + shadow_underlay_.reset();
|
| + }
|
| +
|
| aura::Window* window = widget_->GetNativeWindow();
|
| - if (!shadow_enabled_) {
|
| +
|
| + bool underlay_capture_events =
|
| + WMHelper::GetInstance()->IsSpokenFeedbackEnabled() && widget_->IsActive();
|
| + bool black_background_enabled =
|
| + ((widget_->IsFullscreen() || widget_->IsMaximized()) ||
|
| + underlay_capture_events) &&
|
| + ash::wm::GetWindowState(window)->allow_set_bounds_direct() &&
|
| + window->layer()->GetTargetTransform().IsIdentity();
|
| +
|
| + if (!shadow_enabled_ && !black_background_enabled) {
|
| wm::SetShadowElevation(window, wm::ShadowElevation::NONE);
|
| if (shadow_underlay_)
|
| shadow_underlay_->Hide();
|
| @@ -1511,11 +1524,12 @@ void ShellSurface::UpdateShadow() {
|
|
|
| // Always create and show the underlay, even in maximized/fullscreen.
|
| if (!shadow_underlay_) {
|
| - shadow_underlay_ = new aura::Window(nullptr);
|
| + shadow_underlay_ = base::MakeUnique<aura::Window>(nullptr);
|
| + shadow_underlay_->set_owned_by_parent(false);
|
| shadow_underlay_event_handler_ =
|
| base::MakeUnique<ShadowUnderlayEventHandler>();
|
| shadow_underlay_->SetTargetHandler(shadow_underlay_event_handler_.get());
|
| - DCHECK(shadow_underlay_->owned_by_parent());
|
| + DCHECK(!shadow_underlay_->owned_by_parent());
|
| // Ensure the background area inside the shadow is solid black.
|
| // Clients that provide translucent contents should not be using
|
| // rectangular shadows as this method requires opaque contents to
|
| @@ -1524,18 +1538,14 @@ void ShellSurface::UpdateShadow() {
|
| shadow_underlay_->layer()->SetColor(SK_ColorBLACK);
|
| DCHECK(shadow_underlay_->layer()->fills_bounds_opaquely());
|
| if (shadow_underlay_in_surface_) {
|
| - surface_->window()->AddChild(shadow_underlay_);
|
| - surface_->window()->StackChildAtBottom(shadow_underlay_);
|
| + surface_->window()->AddChild(shadow_underlay());
|
| + surface_->window()->StackChildAtBottom(shadow_underlay());
|
| } else {
|
| - window->AddChild(shadow_underlay_);
|
| - window->StackChildAtBottom(shadow_underlay_);
|
| + window->AddChild(shadow_underlay());
|
| + window->StackChildAtBottom(shadow_underlay());
|
| }
|
| }
|
|
|
| - bool underlay_capture_events =
|
| - WMHelper::GetInstance()->IsSpokenFeedbackEnabled() &&
|
| - widget_->IsActive();
|
| -
|
| float shadow_underlay_opacity = shadow_background_opacity_;
|
|
|
| // Put the black background layer behind the window if
|
| @@ -1545,10 +1555,7 @@ void ShellSurface::UpdateShadow() {
|
| // thus the background can be visible).
|
| // 3) the window has no transform (the transformed background may
|
| // not cover the entire background, e.g. overview mode).
|
| - if ((widget_->IsFullscreen() || widget_->IsMaximized() ||
|
| - underlay_capture_events) &&
|
| - ash::wm::GetWindowState(window)->allow_set_bounds_direct() &&
|
| - window->layer()->GetTargetTransform().IsIdentity()) {
|
| + if (black_background_enabled) {
|
| if (shadow_underlay_in_surface_) {
|
| shadow_underlay_bounds = gfx::Rect(surface_->window()->bounds().size());
|
| } else {
|
| @@ -1572,13 +1579,15 @@ void ShellSurface::UpdateShadow() {
|
|
|
| shadow_underlay_->SetBounds(shadow_underlay_bounds);
|
|
|
| + if (!shadow_underlay_->IsVisible())
|
| + shadow_underlay_->Show();
|
| +
|
| // TODO(oshima): Setting to the same value should be no-op.
|
| // crbug.com/642223.
|
| if (shadow_underlay_opacity !=
|
| shadow_underlay_->layer()->GetTargetOpacity()) {
|
| shadow_underlay_->layer()->SetOpacity(shadow_underlay_opacity);
|
| }
|
| - shadow_underlay_->Show();
|
|
|
| wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window);
|
| // Maximized/Fullscreen window does not create a shadow.
|
| @@ -1586,17 +1595,18 @@ void ShellSurface::UpdateShadow() {
|
| return;
|
|
|
| if (!shadow_overlay_) {
|
| - shadow_overlay_ = new aura::Window(nullptr);
|
| - DCHECK(shadow_overlay_->owned_by_parent());
|
| + shadow_overlay_ = base::MakeUnique<aura::Window>(nullptr);
|
| + shadow_overlay_->set_owned_by_parent(false);
|
| + DCHECK(!shadow_overlay_->owned_by_parent());
|
| shadow_overlay_->set_ignore_events(true);
|
| shadow_overlay_->Init(ui::LAYER_NOT_DRAWN);
|
| shadow_overlay_->layer()->Add(shadow->layer());
|
| - window->AddChild(shadow_overlay_);
|
| + window->AddChild(shadow_overlay());
|
|
|
| if (shadow_underlay_in_surface_) {
|
| - window->StackChildBelow(shadow_overlay_, surface_->window());
|
| + window->StackChildBelow(shadow_overlay(), surface_->window());
|
| } else {
|
| - window->StackChildAbove(shadow_overlay_, shadow_underlay_);
|
| + window->StackChildAbove(shadow_overlay(), shadow_underlay());
|
| }
|
| shadow_overlay_->Show();
|
| }
|
|
|