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 445468a0fe287df2300f99bee6e7292194cccb90..cece6032bd64da52443c602b7845e1b3a9874b77 100644 |
--- a/ash/drag_drop/drag_drop_controller.cc |
+++ b/ash/drag_drop/drag_drop_controller.cc |
@@ -4,6 +4,7 @@ |
#include "ash/drag_drop/drag_drop_controller.h" |
+#include "ash/drag_drop/drag_drop_tracker.h" |
#include "ash/drag_drop/drag_image_view.h" |
#include "ash/shell.h" |
#include "ash/wm/cursor_manager.h" |
@@ -44,7 +45,8 @@ DragDropController::DragDropController() |
drag_operation_(0), |
drag_window_(NULL), |
drag_drop_in_progress_(false), |
- should_block_during_drag_drop_(true) { |
+ should_block_during_drag_drop_(true), |
+ drag_drop_tracker_(new DragDropTracker) { |
Shell::GetInstance()->AddEnvEventFilter(this); |
} |
@@ -56,16 +58,14 @@ DragDropController::~DragDropController() { |
} |
int DragDropController::StartDragAndDrop(const ui::OSExchangeData& data, |
+ aura::RootWindow* root_window, |
const gfx::Point& root_location, |
int operation) { |
DCHECK(!drag_drop_in_progress_); |
- // TODO(oshima): Add CaptureClient client API. |
- aura::Window* capture_window = |
- aura::client::GetCaptureWindow(Shell::GetPrimaryRootWindow()); |
- if (capture_window) |
- capture_window->ReleaseCapture(); |
+ |
drag_drop_in_progress_ = true; |
drag_cursor_ = ui::kCursorPointer; |
+ drag_drop_tracker_->StartTracking(root_window); |
drag_data_ = &data; |
drag_operation_ = operation; |
@@ -213,15 +213,19 @@ bool DragDropController::PreHandleMouseEvent(aura::Window* target, |
ui::MouseEvent* event) { |
if (!drag_drop_in_progress_) |
return false; |
- switch (event->type()) { |
+ aura::Window* translated_target = drag_drop_tracker_->GetTarget(*event); |
+ if (!translated_target) |
+ return false; |
varunjain
2012/08/20 16:21:22
when can this happen? Drag drop is in progress, so
mazda
2012/08/21 02:10:59
This happens when the cursor goes out of root wind
varunjain
2012/08/21 04:37:25
How about calling DragCancel() instead. It will do
mazda
2012/08/24 08:29:01
Done.
|
+ scoped_ptr<ui::MouseEvent> translated_event( |
+ drag_drop_tracker_->ConvertMouseEvent(translated_target, *event)); |
+ switch (translated_event->type()) { |
case ui::ET_MOUSE_DRAGGED: |
- DragUpdate(target, *event); |
+ DragUpdate(translated_target, *translated_event.get()); |
varunjain
2012/08/20 16:21:22
would you also require re-parenting the drag_image
mazda
2012/08/21 02:10:59
DragImageView::SetScreenPosition does it internall
varunjain
2012/08/21 04:37:25
cool! thanks for fixing!
|
break; |
case ui::ET_MOUSE_RELEASED: |
- Drop(target, *event); |
+ Drop(translated_target, *translated_event.get()); |
break; |
default: |
- // We could reach here if the user drops outside the root window. |
// We could also reach here because RootWindow may sometimes generate a |
// bunch of fake mouse events |
// (aura::RootWindow::PostMouseMoveEventAfterWindowChange). |
@@ -298,6 +302,7 @@ void DragDropController::Cleanup() { |
drag_window_ = NULL; |
drag_data_ = NULL; |
drag_drop_in_progress_ = false; |
+ drag_drop_tracker_->StopTracking(); |
} |
} // namespace internal |