Commit 952ab8c1 authored by Toni Barzic's avatar Toni Barzic Committed by Commit Bot

Keep hotseat shown after window drag from shelf to split view

When flinging a window in split view from shelf, the side of the split
view with the flinged window transitions to overview (though, split view
remains active). With existing logic, the hotseat was not getting marked
as extended for this gesture, which created a weird interaction with the
hotseat during window drag/fling from shelf. The hotseat would be
extended from the bottom of the shelf as pointer was moving up from the
shelf, then immediately hidden as the gesture ended. This CL changes the
logic to keep the hotseat in extended state when the gesture ends - the
hotseat is marked as manually extended, and logic that hid the hotseat
on visibility updates with split view with overview is removed.

Additionally, fixes an issue where window drag controller was not
exiting overview when drag window bounds were getting restored for
gestures from split view. Also, makes window activation changes while
dragged window bounds are being restored not mark hotseat as not
manually extended. These two were caught by a test added in this cl.

BUG=1025301

Change-Id: I494d1f924bdc6f88294cd0610b9dcc929fa0591f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2226066
Commit-Queue: Toni Baržić <tbarzic@chromium.org>
Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#775306}
parent 08d3d298
......@@ -311,8 +311,10 @@ bool DragWindowFromShelfController::IsDraggedWindowAnimating() const {
}
void DragWindowFromShelfController::FinalizeDraggedWindow() {
if (!window_drag_result_.has_value())
if (!window_drag_result_.has_value()) {
started_in_overview_ = false;
return;
}
DCHECK(!drag_started_);
DCHECK(window_);
......@@ -332,6 +334,7 @@ void DragWindowFromShelfController::FinalizeDraggedWindow() {
}
window_drag_result_.reset();
started_in_overview_ = false;
}
void DragWindowFromShelfController::OnWindowDestroying(aura::Window* window) {
......@@ -355,6 +358,8 @@ void DragWindowFromShelfController::RemoveObserver(
void DragWindowFromShelfController::OnDragStarted(
const gfx::PointF& location_in_screen) {
drag_started_ = true;
started_in_overview_ =
Shell::Get()->overview_controller()->InOverviewSession();
initial_location_in_screen_ = location_in_screen;
previous_location_in_screen_ = location_in_screen;
WindowState::Get(window_)->CreateDragDetails(
......@@ -658,17 +663,14 @@ void DragWindowFromShelfController::OnWindowScaledDownAfterDrag() {
}
void DragWindowFromShelfController::ScaleUpToRestoreWindowAfterDrag() {
const bool should_end_overview =
Shell::Get()->overview_controller()->InOverviewSession() &&
!SplitViewController::Get(Shell::GetPrimaryRootWindow())
->InSplitViewMode();
// Do the scale up transform for the entire transient tee.
for (auto* window : GetTransientTreeIterator(window_)) {
new WindowScaleAnimation(
window, WindowScaleAnimation::WindowScaleType::kScaleUpToRestore,
base::BindOnce(
&DragWindowFromShelfController::OnWindowRestoredToOrignalBounds,
weak_ptr_factory_.GetWeakPtr(), should_end_overview));
weak_ptr_factory_.GetWeakPtr(),
/*should_end_overview=*/!started_in_overview_));
}
}
......
......@@ -182,6 +182,9 @@ class ASH_EXPORT DragWindowFromShelfController : public aura::WindowObserver {
gfx::PointF previous_location_in_screen_;
bool drag_started_ = false;
// Whether overview was active when the drag started.
bool started_in_overview_ = false;
// Hide all eligible windows during window dragging. Depends on different
// scenarios, we may or may not reshow there windows when drag ends.
std::unique_ptr<WindowsHider> windows_hider_;
......
......@@ -477,7 +477,7 @@ TEST_F(DragWindowFromShelfControllerTest, DragOrFlingInSplitView) {
Drag(gfx::Point(100, 200), 0.f, 1.f);
EXPECT_TRUE(split_view_controller()->InSplitViewMode());
EXPECT_TRUE(overview_controller->InOverviewSession());
EndDrag(gfx::Point(100, 350),
EndDrag(gfx::Point(100, 150),
base::make_optional(
-DragWindowFromShelfController::kVelocityToOverviewThreshold));
EXPECT_TRUE(overview_controller->InOverviewSession());
......
......@@ -1082,8 +1082,11 @@ void ShelfLayoutManager::OnAppListVisibilityChanged(bool shown,
void ShelfLayoutManager::OnWindowActivated(ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) {
if (!IsShelfWindow(gained_active))
if (!IsShelfWindow(gained_active) &&
!(window_drag_controller_ &&
window_drag_controller_->during_window_restoration_callback())) {
shelf_->hotseat_widget()->set_manually_extended(/*value=*/false);
}
UpdateAutoHideStateNow();
}
......@@ -1370,10 +1373,7 @@ HotseatState ShelfLayoutManager::CalculateHotseatState(
if (shelf_->hotseat_widget()->IsShowingShelfMenu())
return HotseatState::kExtended;
if (in_split_view)
return HotseatState::kHidden;
if (in_overview)
if (in_overview && !in_split_view)
return HotseatState::kExtended;
if (state_forced_by_back_gesture_)
......@@ -2467,9 +2467,13 @@ void ShelfLayoutManager::CancelDrag(
shelf_->hotseat_widget()->set_manually_extended(
hotseat_state() == HotseatState::kExtended &&
(!Shell::Get()->overview_controller()->InOverviewSession() ||
SplitViewController::Get(shelf_widget_->GetNativeWindow())
->InSplitViewMode() ||
(window_drag_result.has_value() &&
window_drag_result.value() ==
ShelfWindowDragResult::kRestoreToOriginalBounds)));
(window_drag_result.value() ==
ShelfWindowDragResult::kRestoreToOriginalBounds ||
window_drag_result.value() ==
ShelfWindowDragResult::kGoToSplitviewMode))));
hotseat_presentation_time_recorder_.reset();
}
......
......@@ -3009,6 +3009,90 @@ TEST_F(ShelfLayoutManagerWindowDraggingTest, FlingHomeInSplitModeWithOverview) {
InAppShelfGestures::kSwipeUpToShow, 0);
}
// Tests that the hotseat ends up in manually extended state after swiping up
// a window in split screen to overview (the final state is a split screen with
// one side in overview).
TEST_F(ShelfLayoutManagerWindowDraggingTest, FlingInSplitView) {
const gfx::Rect shelf_widget_bounds =
GetShelfWidget()->GetWindowBoundsInScreen();
const int shelf_size = ShelfConfig::Get()->shelf_size();
const int hotseat_size = GetHotseatWidget()->GetHotseatSize();
const int hotseat_padding_size = ShelfConfig::Get()->hotseat_bottom_padding();
std::unique_ptr<aura::Window> window1 =
AshTestBase::CreateTestWindow(gfx::Rect(0, 0, 400, 400));
std::unique_ptr<aura::Window> window2 =
AshTestBase::CreateTestWindow(gfx::Rect(0, 0, 400, 400));
SplitViewController* split_view_controller =
SplitViewController::Get(Shell::GetPrimaryRootWindow());
split_view_controller->SnapWindow(window1.get(), SplitViewController::LEFT);
split_view_controller->SnapWindow(window2.get(), SplitViewController::RIGHT);
base::HistogramTester histogram_tester;
HotseatStateWatcher watcher(GetShelfLayoutManager());
// Longer fling, one that significantly exceeds the distance required to show
// the hotseat (by 2 hotseat heights).
StartScroll(shelf_widget_bounds.bottom_left());
UpdateScroll(-shelf_size - 3 * hotseat_size - hotseat_padding_size);
EndScroll(
true /* is_fling */,
-(DragWindowFromShelfController::kVelocityToHomeScreenThreshold + 10));
EXPECT_TRUE(Shell::Get()->overview_controller()->InOverviewSession());
EXPECT_TRUE(split_view_controller->InSplitViewMode());
watcher.CheckEqual({HotseatState::kExtended});
EXPECT_TRUE(GetPrimaryShelf()->hotseat_widget()->is_manually_extended());
histogram_tester.ExpectBucketCount(
kHotseatGestureHistogramName,
InAppShelfGestures::kFlingUpToShowHomeScreen, 0);
histogram_tester.ExpectBucketCount(kHotseatGestureHistogramName,
InAppShelfGestures::kSwipeUpToShow, 1);
}
// Tests that the hotseat ends up in manually extended state after swiping up
// hotseat when window drag from shelf in split view ends up restoring original
// window bounds.
TEST_F(ShelfLayoutManagerWindowDraggingTest, ShortFlingInSplitView) {
const gfx::Rect shelf_widget_bounds =
GetShelfWidget()->GetWindowBoundsInScreen();
const int shelf_size = ShelfConfig::Get()->shelf_size();
const int hotseat_size = GetHotseatWidget()->GetHotseatSize();
const int hotseat_padding_size = ShelfConfig::Get()->hotseat_bottom_padding();
std::unique_ptr<aura::Window> window1 =
AshTestBase::CreateTestWindow(gfx::Rect(0, 0, 400, 400));
std::unique_ptr<aura::Window> window2 =
AshTestBase::CreateTestWindow(gfx::Rect(0, 0, 400, 400));
SplitViewController* split_view_controller =
SplitViewController::Get(Shell::GetPrimaryRootWindow());
split_view_controller->SnapWindow(window1.get(), SplitViewController::LEFT);
split_view_controller->SnapWindow(window2.get(), SplitViewController::RIGHT);
base::HistogramTester histogram_tester;
HotseatStateWatcher watcher(GetShelfLayoutManager());
StartScroll(shelf_widget_bounds.bottom_left());
UpdateScroll(-shelf_size - 1.5f * hotseat_size - hotseat_padding_size);
EndScroll(
true /* is_fling */,
-(DragWindowFromShelfController::kVelocityToHomeScreenThreshold + 10));
EXPECT_FALSE(Shell::Get()->overview_controller()->InOverviewSession());
EXPECT_TRUE(split_view_controller->InSplitViewMode());
watcher.CheckEqual({HotseatState::kExtended});
EXPECT_TRUE(GetPrimaryShelf()->hotseat_widget()->is_manually_extended());
histogram_tester.ExpectBucketCount(
kHotseatGestureHistogramName,
InAppShelfGestures::kFlingUpToShowHomeScreen, 0);
histogram_tester.ExpectBucketCount(kHotseatGestureHistogramName,
InAppShelfGestures::kSwipeUpToShow, 1);
}
// Tests that hotseat transition animation is not delayed (i.e. that it happens
// as soon as shelf opaque background changes) when virtual keyboard is hidden,
// and the user swipes from shelf to home.
......
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