Chromium Code Reviews| Index: ash/drag_drop/drag_drop_controller.cc |
| diff --git a/ash/drag_drop/drag_drop_controller.cc b/ash/drag_drop/drag_drop_controller.cc |
| index 4ace7378a24e0e8e606f2d77116ee5b15fbdcd69..133fb35931a3477a05c965aeadfdfd5d5a24c261 100644 |
| --- a/ash/drag_drop/drag_drop_controller.cc |
| +++ b/ash/drag_drop/drag_drop_controller.cc |
| @@ -6,8 +6,9 @@ |
| #include <utility> |
| +#include "ash/aura/wm_window_aura.h" |
| +#include "ash/common/drag_drop/drag_image_view.h" |
| #include "ash/drag_drop/drag_drop_tracker.h" |
| -#include "ash/drag_drop/drag_image_view.h" |
| #include "ash/shell.h" |
| #include "base/bind.h" |
| #include "base/message_loop/message_loop.h" |
| @@ -134,9 +135,11 @@ DragDropController::DragDropController() |
| current_drag_event_source_(ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE), |
| weak_factory_(this) { |
| Shell::GetInstance()->PrependPreTargetHandler(this); |
| + Shell::GetInstance()->window_tree_host_manager()->AddObserver(this); |
| } |
| DragDropController::~DragDropController() { |
| + Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this); |
| Shell::GetInstance()->RemovePreTargetHandler(this); |
| Cleanup(); |
| if (cancel_animation_) |
| @@ -199,7 +202,8 @@ int DragDropController::StartDragAndDrop( |
| drag_image_final_bounds_for_cancel_animation_ = |
| gfx::Rect(start_location - provider->GetDragImageOffset(), |
| provider->GetDragImage().size()); |
| - drag_image_.reset(new DragImageView(source_window->GetRootWindow(), source)); |
| + drag_image_.reset(new DragImageView( |
| + WmWindowAura::Get(source_window)->GetRootWindow(), source)); |
|
msw
2016/08/05 19:32:58
nit: comment here on the reasoning for using WmWin
James Cook
2016/08/05 20:10:11
There's no good reason to change it to WmWindow::G
|
| drag_image_->SetImage(provider->GetDragImage()); |
| drag_image_offset_ = provider->GetDragImageOffset(); |
| gfx::Rect drag_image_bounds(start_location, drag_image_->GetPreferredSize()); |
| @@ -537,6 +541,13 @@ void DragDropController::AnimationCanceled(const gfx::Animation* animation) { |
| AnimationEnded(animation); |
| } |
| +void DragDropController::OnDisplayConfigurationChanging() { |
| + // Abort in-progress drags if a monitor is added or removed because the drag |
| + // image widget's container may be destroyed. |
| + if (IsDragDropInProgress()) |
| + DragCancel(); |
| +} |
| + |
| void DragDropController::StartCanceledAnimation(int animation_duration_ms) { |
| DCHECK(drag_image_.get()); |
| drag_image_->SetTouchDragOperationHintOff(); |