summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
Diffstat (limited to 'ash')
-rw-r--r--ash/drag_drop/drag_drop_controller.cc42
-rw-r--r--ash/drag_drop/drag_drop_controller.h7
-rw-r--r--ash/drag_drop/drag_drop_controller_unittest.cc7
3 files changed, 38 insertions, 18 deletions
diff --git a/ash/drag_drop/drag_drop_controller.cc b/ash/drag_drop/drag_drop_controller.cc
index 09c12ee..227e0810 100644
--- a/ash/drag_drop/drag_drop_controller.cc
+++ b/ash/drag_drop/drag_drop_controller.cc
@@ -52,7 +52,8 @@ DragDropController::~DragDropController() {
}
int DragDropController::StartDragAndDrop(const ui::OSExchangeData& data,
- int operation) {
+ const gfx::Point& root_location,
+ int operation) {
DCHECK(!drag_drop_in_progress_);
aura::Window* capture_window = Shell::GetRootWindow()->capture_window();
if (capture_window)
@@ -61,7 +62,6 @@ int DragDropController::StartDragAndDrop(const ui::OSExchangeData& data,
drag_data_ = &data;
drag_operation_ = operation;
- gfx::Point location = Shell::GetRootWindow()->last_mouse_location();
const ui::OSExchangeDataProviderAura& provider =
static_cast<const ui::OSExchangeDataProviderAura&>(data.provider());
provider.WriteDataToClipboard(
@@ -69,17 +69,19 @@ int DragDropController::StartDragAndDrop(const ui::OSExchangeData& data,
drag_image_.reset(new DragImageView);
drag_image_->SetImage(provider.drag_image());
- drag_image_->SetScreenBounds(gfx::Rect(location.Add(kDragDropWidgetOffset),
- drag_image_->GetPreferredSize()));
+ drag_image_->SetScreenBounds(gfx::Rect(
+ root_location.Add(kDragDropWidgetOffset),
+ drag_image_->GetPreferredSize()));
drag_image_->SetWidgetVisible(true);
dragged_window_ = NULL;
- drag_start_location_ = Shell::GetRootWindow()->last_mouse_location();
+ drag_start_location_ = root_location;
#if !defined(OS_MACOSX)
if (should_block_during_drag_drop_) {
- MessageLoopForUI::current()->RunWithDispatcher(
- Shell::GetRootWindow()->GetDispatcher());
+ MessageLoopForUI* loop = MessageLoopForUI::current();
+ MessageLoop::ScopedNestableTaskAllower allow_nested(loop);
+ loop->RunWithDispatcher(Shell::GetRootWindow()->GetDispatcher());
}
#endif // !defined(OS_MACOSX)
@@ -87,7 +89,7 @@ int DragDropController::StartDragAndDrop(const ui::OSExchangeData& data,
}
void DragDropController::DragUpdate(aura::Window* target,
- const aura::MouseEvent& event) {
+ const aura::LocatedEvent& event) {
aura::client::DragDropDelegate* delegate = NULL;
if (target != dragged_window_) {
if (dragged_window_) {
@@ -119,13 +121,13 @@ void DragDropController::DragUpdate(aura::Window* target,
DCHECK(drag_image_.get());
if (drag_image_->visible()) {
- drag_image_->SetScreenPosition(Shell::GetRootWindow()->
- last_mouse_location().Add(kDragDropWidgetOffset));
+ drag_image_->SetScreenPosition(
+ event.root_location().Add(kDragDropWidgetOffset));
}
}
void DragDropController::Drop(aura::Window* target,
- const aura::MouseEvent& event) {
+ const aura::LocatedEvent& event) {
Shell::GetRootWindow()->SetCursor(aura::kCursorPointer);
aura::client::DragDropDelegate* delegate = NULL;
DCHECK(target == dragged_window_);
@@ -195,7 +197,23 @@ bool DragDropController::PreHandleMouseEvent(aura::Window* target,
ui::TouchStatus DragDropController::PreHandleTouchEvent(
aura::Window* target,
aura::TouchEvent* event) {
- return ui::TOUCH_STATUS_UNKNOWN;
+ // TODO(sad): Also check for the touch-id.
+ if (!drag_drop_in_progress_)
+ return ui::TOUCH_STATUS_UNKNOWN;
+ switch (event->type()) {
+ case ui::ET_TOUCH_MOVED:
+ DragUpdate(target, *event);
+ break;
+ case ui::ET_TOUCH_RELEASED:
+ Drop(target, *event);
+ break;
+ case ui::ET_TOUCH_CANCELLED:
+ DragCancel();
+ break;
+ default:
+ return ui::TOUCH_STATUS_UNKNOWN;
+ }
+ return ui::TOUCH_STATUS_CONTINUE;
}
ui::GestureStatus DragDropController::PreHandleGestureEvent(
diff --git a/ash/drag_drop/drag_drop_controller.h b/ash/drag_drop/drag_drop_controller.h
index 4e5018a..7f86ba5 100644
--- a/ash/drag_drop/drag_drop_controller.h
+++ b/ash/drag_drop/drag_drop_controller.h
@@ -49,11 +49,12 @@ public:
// Overridden from aura::client::DragDropClient:
virtual int StartDragAndDrop(const ui::OSExchangeData& data,
- int operation) OVERRIDE;
+ const gfx::Point& root_location,
+ int operation) OVERRIDE;
virtual void DragUpdate(aura::Window* target,
- const aura::MouseEvent& event) OVERRIDE;
+ const aura::LocatedEvent& event) OVERRIDE;
virtual void Drop(aura::Window* target,
- const aura::MouseEvent& event) OVERRIDE;
+ const aura::LocatedEvent& event) OVERRIDE;
virtual void DragCancel() OVERRIDE;
virtual bool IsDragDropInProgress() OVERRIDE;
diff --git a/ash/drag_drop/drag_drop_controller_unittest.cc b/ash/drag_drop/drag_drop_controller_unittest.cc
index 73cbc45..a2a0d00 100644
--- a/ash/drag_drop/drag_drop_controller_unittest.cc
+++ b/ash/drag_drop/drag_drop_controller_unittest.cc
@@ -125,19 +125,20 @@ class TestDragDropController : public internal::DragDropController {
private:
int StartDragAndDrop(const ui::OSExchangeData& data,
+ const gfx::Point& location,
int operation) OVERRIDE {
drag_start_received_ = true;
data.GetString(&drag_string_);
- return DragDropController::StartDragAndDrop(data, operation);
+ return DragDropController::StartDragAndDrop(data, location, operation);
}
void DragUpdate(aura::Window* target,
- const aura::MouseEvent& event) OVERRIDE {
+ const aura::LocatedEvent& event) OVERRIDE {
DragDropController::DragUpdate(target, event);
num_drag_updates_++;
}
- void Drop(aura::Window* target, const aura::MouseEvent& event) OVERRIDE {
+ void Drop(aura::Window* target, const aura::LocatedEvent& event) OVERRIDE {
DragDropController::Drop(target, event);
drop_received_ = true;
}