Skip to content

Commit

Permalink
Do not hide shadow underlay for max/fullscreen state even if the clie…
Browse files Browse the repository at this point in the history
…nt 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}
  • Loading branch information
mitoshima authored and Commit bot committed Apr 14, 2017
1 parent 5e01790 commit ae72f92
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
24 changes: 12 additions & 12 deletions components/exo/shell_surface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1558,7 +1558,15 @@ void ShellSurface::UpdateShadow() {
if (!widget_ || !surface_)
return;
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();
Expand Down Expand Up @@ -1626,10 +1634,6 @@ void ShellSurface::UpdateShadow() {
}
}

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
Expand All @@ -1639,10 +1643,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 {
Expand All @@ -1657,22 +1658,21 @@ void ShellSurface::UpdateShadow() {
if (!shadow_underlay_in_surface_)
shadow_underlay_bounds = shadow_bounds;

shadow_underlay_->SetBounds(shadow_underlay_bounds);

// Constrain the underlay bounds to the client area in case shell surface
// frame is enabled.
if (frame_enabled_) {
shadow_underlay_bounds.Intersect(
widget_->non_client_view()->frame_view()->GetBoundsForClientView());
}

shadow_underlay_->SetBounds(shadow_underlay_bounds);

// 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);
Expand Down
14 changes: 14 additions & 0 deletions components/exo/shell_surface_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,20 @@ TEST_F(ShellSurfaceTest, ShadowStartMaximized) {
ASSERT_TRUE(shell_surface->shadow_underlay());
EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible());

shell_surface->SetRectangularSurfaceShadow(gfx::Rect(0, 0, 0, 0));
// Underlay should be created even without shadow.
ASSERT_TRUE(shell_surface->shadow_underlay());
EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible());
shell_surface->SetRectangularShadowEnabled(false);
surface->Commit();
// Underlay should be created even without shadow.
ASSERT_TRUE(shell_surface->shadow_underlay());
EXPECT_TRUE(shell_surface->shadow_underlay()->IsVisible());

shell_surface->SetRectangularShadowEnabled(true);
shell_surface->SetRectangularSurfaceShadow(gfx::Rect(10, 10, 100, 100));
surface->Commit();

// Restore the window and make sure the shadow is created, visible and
// has the latest bounds.
widget->Restore();
Expand Down

0 comments on commit ae72f92

Please sign in to comment.