Commit d3750ec1 authored by Sammie Quon's avatar Sammie Quon Committed by Commit Bot

overview: Apply rounded edges to non-animated windows.

Animations into overview has changed so that non visible windows do not
need to animation. Previous rounded edges code relied on animation end to
apply mask, this cl applies mask to all cases, and removes before animations,
and reapplies after animation.

Test: ash_unittests WindowSelectorTest.RoundedEdgeMaskVisibility
Bug: 817860
Change-Id: I9da0e2a56e991a7c3073a4c2c0de79d8e3799915
Reviewed-on: https://chromium-review.googlesource.com/953135Reviewed-by: default avatarTao Wu <wutao@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#541690}
parent 104c81f5
...@@ -223,6 +223,7 @@ void ScopedTransformOverviewWindow::BeginScopedAnimation( ...@@ -223,6 +223,7 @@ void ScopedTransformOverviewWindow::BeginScopedAnimation(
window_->layer()->SetMaskLayer(original_mask_layer_); window_->layer()->SetMaskLayer(original_mask_layer_);
} }
} }
for (auto* window : wm::GetTransientTreeIterator(GetOverviewWindow())) { for (auto* window : wm::GetTransientTreeIterator(GetOverviewWindow())) {
auto settings = std::make_unique<ScopedOverviewAnimationSettings>( auto settings = std::make_unique<ScopedOverviewAnimationSettings>(
animation_type, window); animation_type, window);
...@@ -507,6 +508,11 @@ void ScopedTransformOverviewWindow::PrepareForOverview() { ...@@ -507,6 +508,11 @@ void ScopedTransformOverviewWindow::PrepareForOverview() {
std::make_unique<LayerCachingAndFilteringObserver>(window->layer())); std::make_unique<LayerCachingAndFilteringObserver>(window->layer()));
} }
} }
// Apply rounded edge mask. Windows which are animated into overview mode
// will have their mask removed before the animation begins and reapplied
// after the animation ends.
CreateAndApplyMaskAndShadow();
} }
void ScopedTransformOverviewWindow::CloseWidget() { void ScopedTransformOverviewWindow::CloseWidget() {
...@@ -548,22 +554,8 @@ void ScopedTransformOverviewWindow::CancelAnimationsListener() { ...@@ -548,22 +554,8 @@ void ScopedTransformOverviewWindow::CancelAnimationsListener() {
} }
void ScopedTransformOverviewWindow::OnImplicitAnimationsCompleted() { void ScopedTransformOverviewWindow::OnImplicitAnimationsCompleted() {
// Add the mask which gives the window selector items rounded corners, and add
// the shadow around the window.
DCHECK(IsNewOverviewUi()); DCHECK(IsNewOverviewUi());
CreateAndApplyMaskAndShadow();
ui::Layer* layer = minimized_widget_
? minimized_widget_->GetContentsView()->layer()
: window_->layer();
if (!minimized_widget_)
original_mask_layer_ = window_->layer()->layer_mask_layer();
mask_ = std::make_unique<WindowMask>(GetOverviewWindow());
mask_->layer()->SetBounds(layer->bounds());
mask_->set_top_inset(GetTopInset());
layer->SetMaskLayer(mask_->layer());
selector_item_->SetShadowBounds(base::make_optional(GetTransformedBounds()));
selector_item_->EnableBackdropIfNeeded();
} }
void ScopedTransformOverviewWindow::CreateMirrorWindowForMinimizedState() { void ScopedTransformOverviewWindow::CreateMirrorWindowForMinimizedState() {
...@@ -597,4 +589,25 @@ void ScopedTransformOverviewWindow::CreateMirrorWindowForMinimizedState() { ...@@ -597,4 +589,25 @@ void ScopedTransformOverviewWindow::CreateMirrorWindowForMinimizedState() {
minimized_widget_->Show(); minimized_widget_->Show();
} }
void ScopedTransformOverviewWindow::CreateAndApplyMaskAndShadow() {
// Add the mask which gives the window selector items rounded corners, and add
// the shadow around the window.
if (!IsNewOverviewUi())
return;
ui::Layer* layer = minimized_widget_
? minimized_widget_->GetContentsView()->layer()
: window_->layer();
if (!minimized_widget_)
original_mask_layer_ = window_->layer()->layer_mask_layer();
mask_ = std::make_unique<WindowMask>(GetOverviewWindow());
mask_->layer()->SetBounds(layer->bounds());
mask_->set_top_inset(GetTopInset());
layer->SetMaskLayer(mask_->layer());
selector_item_->SetShadowBounds(base::make_optional(GetTransformedBounds()));
selector_item_->EnableBackdropIfNeeded();
}
} // namespace ash } // namespace ash
...@@ -195,6 +195,10 @@ class ASH_EXPORT ScopedTransformOverviewWindow ...@@ -195,6 +195,10 @@ class ASH_EXPORT ScopedTransformOverviewWindow
void CreateMirrorWindowForMinimizedState(); void CreateMirrorWindowForMinimizedState();
// Creates and applys a mask which adds rounded edges to windows in overview
// mode.
void CreateAndApplyMaskAndShadow();
// Makes Close() execute synchronously when used in tests. // Makes Close() execute synchronously when used in tests.
static void SetImmediateCloseForTests(); static void SetImmediateCloseForTests();
......
...@@ -382,6 +382,10 @@ class WindowSelectorTest : public AshTestBase { ...@@ -382,6 +382,10 @@ class WindowSelectorTest : public AshTestBase {
return item->backdrop_widget_.get(); return item->backdrop_widget_.get();
} }
bool HasMaskForItem(WindowSelectorItem* item) const {
return !!item->transform_window_.mask_;
}
private: private:
aura::test::TestWindowDelegate delegate_; aura::test::TestWindowDelegate delegate_;
NonActivatableActivationDelegate non_activatable_activation_delegate_; NonActivatableActivationDelegate non_activatable_activation_delegate_;
...@@ -2717,6 +2721,50 @@ TEST_F(WindowSelectorTest, Backdrop) { ...@@ -2717,6 +2721,50 @@ TEST_F(WindowSelectorTest, Backdrop) {
ToggleOverview(); ToggleOverview();
} }
// Verify that the mask that is applied to add rounded corners in overview mode
// is removed during animations and drags.
TEST_F(WindowSelectorTest, RoundedEdgeMaskVisibility) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kAshEnableNewOverviewUi);
UpdateDisplay("400x400");
const gfx::Rect bounds(0, 0, 200, 200);
std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
std::unique_ptr<aura::Window> window2(CreateWindow(bounds));
wm::ActivateWindow(window2.get());
wm::ActivateWindow(window1.get());
// Dragging is only allowed in tablet mode.
RunAllPendingInMessageLoop();
Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true);
ToggleOverview();
RunAllPendingInMessageLoop();
WindowSelectorItem* item1 = GetWindowItemForWindow(0, window1.get());
WindowSelectorItem* item2 = GetWindowItemForWindow(0, window2.get());
EXPECT_TRUE(HasMaskForItem(item1));
EXPECT_TRUE(HasMaskForItem(item2));
// Drag the first window. Verify that the mask disappears.
const gfx::Point start_drag = item1->target_bounds().CenterPoint();
GetEventGenerator().MoveMouseTo(start_drag);
GetEventGenerator().PressLeftButton();
EXPECT_FALSE(HasMaskForItem(item1));
EXPECT_TRUE(HasMaskForItem(item2));
// Drag to origin and then back to the start to avoid activating the window or
// entering splitview. Verify that the mask is visible on both items.
GetEventGenerator().MoveMouseTo(gfx::Point());
GetEventGenerator().MoveMouseTo(start_drag);
GetEventGenerator().ReleaseLeftButton();
EXPECT_TRUE(HasMaskForItem(item1));
EXPECT_TRUE(HasMaskForItem(item2));
// Test that leaving overview mode cleans up properly.
ToggleOverview();
}
// Verify that the system does not crash when exiting overview mode after // Verify that the system does not crash when exiting overview mode after
// pressing CTRL+SHIFT+U. // pressing CTRL+SHIFT+U.
TEST_F(WindowSelectorTest, ExitInUnderlineMode) { TEST_F(WindowSelectorTest, ExitInUnderlineMode) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment