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

overview: Fix cannot snap label not stacked underneath snapped window.

This was because the label was previous parented to AlwaysOnTop
container. This was fine before when there was no scrolling, but now
with scrolling, the label should be parented to the same container
as the regular windows, so that it snapped window can be stacked
ontop of it as well.

Test: added test, manual
Bug: 1017882
Change-Id: I8b3d2d50f814e1b1c631372478d6ddd16bcc5608
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1880177Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709517}
parent 6203fdb2
...@@ -564,11 +564,12 @@ void OverviewItem::UpdateCannotSnapWarningVisibility() { ...@@ -564,11 +564,12 @@ void OverviewItem::UpdateCannotSnapWarningVisibility() {
params.rounding_dp = kSplitviewLabelRoundRectRadiusDp; params.rounding_dp = kSplitviewLabelRoundRectRadiusDp;
params.preferred_height = kSplitviewLabelPreferredHeightDp; params.preferred_height = kSplitviewLabelPreferredHeightDp;
params.message_id = IDS_ASH_SPLIT_VIEW_CANNOT_SNAP; params.message_id = IDS_ASH_SPLIT_VIEW_CANNOT_SNAP;
params.parent = params.parent = GetWindow()->parent();
root_window()->GetChildById(kShellWindowId_AlwaysOnTopContainer);
params.hide_in_mini_view = true; params.hide_in_mini_view = true;
cannot_snap_widget_ = std::make_unique<RoundedLabelWidget>(); cannot_snap_widget_ = std::make_unique<RoundedLabelWidget>();
cannot_snap_widget_->Init(std::move(params)); cannot_snap_widget_->Init(std::move(params));
GetWindow()->parent()->StackChildAbove(
cannot_snap_widget_->GetNativeWindow(), GetWindow());
} }
DoSplitviewOpacityAnimation(cannot_snap_widget_->GetNativeWindow()->layer(), DoSplitviewOpacityAnimation(cannot_snap_widget_->GetNativeWindow()->layer(),
...@@ -704,6 +705,12 @@ void OverviewItem::OnDragAnimationCompleted() { ...@@ -704,6 +705,12 @@ void OverviewItem::OnDragAnimationCompleted() {
break; break;
} }
} }
if (cannot_snap_widget_) {
DCHECK_EQ(parent_window, cannot_snap_widget_->GetNativeWindow()->parent());
parent_window->StackChildAbove(cannot_snap_widget_->GetNativeWindow(),
dragged_window);
}
} }
void OverviewItem::UpdatePhantomsForDragging(bool is_touch_dragging) { void OverviewItem::UpdatePhantomsForDragging(bool is_touch_dragging) {
......
...@@ -318,6 +318,15 @@ class OverviewSessionTest : public MultiDisplayOverviewAndSplitViewTest { ...@@ -318,6 +318,15 @@ class OverviewSessionTest : public MultiDisplayOverviewAndSplitViewTest {
} }
} }
// Creates a window which cannot be snapped by splitview.
std::unique_ptr<aura::Window> CreateUnsnappableWindow(
const gfx::Rect& bounds = gfx::Rect()) {
std::unique_ptr<aura::Window> window = CreateTestWindow(bounds);
window->SetProperty(aura::client::kResizeBehaviorKey,
aura::client::kResizeBehaviorNone);
return window;
}
static void StubForTest(ExitWarningHandler* ewh) { static void StubForTest(ExitWarningHandler* ewh) {
ewh->stub_timer_for_test_ = true; ewh->stub_timer_for_test_ = true;
} }
...@@ -3062,30 +3071,45 @@ TEST_P(OverviewSessionNewLayoutTest, CheckOverviewItemScrollingBounds) { ...@@ -3062,30 +3071,45 @@ TEST_P(OverviewSessionNewLayoutTest, CheckOverviewItemScrollingBounds) {
// while the new overivew layout is enabled. // while the new overivew layout is enabled.
TEST_P(OverviewSessionNewLayoutTest, StackingOrderSplitviewWindow) { TEST_P(OverviewSessionNewLayoutTest, StackingOrderSplitviewWindow) {
std::unique_ptr<aura::Window> window1 = CreateTestWindow(); std::unique_ptr<aura::Window> window1 = CreateTestWindow();
std::unique_ptr<aura::Window> window2 = CreateTestWindow(); std::unique_ptr<aura::Window> window2 = CreateUnsnappableWindow();
std::unique_ptr<aura::Window> window3 = CreateTestWindow();
ToggleOverview(); ToggleOverview();
ASSERT_TRUE(InOverviewSession()); ASSERT_TRUE(InOverviewSession());
// Snap |window1| to the left and exit overview. |window2| should have higher // Snap |window1| to the left and exit overview. |window3| should have higher
// z-order now, since it is the MRU window. // z-order now, since it is the MRU window.
split_view_controller()->SnapWindow(window1.get(), SplitViewController::LEFT); split_view_controller()->SnapWindow(window1.get(), SplitViewController::LEFT);
ToggleOverview(); ToggleOverview();
ASSERT_EQ(SplitViewController::State::kBothSnapped, ASSERT_EQ(SplitViewController::State::kBothSnapped,
split_view_controller()->state()); split_view_controller()->state());
ASSERT_GT(IndexOf(window2.get(), window2->parent()), ASSERT_GT(IndexOf(window3.get(), window3->parent()),
IndexOf(window1.get(), window1->parent())); IndexOf(window1.get(), window1->parent()));
// Test that on entering overview, |window2| is of a lower z-order, so that // Test that on entering overview, |window3| is of a lower z-order, so that
// when we scroll the grid, it will be seen under |window1|. // when we scroll the grid, it will be seen under |window1|.
ToggleOverview(); ToggleOverview();
EXPECT_LT(IndexOf(window3.get(), window3->parent()),
IndexOf(window1.get(), window1->parent()));
// Test that |window2| has a cannot snap widget indicating that it cannot be
// snapped, and that both |window2| and the widget are lower z-order than
// |window1|.
views::Widget* cannot_snap_widget =
static_cast<views::Widget*>(GetOverviewItemForWindow(window2.get())
->cannot_snap_widget_for_testing());
ASSERT_TRUE(cannot_snap_widget);
aura::Window* cannot_snap_window = cannot_snap_widget->GetNativeWindow();
ASSERT_EQ(window1->parent(), cannot_snap_window->parent());
EXPECT_LT(IndexOf(window2.get(), window2->parent()), EXPECT_LT(IndexOf(window2.get(), window2->parent()),
IndexOf(window1.get(), window1->parent())); IndexOf(window1.get(), window1->parent()));
EXPECT_LT(IndexOf(cannot_snap_window, cannot_snap_window->parent()),
IndexOf(window1.get(), window1->parent()));
// Test that on exiting overview, |window2| becomes activated, so it returns // Test that on exiting overview, |window3| becomes activated, so it returns
// to being higher on the z-order than |window1|. // to being higher on the z-order than |window1|.
ToggleOverview(); ToggleOverview();
EXPECT_GT(IndexOf(window2.get(), window2->parent()), EXPECT_GT(IndexOf(window3.get(), window3->parent()),
IndexOf(window1.get(), window1->parent())); IndexOf(window1.get(), window1->parent()));
} }
...@@ -3454,15 +3478,6 @@ class SplitViewOverviewSessionTest : public OverviewSessionTest { ...@@ -3454,15 +3478,6 @@ class SplitViewOverviewSessionTest : public OverviewSessionTest {
DragWindowTo(item, end_location, SelectorItemLocation::CENTER, true); DragWindowTo(item, end_location, SelectorItemLocation::CENTER, true);
} }
// Creates a window which cannot be snapped by splitview.
std::unique_ptr<aura::Window> CreateUnsnappableWindow(
const gfx::Rect& bounds = gfx::Rect()) {
std::unique_ptr<aura::Window> window = CreateTestWindow(bounds);
window->SetProperty(aura::client::kResizeBehaviorKey,
aura::client::kResizeBehaviorNone);
return window;
}
private: private:
class SplitViewTestWindowDelegate : public aura::test::TestWindowDelegate { class SplitViewTestWindowDelegate : public aura::test::TestWindowDelegate {
public: public:
......
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