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

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

Issue 2818413003: Do not hide shadow underlay for max/fullscreen state even if the client disables the shadow. (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 if (!shadow_enabled_) { 1467
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) {
1468 wm::SetShadowElevation(window, wm::ShadowElevation::NONE); 1476 wm::SetShadowElevation(window, wm::ShadowElevation::NONE);
1469 if (shadow_underlay_) 1477 if (shadow_underlay_)
1470 shadow_underlay_->Hide(); 1478 shadow_underlay_->Hide();
1471 } else { 1479 } else {
1472 wm::SetShadowElevation(window, wm::ShadowElevation::MEDIUM); 1480 wm::SetShadowElevation(window, wm::ShadowElevation::MEDIUM);
1473 gfx::Rect shadow_content_bounds = 1481 gfx::Rect shadow_content_bounds =
1474 gfx::ScaleToEnclosedRect(shadow_content_bounds_, 1.f / scale_); 1482 gfx::ScaleToEnclosedRect(shadow_content_bounds_, 1.f / scale_);
1475 1483
1476 // Convert from screen to display coordinates. 1484 // Convert from screen to display coordinates.
1477 if (!shadow_content_bounds.IsEmpty()) { 1485 if (!shadow_content_bounds.IsEmpty()) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 DCHECK(shadow_underlay_->layer()->fills_bounds_opaquely()); 1533 DCHECK(shadow_underlay_->layer()->fills_bounds_opaquely());
1526 if (shadow_underlay_in_surface_) { 1534 if (shadow_underlay_in_surface_) {
1527 surface_->window()->AddChild(shadow_underlay_); 1535 surface_->window()->AddChild(shadow_underlay_);
1528 surface_->window()->StackChildAtBottom(shadow_underlay_); 1536 surface_->window()->StackChildAtBottom(shadow_underlay_);
1529 } else { 1537 } else {
1530 window->AddChild(shadow_underlay_); 1538 window->AddChild(shadow_underlay_);
1531 window->StackChildAtBottom(shadow_underlay_); 1539 window->StackChildAtBottom(shadow_underlay_);
1532 } 1540 }
1533 } 1541 }
1534 1542
1535 bool underlay_capture_events =
1536 WMHelper::GetInstance()->IsSpokenFeedbackEnabled() &&
1537 widget_->IsActive();
1538
1539 float shadow_underlay_opacity = shadow_background_opacity_; 1543 float shadow_underlay_opacity = shadow_background_opacity_;
1540 1544
1541 // Put the black background layer behind the window if 1545 // Put the black background layer behind the window if
1542 // 1) the window is in immersive fullscreen, maximized or is active with 1546 // 1) the window is in immersive fullscreen, maximized or is active with
1543 // spoken feedback enabled. 1547 // spoken feedback enabled.
1544 // 2) the window can control the bounds of the window in fullscreen ( 1548 // 2) the window can control the bounds of the window in fullscreen (
1545 // thus the background can be visible). 1549 // thus the background can be visible).
1546 // 3) the window has no transform (the transformed background may 1550 // 3) the window has no transform (the transformed background may
1547 // not cover the entire background, e.g. overview mode). 1551 // not cover the entire background, e.g. overview mode).
1548 if ((widget_->IsFullscreen() || widget_->IsMaximized() || 1552 if (black_background_enabled) {
1549 underlay_capture_events) &&
1550 ash::wm::GetWindowState(window)->allow_set_bounds_direct() &&
1551 window->layer()->GetTargetTransform().IsIdentity()) {
1552 if (shadow_underlay_in_surface_) { 1553 if (shadow_underlay_in_surface_) {
1553 shadow_underlay_bounds = gfx::Rect(surface_->window()->bounds().size()); 1554 shadow_underlay_bounds = gfx::Rect(surface_->window()->bounds().size());
1554 } else { 1555 } else {
1555 gfx::Point origin; 1556 gfx::Point origin;
1556 origin -= window->bounds().origin().OffsetFromOrigin(); 1557 origin -= window->bounds().origin().OffsetFromOrigin();
1557 shadow_bounds.set_origin(origin); 1558 shadow_bounds.set_origin(origin);
1558 shadow_bounds.set_size(window->parent()->bounds().size()); 1559 shadow_bounds.set_size(window->parent()->bounds().size());
1559 } 1560 }
1560 shadow_underlay_opacity = 1.0f; 1561 shadow_underlay_opacity = 1.0f;
1561 } 1562 }
1562 1563
1563 if (!shadow_underlay_in_surface_) 1564 if (!shadow_underlay_in_surface_)
1564 shadow_underlay_bounds = shadow_bounds; 1565 shadow_underlay_bounds = shadow_bounds;
1565 1566
1567 shadow_underlay_->SetBounds(shadow_underlay_bounds);
1568
1566 // Constrain the underlay bounds to the client area in case shell surface 1569 // Constrain the underlay bounds to the client area in case shell surface
1567 // frame is enabled. 1570 // frame is enabled.
1568 if (frame_enabled_) { 1571 if (frame_enabled_) {
1569 shadow_underlay_bounds.Intersect( 1572 shadow_underlay_bounds.Intersect(
1570 widget_->non_client_view()->frame_view()->GetBoundsForClientView()); 1573 widget_->non_client_view()->frame_view()->GetBoundsForClientView());
1571 } 1574 }
1572 1575
1573 shadow_underlay_->SetBounds(shadow_underlay_bounds);
1574
1575 // TODO(oshima): Setting to the same value should be no-op. 1576 // TODO(oshima): Setting to the same value should be no-op.
1576 // crbug.com/642223. 1577 // crbug.com/642223.
1577 if (shadow_underlay_opacity != 1578 if (shadow_underlay_opacity !=
1578 shadow_underlay_->layer()->GetTargetOpacity()) { 1579 shadow_underlay_->layer()->GetTargetOpacity()) {
1579 shadow_underlay_->layer()->SetOpacity(shadow_underlay_opacity); 1580 shadow_underlay_->layer()->SetOpacity(shadow_underlay_opacity);
1580 } 1581 }
1581
1582 shadow_underlay_->Show(); 1582 shadow_underlay_->Show();
1583 1583
1584 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window); 1584 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window);
1585 // Maximized/Fullscreen window does not create a shadow. 1585 // Maximized/Fullscreen window does not create a shadow.
1586 if (!shadow) 1586 if (!shadow)
1587 return; 1587 return;
1588 1588
1589 if (!shadow_overlay_) { 1589 if (!shadow_overlay_) {
1590 shadow_overlay_ = new aura::Window(nullptr); 1590 shadow_overlay_ = new aura::Window(nullptr);
1591 DCHECK(shadow_overlay_->owned_by_parent()); 1591 DCHECK(shadow_overlay_->owned_by_parent());
(...skipping 15 matching lines...) Expand all
1607 // small style shadow for them. 1607 // small style shadow for them.
1608 if (!activatable_) 1608 if (!activatable_)
1609 shadow->SetElevation(wm::ShadowElevation::SMALL); 1609 shadow->SetElevation(wm::ShadowElevation::SMALL);
1610 // We don't have rounded corners unless frame is enabled. 1610 // We don't have rounded corners unless frame is enabled.
1611 if (!frame_enabled_) 1611 if (!frame_enabled_)
1612 shadow->SetRoundedCornerRadius(0); 1612 shadow->SetRoundedCornerRadius(0);
1613 } 1613 }
1614 } 1614 }
1615 1615
1616 } // namespace exo 1616 } // 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