OLD | NEW |
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/frame/custom_frame_view_ash.h" | 9 #include "ash/frame/custom_frame_view_ash.h" |
10 #include "ash/public/cpp/shell_window_ids.h" | 10 #include "ash/public/cpp/shell_window_ids.h" |
(...skipping 1540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1551 | 1551 |
1552 surface_->window()->SetBounds( | 1552 surface_->window()->SetBounds( |
1553 gfx::Rect(GetSurfaceOrigin() + client_view_bounds.OffsetFromOrigin(), | 1553 gfx::Rect(GetSurfaceOrigin() + client_view_bounds.OffsetFromOrigin(), |
1554 surface_->window()->layer()->size())); | 1554 surface_->window()->layer()->size())); |
1555 } | 1555 } |
1556 | 1556 |
1557 void ShellSurface::UpdateShadow() { | 1557 void ShellSurface::UpdateShadow() { |
1558 if (!widget_ || !surface_) | 1558 if (!widget_ || !surface_) |
1559 return; | 1559 return; |
1560 aura::Window* window = widget_->GetNativeWindow(); | 1560 aura::Window* window = widget_->GetNativeWindow(); |
1561 | 1561 if (!shadow_enabled_) { |
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) { | |
1570 wm::SetShadowElevation(window, wm::ShadowElevation::NONE); | 1562 wm::SetShadowElevation(window, wm::ShadowElevation::NONE); |
1571 if (shadow_underlay_) | 1563 if (shadow_underlay_) |
1572 shadow_underlay_->Hide(); | 1564 shadow_underlay_->Hide(); |
1573 } else { | 1565 } else { |
1574 wm::SetShadowElevation(window, wm::ShadowElevation::MEDIUM); | 1566 wm::SetShadowElevation(window, wm::ShadowElevation::MEDIUM); |
1575 gfx::Rect shadow_content_bounds = | 1567 gfx::Rect shadow_content_bounds = |
1576 gfx::ScaleToEnclosedRect(shadow_content_bounds_, 1.f / scale_); | 1568 gfx::ScaleToEnclosedRect(shadow_content_bounds_, 1.f / scale_); |
1577 | 1569 |
1578 // Convert from screen to display coordinates. | 1570 // Convert from screen to display coordinates. |
1579 if (!shadow_content_bounds.IsEmpty()) { | 1571 if (!shadow_content_bounds.IsEmpty()) { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1627 DCHECK(shadow_underlay_->layer()->fills_bounds_opaquely()); | 1619 DCHECK(shadow_underlay_->layer()->fills_bounds_opaquely()); |
1628 if (shadow_underlay_in_surface_) { | 1620 if (shadow_underlay_in_surface_) { |
1629 surface_->window()->AddChild(shadow_underlay_); | 1621 surface_->window()->AddChild(shadow_underlay_); |
1630 surface_->window()->StackChildAtBottom(shadow_underlay_); | 1622 surface_->window()->StackChildAtBottom(shadow_underlay_); |
1631 } else { | 1623 } else { |
1632 window->AddChild(shadow_underlay_); | 1624 window->AddChild(shadow_underlay_); |
1633 window->StackChildAtBottom(shadow_underlay_); | 1625 window->StackChildAtBottom(shadow_underlay_); |
1634 } | 1626 } |
1635 } | 1627 } |
1636 | 1628 |
| 1629 bool underlay_capture_events = |
| 1630 WMHelper::GetInstance()->IsSpokenFeedbackEnabled() && |
| 1631 widget_->IsActive(); |
| 1632 |
1637 float shadow_underlay_opacity = shadow_background_opacity_; | 1633 float shadow_underlay_opacity = shadow_background_opacity_; |
1638 | 1634 |
1639 // Put the black background layer behind the window if | 1635 // Put the black background layer behind the window if |
1640 // 1) the window is in immersive fullscreen, maximized or is active with | 1636 // 1) the window is in immersive fullscreen, maximized or is active with |
1641 // spoken feedback enabled. | 1637 // spoken feedback enabled. |
1642 // 2) the window can control the bounds of the window in fullscreen ( | 1638 // 2) the window can control the bounds of the window in fullscreen ( |
1643 // thus the background can be visible). | 1639 // thus the background can be visible). |
1644 // 3) the window has no transform (the transformed background may | 1640 // 3) the window has no transform (the transformed background may |
1645 // not cover the entire background, e.g. overview mode). | 1641 // not cover the entire background, e.g. overview mode). |
1646 if (black_background_enabled) { | 1642 if ((widget_->IsFullscreen() || widget_->IsMaximized() || |
| 1643 underlay_capture_events) && |
| 1644 ash::wm::GetWindowState(window)->allow_set_bounds_direct() && |
| 1645 window->layer()->GetTargetTransform().IsIdentity()) { |
1647 if (shadow_underlay_in_surface_) { | 1646 if (shadow_underlay_in_surface_) { |
1648 shadow_underlay_bounds = gfx::Rect(surface_->window()->bounds().size()); | 1647 shadow_underlay_bounds = gfx::Rect(surface_->window()->bounds().size()); |
1649 } else { | 1648 } else { |
1650 gfx::Point origin; | 1649 gfx::Point origin; |
1651 origin -= window->bounds().origin().OffsetFromOrigin(); | 1650 origin -= window->bounds().origin().OffsetFromOrigin(); |
1652 shadow_bounds.set_origin(origin); | 1651 shadow_bounds.set_origin(origin); |
1653 shadow_bounds.set_size(window->parent()->bounds().size()); | 1652 shadow_bounds.set_size(window->parent()->bounds().size()); |
1654 } | 1653 } |
1655 shadow_underlay_opacity = 1.0f; | 1654 shadow_underlay_opacity = 1.0f; |
1656 } | 1655 } |
1657 | 1656 |
1658 if (!shadow_underlay_in_surface_) | 1657 if (!shadow_underlay_in_surface_) |
1659 shadow_underlay_bounds = shadow_bounds; | 1658 shadow_underlay_bounds = shadow_bounds; |
1660 | 1659 |
1661 shadow_underlay_->SetBounds(shadow_underlay_bounds); | |
1662 | |
1663 // Constrain the underlay bounds to the client area in case shell surface | 1660 // Constrain the underlay bounds to the client area in case shell surface |
1664 // frame is enabled. | 1661 // frame is enabled. |
1665 if (frame_enabled_) { | 1662 if (frame_enabled_) { |
1666 shadow_underlay_bounds.Intersect( | 1663 shadow_underlay_bounds.Intersect( |
1667 widget_->non_client_view()->frame_view()->GetBoundsForClientView()); | 1664 widget_->non_client_view()->frame_view()->GetBoundsForClientView()); |
1668 } | 1665 } |
1669 | 1666 |
| 1667 shadow_underlay_->SetBounds(shadow_underlay_bounds); |
| 1668 |
1670 shadow_underlay_->Show(); | 1669 shadow_underlay_->Show(); |
1671 | 1670 |
1672 // TODO(oshima): Setting to the same value should be no-op. | 1671 // TODO(oshima): Setting to the same value should be no-op. |
1673 // crbug.com/642223. | 1672 // crbug.com/642223. |
1674 if (shadow_underlay_opacity != | 1673 if (shadow_underlay_opacity != |
1675 shadow_underlay_->layer()->GetTargetOpacity()) { | 1674 shadow_underlay_->layer()->GetTargetOpacity()) { |
1676 shadow_underlay_->layer()->SetOpacity(shadow_underlay_opacity); | 1675 shadow_underlay_->layer()->SetOpacity(shadow_underlay_opacity); |
1677 } | 1676 } |
1678 | 1677 |
1679 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window); | 1678 wm::Shadow* shadow = wm::ShadowController::GetShadowForWindow(window); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1711 gfx::Point ShellSurface::GetMouseLocation() const { | 1710 gfx::Point ShellSurface::GetMouseLocation() const { |
1712 aura::Window* const root_window = widget_->GetNativeWindow()->GetRootWindow(); | 1711 aura::Window* const root_window = widget_->GetNativeWindow()->GetRootWindow(); |
1713 gfx::Point location = | 1712 gfx::Point location = |
1714 root_window->GetHost()->dispatcher()->GetLastMouseLocationInRoot(); | 1713 root_window->GetHost()->dispatcher()->GetLastMouseLocationInRoot(); |
1715 aura::Window::ConvertPointToTarget( | 1714 aura::Window::ConvertPointToTarget( |
1716 root_window, widget_->GetNativeWindow()->parent(), &location); | 1715 root_window, widget_->GetNativeWindow()->parent(), &location); |
1717 return location; | 1716 return location; |
1718 } | 1717 } |
1719 | 1718 |
1720 } // namespace exo | 1719 } // namespace exo |
OLD | NEW |