Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2278)

Unified Diff: ash/drag_drop/drag_drop_controller.cc

Issue 10855159: Support Drag and Drop across displays. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698