Commit 40165b9a authored by Avery Musbach's avatar Avery Musbach Committed by Commit Bot

overview: Show drop target even if split view is disabled

The purpose of the present CL is to add a drop target in a certain
workflow. As of [1], the "drag to snap" mode has become a "normal drag"
mode which is available even when split view mode is not available. For
testing, you can note that in clamshell mode, with the functionality of
[2] disabled (the current default), split view mode is not available,
but you can still do a "normal drag" from overview. There is presently
no drop target in that workflow. There is no drop target depicted in [3]
either, but I am pretty sure a drop target is actually appropriate,
because of [4] (which is assigned to me) if for no other reason.

[1] https://chromium-review.googlesource.com/c/chromium/src/+/1612121
[2] https://crbug.com/890029
[3] https://bugs.chromium.org/p/chromium/issues/detail?id=866622#c33
[4] https://crbug.com/961170

Test: manual
Bug: 866622, 961170
Change-Id: I079d01c3e449b10f23a19a9993fbdd44d0c1482e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1627562Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Reviewed-by: default avatarSammie Quon <sammiequon@chromium.org>
Commit-Queue: Avery Musbach <amusbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#663305}
parent 933dcf38
...@@ -660,7 +660,6 @@ void OverviewGrid::SetBoundsAndUpdatePositions( ...@@ -660,7 +660,6 @@ void OverviewGrid::SetBoundsAndUpdatePositions(
} }
void OverviewGrid::RearrangeDuringDrag(aura::Window* dragged_window, void OverviewGrid::RearrangeDuringDrag(aura::Window* dragged_window,
const gfx::PointF& location_in_screen,
IndicatorState indicator_state) { IndicatorState indicator_state) {
OverviewItem* drop_target = GetDropTarget(); OverviewItem* drop_target = GetDropTarget();
...@@ -676,12 +675,11 @@ void OverviewGrid::RearrangeDuringDrag(aura::Window* dragged_window, ...@@ -676,12 +675,11 @@ void OverviewGrid::RearrangeDuringDrag(aura::Window* dragged_window,
drop_target->SetOpacity(wanted_drop_target_visibility ? 1.f : 0.f); drop_target->SetOpacity(wanted_drop_target_visibility ? 1.f : 0.f);
} }
OverviewItem* dragged_item = GetOverviewItemContaining(dragged_window);
// Update the grid's bounds. // Update the grid's bounds.
const gfx::Rect wanted_grid_bounds = const gfx::Rect wanted_grid_bounds =
GetGridBoundsInScreenDuringDragging(dragged_window, indicator_state); GetGridBoundsInScreenDuringDragging(dragged_window, indicator_state);
if (update_drop_target_visibility || bounds_ != wanted_grid_bounds) { if (update_drop_target_visibility || bounds_ != wanted_grid_bounds) {
OverviewItem* dragged_item = GetOverviewItemContaining(dragged_window);
base::flat_set<OverviewItem*> ignored_items; base::flat_set<OverviewItem*> ignored_items;
if (dragged_item) if (dragged_item)
ignored_items.insert(dragged_item); ignored_items.insert(dragged_item);
...@@ -689,12 +687,12 @@ void OverviewGrid::RearrangeDuringDrag(aura::Window* dragged_window, ...@@ -689,12 +687,12 @@ void OverviewGrid::RearrangeDuringDrag(aura::Window* dragged_window,
ignored_items.insert(drop_target); ignored_items.insert(drop_target);
SetBoundsAndUpdatePositions(wanted_grid_bounds, ignored_items); SetBoundsAndUpdatePositions(wanted_grid_bounds, ignored_items);
} }
}
// If the drop target is on another grid, let that grid handle what follows. void OverviewGrid::UpdateDropTargetBackgroundVisibility(
if (!drop_target) OverviewItem* dragged_item,
return; const gfx::PointF& location_in_screen) {
DCHECK(drop_target_widget_);
// Visually indicate when |dragged_window| is dragged over the drop target.
aura::Window* target_window = aura::Window* target_window =
GetTargetWindowOnLocation(location_in_screen, dragged_item); GetTargetWindowOnLocation(location_in_screen, dragged_item);
DropTargetView* drop_target_view = DropTargetView* drop_target_view =
...@@ -749,7 +747,8 @@ void OverviewGrid::OnWindowDragContinued(aura::Window* dragged_window, ...@@ -749,7 +747,8 @@ void OverviewGrid::OnWindowDragContinued(aura::Window* dragged_window,
IndicatorState indicator_state) { IndicatorState indicator_state) {
DCHECK_EQ(dragged_window->GetRootWindow(), root_window_); DCHECK_EQ(dragged_window->GetRootWindow(), root_window_);
RearrangeDuringDrag(dragged_window, location_in_screen, indicator_state); RearrangeDuringDrag(dragged_window, indicator_state);
UpdateDropTargetBackgroundVisibility(nullptr, location_in_screen);
aura::Window* target_window = aura::Window* target_window =
GetTargetWindowOnLocation(location_in_screen, /*ignored_item=*/nullptr); GetTargetWindowOnLocation(location_in_screen, /*ignored_item=*/nullptr);
......
...@@ -135,12 +135,17 @@ class ASH_EXPORT OverviewGrid : public aura::WindowObserver, ...@@ -135,12 +135,17 @@ class ASH_EXPORT OverviewGrid : public aura::WindowObserver,
const base::flat_set<OverviewItem*>& ignored_items); const base::flat_set<OverviewItem*>& ignored_items);
// Updates overview bounds and hides the drop target when a preview area is // Updates overview bounds and hides the drop target when a preview area is
// shown. Updates the appearance of the drop target to visually indicate when // shown.
// |dragged_window| is being dragged over it.
void RearrangeDuringDrag(aura::Window* dragged_window, void RearrangeDuringDrag(aura::Window* dragged_window,
const gfx::PointF& location_in_screen,
IndicatorState indicator_state); IndicatorState indicator_state);
// Updates the appearance of the drop target to visually indicate when the
// dragged window is being dragged over it. For dragging from the top, pass
// null for |dragged_item|.
void UpdateDropTargetBackgroundVisibility(
OverviewItem* dragged_item,
const gfx::PointF& location_in_screen);
// Shows or hides the selection widget. To be called by an overview item when // Shows or hides the selection widget. To be called by an overview item when
// it is dragged. // it is dragged.
void SetSelectionWidgetVisibility(bool visible); void SetSelectionWidgetVisibility(bool visible);
......
...@@ -190,9 +190,9 @@ void OverviewWindowDragController::StartNormalDragMode( ...@@ -190,9 +190,9 @@ void OverviewWindowDragController::StartNormalDragMode(
item_->ScaleUpSelectedItem( item_->ScaleUpSelectedItem(
OVERVIEW_ANIMATION_LAYOUT_OVERVIEW_ITEMS_IN_OVERVIEW); OVERVIEW_ANIMATION_LAYOUT_OVERVIEW_ITEMS_IN_OVERVIEW);
original_scaled_size_ = item_->target_bounds().size(); original_scaled_size_ = item_->target_bounds().size();
item_->overview_grid()->AddDropTargetForDraggingFromOverview(item_);
if (should_allow_split_view_) { if (should_allow_split_view_) {
item_->overview_grid()->AddDropTargetForDraggingFromOverview(item_);
overview_session_->SetSplitViewDragIndicatorsIndicatorState( overview_session_->SetSplitViewDragIndicatorsIndicatorState(
CanSnapInSplitview(item_->GetWindow()) ? IndicatorState::kDragArea CanSnapInSplitview(item_->GetWindow()) ? IndicatorState::kDragArea
: IndicatorState::kCannotSnap, : IndicatorState::kCannotSnap,
...@@ -252,6 +252,8 @@ void OverviewWindowDragController::ActivateDraggedWindow() { ...@@ -252,6 +252,8 @@ void OverviewWindowDragController::ActivateDraggedWindow() {
void OverviewWindowDragController::ResetGesture() { void OverviewWindowDragController::ResetGesture() {
if (current_drag_behavior_ == DragBehavior::kNormalDrag) { if (current_drag_behavior_ == DragBehavior::kNormalDrag) {
DCHECK(item_->overview_grid()->drop_target_widget());
Shell::Get()->mouse_cursor_filter()->HideSharedEdgeIndicator(); Shell::Get()->mouse_cursor_filter()->HideSharedEdgeIndicator();
item_->DestroyPhantomsForDragging(); item_->DestroyPhantomsForDragging();
item_->overview_grid()->RemoveDropTarget(); item_->overview_grid()->RemoveDropTarget();
...@@ -350,6 +352,8 @@ gfx::RectF OverviewWindowDragController::ContinueNormalDrag( ...@@ -350,6 +352,8 @@ gfx::RectF OverviewWindowDragController::ContinueNormalDrag(
if (should_allow_split_view_) if (should_allow_split_view_)
UpdateDragIndicatorsAndOverviewGrid(location_in_screen); UpdateDragIndicatorsAndOverviewGrid(location_in_screen);
item_->overview_grid()->UpdateDropTargetBackgroundVisibility(
item_, location_in_screen);
bounds.set_x(centerpoint.x() - bounds.width() / 2.f); bounds.set_x(centerpoint.x() - bounds.width() / 2.f);
bounds.set_y(centerpoint.y() - bounds.height() / 2.f); bounds.set_y(centerpoint.y() - bounds.height() / 2.f);
...@@ -360,14 +364,14 @@ OverviewWindowDragController::DragResult ...@@ -360,14 +364,14 @@ OverviewWindowDragController::DragResult
OverviewWindowDragController::CompleteNormalDrag( OverviewWindowDragController::CompleteNormalDrag(
const gfx::PointF& location_in_screen) { const gfx::PointF& location_in_screen) {
DCHECK_EQ(current_drag_behavior_, DragBehavior::kNormalDrag); DCHECK_EQ(current_drag_behavior_, DragBehavior::kNormalDrag);
DCHECK(item_->overview_grid()->drop_target_widget());
Shell::Get()->mouse_cursor_filter()->HideSharedEdgeIndicator(); Shell::Get()->mouse_cursor_filter()->HideSharedEdgeIndicator();
item_->DestroyPhantomsForDragging(); item_->DestroyPhantomsForDragging();
item_->overview_grid()->RemoveDropTarget();
const gfx::Point rounded_screen_point = const gfx::Point rounded_screen_point =
gfx::ToRoundedPoint(location_in_screen); gfx::ToRoundedPoint(location_in_screen);
if (should_allow_split_view_) { if (should_allow_split_view_) {
DCHECK(item_->overview_grid()->drop_target_widget());
item_->overview_grid()->RemoveDropTarget();
// Update the split view divider bar stuatus if necessary. The divider bar // Update the split view divider bar stuatus if necessary. The divider bar
// should be placed above the dragged window after drag ends. Note here the // should be placed above the dragged window after drag ends. Note here the
// passed parameters |snap_position_| and |location_in_screen| won't be used // passed parameters |snap_position_| and |location_in_screen| won't be used
...@@ -441,8 +445,8 @@ void OverviewWindowDragController::UpdateDragIndicatorsAndOverviewGrid( ...@@ -441,8 +445,8 @@ void OverviewWindowDragController::UpdateDragIndicatorsAndOverviewGrid(
snap_position_ = SplitViewController::NONE; snap_position_ = SplitViewController::NONE;
indicator_state = IndicatorState::kCannotSnap; indicator_state = IndicatorState::kCannotSnap;
} }
item_->overview_grid()->RearrangeDuringDrag( item_->overview_grid()->RearrangeDuringDrag(item_->GetWindow(),
item_->GetWindow(), location_in_screen, indicator_state); indicator_state);
overview_session_->SetSplitViewDragIndicatorsIndicatorState(indicator_state, overview_session_->SetSplitViewDragIndicatorsIndicatorState(indicator_state,
gfx::Point()); gfx::Point());
} }
......
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