Commit f682e887 authored by Xiaoqian Dai's avatar Xiaoqian Dai Committed by Commit Bot

Tab dragging: do not cancel split when moving toward the top of the screen.

After drag starts, the window needs to be dragged vertically a small
amount of distance to be considered as 'moved' and only after that, the
drag indicators will show up and the window can be snapped. But after
the window has been 'moved', it should stay moved even the window is
dragged toward to the top of the screen.

Bug: 873275
Change-Id: I4546a3a6839427c7232dcc5b6f234913b9dd516d
Reviewed-on: https://chromium-review.googlesource.com/1173472
Commit-Queue: Xiaoqian Dai <xdai@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583041}
parent 213b1aac
......@@ -127,6 +127,17 @@ void TabletModeWindowDragDelegate::ContinueWindowDrag(
const gfx::Point& location_in_screen,
UpdateDraggedWindowType type,
const gfx::Rect& target_bounds) {
if (!did_move_) {
const gfx::Rect work_area_bounds =
display::Screen::GetScreen()
->GetDisplayNearestWindow(dragged_window_)
.work_area();
if (location_in_screen.y() >=
GetIndicatorsVerticalThreshold(work_area_bounds)) {
did_move_ = true;
}
}
if (type == UpdateDraggedWindowType::UPDATE_BOUNDS) {
// UPDATE_BOUNDS is used when dragging tab(s) out of a browser window.
// Changing bounds might delete ourselves as the dragged (browser) window
......@@ -188,6 +199,7 @@ void TabletModeWindowDragDelegate::EndWindowDrag(
}
dragged_window_ = nullptr;
did_move_ = false;
}
bool TabletModeWindowDragDelegate::ShouldOpenOverviewWhenDragStarts() {
......@@ -215,8 +227,10 @@ SplitViewController::SnapPosition TabletModeWindowDragDelegate::GetSnapPosition(
// The user has to drag pass the indicator vertical threshold to snap the
// window.
if (location_in_screen.y() < GetIndicatorsVerticalThreshold(work_area_bounds))
if (!did_move_ && location_in_screen.y() <
GetIndicatorsVerticalThreshold(work_area_bounds)) {
return SplitViewController::NONE;
}
const bool is_landscape =
split_view_controller_->IsCurrentScreenOrientationLandscape();
......@@ -287,11 +301,14 @@ IndicatorState TabletModeWindowDragDelegate::GetIndicatorState(
// If the event location hasn't passed the indicator vertical threshold, do
// not show the drag indicators.
gfx::Rect work_area_bounds = display::Screen::GetScreen()
const gfx::Rect work_area_bounds =
display::Screen::GetScreen()
->GetDisplayNearestWindow(dragged_window_)
.work_area();
if (location_in_screen.y() < GetIndicatorsVerticalThreshold(work_area_bounds))
if (!did_move_ && location_in_screen.y() <
GetIndicatorsVerticalThreshold(work_area_bounds)) {
return IndicatorState::kNone;
}
// If the event location has passed the maximize vertical threshold, and the
// event location is not in snap indicator area, and overview mode is not
......
......@@ -105,6 +105,12 @@ class TabletModeWindowDragDelegate {
// the desired window tranform during dragging.
gfx::Rect new_selector_item_bounds_;
// Flag to indicate whether a window is considered as moved. A window needs to
// be dragged vertically a small amount of distance to be considered as moved.
// The drag indicators will only show up after the window has been moved. Once
// the window is moved, it will stay as 'moved'.
bool did_move_ = false;
base::WeakPtrFactory<TabletModeWindowDragDelegate> weak_ptr_factory_;
private:
......
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