Skip to content

Commit 4d5dad8

Browse files
committed
Do not hide shadow underlay for max/fullscreen state even if the client disables the shadow.
During the state transition, ARC preserves windows being deleted, however the main window is deleted (thus, window frame is empty) which disables the shadow. BUG=711514 TEST=covered by unit tests. manual. Instal & start "Clash Royal", then F4 to toggle fullscreen. Review-Url: https://codereview.chromium.org/2820493004 Cr-Commit-Position: refs/heads/master@{#464819} (cherry picked from commit ae72f92) Review-Url: https://codereview.chromium.org/2821963002 . Cr-Commit-Position: refs/branch-heads/3071@{#52} Cr-Branched-From: a106f0a-refs/heads/master@{#464641}
1 parent a74d022 commit 4d5dad8

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed

components/exo/shell_surface.cc

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,7 +1558,15 @@ void ShellSurface::UpdateShadow() {
15581558
if (!widget_ || !surface_)
15591559
return;
15601560
aura::Window* window = widget_->GetNativeWindow();
1561-
if (!shadow_enabled_) {
1561+
1562+
bool underlay_capture_events =
1563+
WMHelper::GetInstance()->IsSpokenFeedbackEnabled() && widget_->IsActive();
1564+
bool black_background_enabled =
1565+
((widget_->IsFullscreen() || widget_->IsMaximized()) ||
1566+
underlay_capture_events) &&
1567+
ash::wm::GetWindowState(window)->allow_set_bounds_direct() &&
1568+
window->layer()->GetTargetTransform().IsIdentity();
1569+
if (!shadow_enabled_ && !black_background_enabled) {
15621570
wm::SetShadowElevation(window, wm::ShadowElevation::NONE);
15631571
if (shadow_underlay_)
15641572
shadow_underlay_->Hide();
@@ -1626,10 +1634,6 @@ void ShellSurface::UpdateShadow() {
16261634
}
16271635
}
16281636

1629-
bool underlay_capture_events =
1630-
WMHelper::GetInstance()->IsSpokenFeedbackEnabled() &&
1631-
widget_->IsActive();
1632-
16331637
float shadow_underlay_opacity = shadow_background_opacity_;
16341638

16351639
// Put the black background layer behind the window if
@@ -1639,10 +1643,7 @@ void ShellSurface::UpdateShadow() {
16391643
// thus the background can be visible).
16401644
// 3) the window has no transform (the transformed background may
16411645
// not cover the entire background, e.g. overview mode).
1642-
if ((widget_->IsFullscreen() || widget_->IsMaximized() ||
1643-
underlay_capture_events) &&
1644-
ash::wm::GetWindowState(window)->allow_set_bounds_direct() &&
1645-
window->layer()->GetTargetTransform().IsIdentity()) {
1646+
if (black_background_enabled) {
16461647
if (shadow_underlay_in_surface_) {
16471648
shadow_underlay_bounds = gfx::Rect(surface_->window()->bounds().size());
16481649
} else {
@@ -1657,22 +1658,21 @@ void ShellSurface::UpdateShadow() {
16571658
if (!shadow_underlay_in_surface_)
16581659
shadow_underlay_bounds = shadow_bounds;
16591660

1661+
shadow_underlay_->SetBounds(shadow_underlay_bounds);
1662+
16601663
// Constrain the underlay bounds to the client area in case shell surface
16611664
// frame is enabled.
16621665
if (frame_enabled_) {
16631666
shadow_underlay_bounds.Intersect(
16641667
widget_->non_client_view()->frame_view()->GetBoundsForClientView());
16651668
}
16661669

1667-
shadow_underlay_->SetBounds(shadow_underlay_bounds);
1668-
16691670
// TODO(oshima): Setting to the same value should be no-op.
16701671
// crbug.com/642223.
16711672
if (shadow_underlay_opacity !=
16721673
shadow_underlay_->layer()->GetTargetOpacity()) {
16731674
shadow_underlay_->layer()->SetOpacity(shadow_underlay_opacity);
16741675
}
1675-
16761676
shadow_underlay_->Show();
16771677

16781678
wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window);

components/exo/shell_surface_unittest.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,20 @@ TEST_F(ShellSurfaceTest, ShadowStartMaximized) {
832832
ASSERT_TRUE(shell_surface->shadow_underlay());
833833
EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible());
834834

835+
shell_surface->SetRectangularSurfaceShadow(gfx::Rect(0, 0, 0, 0));
836+
// Underlay should be created even without shadow.
837+
ASSERT_TRUE(shell_surface->shadow_underlay());
838+
EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible());
839+
shell_surface->SetRectangularShadowEnabled(false);
840+
surface->Commit();
841+
// Underlay should be created even without shadow.
842+
ASSERT_TRUE(shell_surface->shadow_underlay());
843+
EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible());
844+
845+
shell_surface->SetRectangularShadowEnabled(true);
846+
shell_surface->SetRectangularSurfaceShadow(gfx::Rect(10, 10, 100, 100));
847+
surface->Commit();
848+
835849
// Restore the window and make sure the shadow is created, visible and
836850
// has the latest bounds.
837851
widget->Restore();

0 commit comments

Comments
 (0)