| Index: components/exo/shell_surface.cc
|
| diff --git a/components/exo/shell_surface.cc b/components/exo/shell_surface.cc
|
| index e0ba66d23d59b553c19c9ea867f84d3fdfea8c4c..ffa7d00d1871efd3253c2ce536d3e88c61f3c816 100644
|
| --- a/components/exo/shell_surface.cc
|
| +++ b/components/exo/shell_surface.cc
|
| @@ -627,7 +627,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;
|
| }
|
|
|
| @@ -635,7 +635,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();
|
| }
|
| @@ -644,7 +644,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();
|
| }
|
| @@ -876,8 +876,6 @@ void ShellSurface::WindowClosing() {
|
| EndDrag(true /* revert */);
|
| SetEnabled(false);
|
| widget_ = nullptr;
|
| - shadow_overlay_ = nullptr;
|
| - shadow_underlay_ = nullptr;
|
| }
|
|
|
| views::Widget* ShellSurface::GetWidget() {
|
| @@ -1568,8 +1566,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();
|
| @@ -1616,11 +1629,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
|
| @@ -1629,18 +1643,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
|
| @@ -1650,10 +1660,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 {
|
| @@ -1677,7 +1684,8 @@ void ShellSurface::UpdateShadow() {
|
|
|
| shadow_underlay_->SetBounds(shadow_underlay_bounds);
|
|
|
| - shadow_underlay_->Show();
|
| + if (!shadow_underlay_->IsVisible())
|
| + shadow_underlay_->Show();
|
|
|
| // TODO(oshima): Setting to the same value should be no-op.
|
| // crbug.com/642223.
|
| @@ -1692,17 +1700,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();
|
| }
|
|
|