Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: components/exo/shell_surface.cc

Issue 2836433002: Revert of Do not hide shadow underlay for max/fullscreen state even if the client disables the shad… (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | components/exo/shell_surface_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/exo/shell_surface.h" 5 #include "components/exo/shell_surface.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/common/frame/custom_frame_view_ash.h" 9 #include "ash/common/frame/custom_frame_view_ash.h"
10 #include "ash/common/shelf/wm_shelf.h" 10 #include "ash/common/shelf/wm_shelf.h"
(...skipping 1446 matching lines...) Expand 10 before | Expand all | Expand 10 after
1457 1457
1458 surface_->window()->SetBounds( 1458 surface_->window()->SetBounds(
1459 gfx::Rect(GetSurfaceOrigin() + client_view_bounds.OffsetFromOrigin(), 1459 gfx::Rect(GetSurfaceOrigin() + client_view_bounds.OffsetFromOrigin(),
1460 surface_->window()->layer()->size())); 1460 surface_->window()->layer()->size()));
1461 } 1461 }
1462 1462
1463 void ShellSurface::UpdateShadow() { 1463 void ShellSurface::UpdateShadow() {
1464 if (!widget_ || !surface_) 1464 if (!widget_ || !surface_)
1465 return; 1465 return;
1466 aura::Window* window = widget_->GetNativeWindow(); 1466 aura::Window* window = widget_->GetNativeWindow();
1467 1467 if (!shadow_enabled_) {
1468 bool underlay_capture_events =
1469 WMHelper::GetInstance()->IsSpokenFeedbackEnabled() && widget_->IsActive();
1470 bool black_background_enabled =
1471 ((widget_->IsFullscreen() || widget_->IsMaximized()) ||
1472 underlay_capture_events) &&
1473 ash::wm::GetWindowState(window)->allow_set_bounds_direct() &&
1474 window->layer()->GetTargetTransform().IsIdentity();
1475 if (!shadow_enabled_ && !black_background_enabled) {
1476 wm::SetShadowElevation(window, wm::ShadowElevation::NONE); 1468 wm::SetShadowElevation(window, wm::ShadowElevation::NONE);
1477 if (shadow_underlay_) 1469 if (shadow_underlay_)
1478 shadow_underlay_->Hide(); 1470 shadow_underlay_->Hide();
1479 } else { 1471 } else {
1480 wm::SetShadowElevation(window, wm::ShadowElevation::MEDIUM); 1472 wm::SetShadowElevation(window, wm::ShadowElevation::MEDIUM);
1481 gfx::Rect shadow_content_bounds = 1473 gfx::Rect shadow_content_bounds =
1482 gfx::ScaleToEnclosedRect(shadow_content_bounds_, 1.f / scale_); 1474 gfx::ScaleToEnclosedRect(shadow_content_bounds_, 1.f / scale_);
1483 1475
1484 // Convert from screen to display coordinates. 1476 // Convert from screen to display coordinates.
1485 if (!shadow_content_bounds.IsEmpty()) { 1477 if (!shadow_content_bounds.IsEmpty()) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1533 DCHECK(shadow_underlay_->layer()->fills_bounds_opaquely()); 1525 DCHECK(shadow_underlay_->layer()->fills_bounds_opaquely());
1534 if (shadow_underlay_in_surface_) { 1526 if (shadow_underlay_in_surface_) {
1535 surface_->window()->AddChild(shadow_underlay_); 1527 surface_->window()->AddChild(shadow_underlay_);
1536 surface_->window()->StackChildAtBottom(shadow_underlay_); 1528 surface_->window()->StackChildAtBottom(shadow_underlay_);
1537 } else { 1529 } else {
1538 window->AddChild(shadow_underlay_); 1530 window->AddChild(shadow_underlay_);
1539 window->StackChildAtBottom(shadow_underlay_); 1531 window->StackChildAtBottom(shadow_underlay_);
1540 } 1532 }
1541 } 1533 }
1542 1534
1535 bool underlay_capture_events =
1536 WMHelper::GetInstance()->IsSpokenFeedbackEnabled() &&
1537 widget_->IsActive();
1538
1543 float shadow_underlay_opacity = shadow_background_opacity_; 1539 float shadow_underlay_opacity = shadow_background_opacity_;
1544 1540
1545 // Put the black background layer behind the window if 1541 // Put the black background layer behind the window if
1546 // 1) the window is in immersive fullscreen, maximized or is active with 1542 // 1) the window is in immersive fullscreen, maximized or is active with
1547 // spoken feedback enabled. 1543 // spoken feedback enabled.
1548 // 2) the window can control the bounds of the window in fullscreen ( 1544 // 2) the window can control the bounds of the window in fullscreen (
1549 // thus the background can be visible). 1545 // thus the background can be visible).
1550 // 3) the window has no transform (the transformed background may 1546 // 3) the window has no transform (the transformed background may
1551 // not cover the entire background, e.g. overview mode). 1547 // not cover the entire background, e.g. overview mode).
1552 if (black_background_enabled) { 1548 if ((widget_->IsFullscreen() || widget_->IsMaximized() ||
1549 underlay_capture_events) &&
1550 ash::wm::GetWindowState(window)->allow_set_bounds_direct() &&
1551 window->layer()->GetTargetTransform().IsIdentity()) {
1553 if (shadow_underlay_in_surface_) { 1552 if (shadow_underlay_in_surface_) {
1554 shadow_underlay_bounds = gfx::Rect(surface_->window()->bounds().size()); 1553 shadow_underlay_bounds = gfx::Rect(surface_->window()->bounds().size());
1555 } else { 1554 } else {
1556 gfx::Point origin; 1555 gfx::Point origin;
1557 origin -= window->bounds().origin().OffsetFromOrigin(); 1556 origin -= window->bounds().origin().OffsetFromOrigin();
1558 shadow_bounds.set_origin(origin); 1557 shadow_bounds.set_origin(origin);
1559 shadow_bounds.set_size(window->parent()->bounds().size()); 1558 shadow_bounds.set_size(window->parent()->bounds().size());
1560 } 1559 }
1561 shadow_underlay_opacity = 1.0f; 1560 shadow_underlay_opacity = 1.0f;
1562 } 1561 }
1563 1562
1564 if (!shadow_underlay_in_surface_) 1563 if (!shadow_underlay_in_surface_)
1565 shadow_underlay_bounds = shadow_bounds; 1564 shadow_underlay_bounds = shadow_bounds;
1566 1565
1567 shadow_underlay_->SetBounds(shadow_underlay_bounds);
1568
1569 // Constrain the underlay bounds to the client area in case shell surface 1566 // Constrain the underlay bounds to the client area in case shell surface
1570 // frame is enabled. 1567 // frame is enabled.
1571 if (frame_enabled_) { 1568 if (frame_enabled_) {
1572 shadow_underlay_bounds.Intersect( 1569 shadow_underlay_bounds.Intersect(
1573 widget_->non_client_view()->frame_view()->GetBoundsForClientView()); 1570 widget_->non_client_view()->frame_view()->GetBoundsForClientView());
1574 } 1571 }
1575 1572
1573 shadow_underlay_->SetBounds(shadow_underlay_bounds);
1574
1576 // TODO(oshima): Setting to the same value should be no-op. 1575 // TODO(oshima): Setting to the same value should be no-op.
1577 // crbug.com/642223. 1576 // crbug.com/642223.
1578 if (shadow_underlay_opacity != 1577 if (shadow_underlay_opacity !=
1579 shadow_underlay_->layer()->GetTargetOpacity()) { 1578 shadow_underlay_->layer()->GetTargetOpacity()) {
1580 shadow_underlay_->layer()->SetOpacity(shadow_underlay_opacity); 1579 shadow_underlay_->layer()->SetOpacity(shadow_underlay_opacity);
1581 } 1580 }
1582 shadow_underlay_->Show(); 1581 shadow_underlay_->Show();
1583 1582
1584 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window); 1583 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window);
1585 // Maximized/Fullscreen window does not create a shadow. 1584 // Maximized/Fullscreen window does not create a shadow.
(...skipping 21 matching lines...) Expand all
1607 // small style shadow for them. 1606 // small style shadow for them.
1608 if (!activatable_) 1607 if (!activatable_)
1609 shadow->SetElevation(wm::ShadowElevation::SMALL); 1608 shadow->SetElevation(wm::ShadowElevation::SMALL);
1610 // We don't have rounded corners unless frame is enabled. 1609 // We don't have rounded corners unless frame is enabled.
1611 if (!frame_enabled_) 1610 if (!frame_enabled_)
1612 shadow->SetRoundedCornerRadius(0); 1611 shadow->SetRoundedCornerRadius(0);
1613 } 1612 }
1614 } 1613 }
1615 1614
1616 } // namespace exo 1615 } // namespace exo
OLDNEW
« no previous file with comments | « no previous file | components/exo/shell_surface_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698