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