Commit d9af410f authored by Avery Musbach's avatar Avery Musbach Committed by Commit Bot

overview: Basic visuals for multidisplay drag, based on outside overview

See Comment 2 here:
https://bugs.chromium.org/p/chromium/issues/detail?id=961170#c2

Test: manual
Bug: 961170
Change-Id: I42509d8f4ff4cffa84441ea392b56a68ac8d608b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1627910
Commit-Queue: Avery Musbach <amusbach@chromium.org>
Reviewed-by: default avatarSammie Quon <sammiequon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#662885}
parent 63b914e2
......@@ -15,6 +15,7 @@
#include "ash/scoped_animation_disabler.h"
#include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/wm/drag_window_controller.h"
#include "ash/wm/overview/delayed_animation_observer_impl.h"
#include "ash/wm/overview/overview_animation_type.h"
#include "ash/wm/overview/overview_constants.h"
......@@ -702,6 +703,31 @@ void OverviewItem::OnDragAnimationCompleted() {
}
}
void OverviewItem::UpdatePhantomsForDragging(
const gfx::PointF& location_in_screen) {
aura::Window* window = transform_window_.IsMinimized()
? item_widget_->GetNativeWindow()
: GetWindow();
if (!phantoms_for_dragging_) {
DCHECK_EQ(1.f, window->layer()->opacity());
phantoms_for_dragging_ = std::make_unique<DragWindowController>(window);
}
const gfx::Point location = gfx::ToRoundedPoint(location_in_screen);
window->layer()->SetOpacity(DragWindowController::GetDragWindowOpacity(
root_window_, window, location));
phantoms_for_dragging_->Update(location);
}
void OverviewItem::DestroyPhantomsForDragging() {
phantoms_for_dragging_.reset();
aura::Window* window = transform_window_.IsMinimized()
? item_widget_->GetNativeWindow()
: GetWindow();
window->layer()->SetOpacity(1.f);
}
void OverviewItem::SetShadowBounds(base::Optional<gfx::Rect> bounds_in_screen) {
// Shadow is normally turned off during animations and reapplied when they
// are finished. On destruction, |shadow_| is cleaned up before
......
......@@ -29,6 +29,7 @@ class Widget;
} // namespace views
namespace ash {
class DragWindowController;
class OverviewGrid;
class RoundedLabelWidget;
......@@ -162,6 +163,12 @@ class ASH_EXPORT OverviewItem : public CaptionContainerView::EventDelegate,
// when entering overview.
void OnDragAnimationCompleted();
// Updates |phantoms_for_dragging_|. If |phantoms_for_dragging_| is null, then
// a new object is created for it.
void UpdatePhantomsForDragging(const gfx::PointF& location_in_screen);
void DestroyPhantomsForDragging();
// Sets the bounds of the window shadow. If |bounds_in_screen| is nullopt,
// the shadow is hidden.
void SetShadowBounds(base::Optional<gfx::Rect> bounds_in_screen);
......@@ -315,6 +322,10 @@ class ASH_EXPORT OverviewItem : public CaptionContainerView::EventDelegate,
// users this window cannot be snapped.
std::unique_ptr<RoundedLabelWidget> cannot_snap_widget_;
// Responsible for phantoms that look like the window on all displays during
// dragging.
std::unique_ptr<DragWindowController> phantoms_for_dragging_;
// Pointer to the Overview that owns the OverviewGrid containing |this|.
// Guaranteed to be non-null for the lifetime of |this|.
OverviewSession* overview_session_;
......
......@@ -6,6 +6,7 @@
#include <memory>
#include "ash/display/mouse_cursor_event_filter.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/presentation_time_recorder.h"
#include "ash/screen_util.h"
......@@ -146,6 +147,8 @@ void OverviewWindowDragController::Drag(const gfx::PointF& location_in_screen) {
presentation_time_recorder_->RequestNext();
item_->SetBounds(bounds, OVERVIEW_ANIMATION_NONE);
if (current_drag_behavior_ == DragBehavior::kNormalDrag)
item_->UpdatePhantomsForDragging(location_in_screen);
}
OverviewWindowDragController::DragResult
......@@ -182,6 +185,8 @@ void OverviewWindowDragController::StartNormalDragMode(
const gfx::PointF& location_in_screen) {
did_move_ = true;
current_drag_behavior_ = DragBehavior::kNormalDrag;
Shell::Get()->mouse_cursor_filter()->ShowSharedEdgeIndicator(
item_->root_window());
item_->ScaleUpSelectedItem(
OVERVIEW_ANIMATION_LAYOUT_OVERVIEW_ITEMS_IN_OVERVIEW);
original_scaled_size_ = item_->target_bounds().size();
......@@ -247,6 +252,8 @@ void OverviewWindowDragController::ActivateDraggedWindow() {
void OverviewWindowDragController::ResetGesture() {
if (current_drag_behavior_ == DragBehavior::kNormalDrag) {
Shell::Get()->mouse_cursor_filter()->HideSharedEdgeIndicator();
item_->DestroyPhantomsForDragging();
overview_session_->RemoveDropTargetForDraggingFromOverview(item_);
overview_session_->SetSplitViewDragIndicatorsIndicatorState(
IndicatorState::kNone, gfx::Point());
......@@ -353,6 +360,8 @@ OverviewWindowDragController::DragResult
OverviewWindowDragController::CompleteNormalDrag(
const gfx::PointF& location_in_screen) {
DCHECK_EQ(current_drag_behavior_, DragBehavior::kNormalDrag);
Shell::Get()->mouse_cursor_filter()->HideSharedEdgeIndicator();
item_->DestroyPhantomsForDragging();
const gfx::Point rounded_screen_point =
gfx::ToRoundedPoint(location_in_screen);
......
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