| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/drag_drop/drag_drop_controller.h" | 5 #include "ash/drag_drop/drag_drop_controller.h" |
| 6 | 6 |
| 7 #include "ash/drag_drop/drag_drop_tracker.h" | 7 #include "ash/drag_drop/drag_drop_tracker.h" |
| 8 #include "ash/drag_drop/drag_image_view.h" | 8 #include "ash/drag_drop/drag_image_view.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/wm/coordinate_conversion.h" | 10 #include "ash/wm/coordinate_conversion.h" |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 delegate->OnDragExited(); | 254 delegate->OnDragExited(); |
| 255 if (drag_window_ != drag_source_window_) | 255 if (drag_window_ != drag_source_window_) |
| 256 drag_window_->RemoveObserver(this); | 256 drag_window_->RemoveObserver(this); |
| 257 } | 257 } |
| 258 drag_window_ = target; | 258 drag_window_ = target; |
| 259 // We are already an observer of |drag_source_window_| so no need to add. | 259 // We are already an observer of |drag_source_window_| so no need to add. |
| 260 if (drag_window_ != drag_source_window_) | 260 if (drag_window_ != drag_source_window_) |
| 261 drag_window_->AddObserver(this); | 261 drag_window_->AddObserver(this); |
| 262 if ((delegate = aura::client::GetDragDropDelegate(drag_window_))) { | 262 if ((delegate = aura::client::GetDragDropDelegate(drag_window_))) { |
| 263 ui::DropTargetEvent e(*drag_data_, | 263 ui::DropTargetEvent e(*drag_data_, |
| 264 event.location(), | 264 gfx::ToFlooredPoint(event.location()), |
| 265 event.root_location(), | 265 event.root_location(), |
| 266 drag_operation_); | 266 drag_operation_); |
| 267 e.set_flags(event.flags()); | 267 e.set_flags(event.flags()); |
| 268 delegate->OnDragEntered(e); | 268 delegate->OnDragEntered(e); |
| 269 } | 269 } |
| 270 } else { | 270 } else { |
| 271 if ((delegate = aura::client::GetDragDropDelegate(drag_window_))) { | 271 if ((delegate = aura::client::GetDragDropDelegate(drag_window_))) { |
| 272 ui::DropTargetEvent e(*drag_data_, | 272 ui::DropTargetEvent e(*drag_data_, |
| 273 event.location(), | 273 gfx::ToFlooredPoint(event.location()), |
| 274 event.root_location(), | 274 event.root_location(), |
| 275 drag_operation_); | 275 drag_operation_); |
| 276 e.set_flags(event.flags()); | 276 e.set_flags(event.flags()); |
| 277 op = delegate->OnDragUpdated(e); | 277 op = delegate->OnDragUpdated(e); |
| 278 gfx::NativeCursor cursor = ui::kCursorNoDrop; | 278 gfx::NativeCursor cursor = ui::kCursorNoDrop; |
| 279 if (op & ui::DragDropTypes::DRAG_COPY) | 279 if (op & ui::DragDropTypes::DRAG_COPY) |
| 280 cursor = ui::kCursorCopy; | 280 cursor = ui::kCursorCopy; |
| 281 else if (op & ui::DragDropTypes::DRAG_LINK) | 281 else if (op & ui::DragDropTypes::DRAG_LINK) |
| 282 cursor = ui::kCursorAlias; | 282 cursor = ui::kCursorAlias; |
| 283 else if (op & ui::DragDropTypes::DRAG_MOVE) | 283 else if (op & ui::DragDropTypes::DRAG_MOVE) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 303 aura::client::DragDropDelegate* delegate = NULL; | 303 aura::client::DragDropDelegate* delegate = NULL; |
| 304 | 304 |
| 305 // We must guarantee that a target gets a OnDragEntered before Drop. WebKit | 305 // We must guarantee that a target gets a OnDragEntered before Drop. WebKit |
| 306 // depends on not getting a Drop without DragEnter. This behavior is | 306 // depends on not getting a Drop without DragEnter. This behavior is |
| 307 // consistent with drag/drop on other platforms. | 307 // consistent with drag/drop on other platforms. |
| 308 if (target != drag_window_) | 308 if (target != drag_window_) |
| 309 DragUpdate(target, event); | 309 DragUpdate(target, event); |
| 310 DCHECK(target == drag_window_); | 310 DCHECK(target == drag_window_); |
| 311 | 311 |
| 312 if ((delegate = aura::client::GetDragDropDelegate(target))) { | 312 if ((delegate = aura::client::GetDragDropDelegate(target))) { |
| 313 ui::DropTargetEvent e( | 313 ui::DropTargetEvent e(*drag_data_, |
| 314 *drag_data_, event.location(), event.root_location(), drag_operation_); | 314 gfx::ToFlooredPoint(event.location()), |
| 315 event.root_location(), |
| 316 drag_operation_); |
| 315 e.set_flags(event.flags()); | 317 e.set_flags(event.flags()); |
| 316 drag_operation_ = delegate->OnPerformDrop(e); | 318 drag_operation_ = delegate->OnPerformDrop(e); |
| 317 if (drag_operation_ == 0) | 319 if (drag_operation_ == 0) |
| 318 StartCanceledAnimation(kCancelAnimationDuration); | 320 StartCanceledAnimation(kCancelAnimationDuration); |
| 319 else | 321 else |
| 320 drag_image_.reset(); | 322 drag_image_.reset(); |
| 321 } else { | 323 } else { |
| 322 drag_image_.reset(); | 324 drag_image_.reset(); |
| 323 } | 325 } |
| 324 | 326 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 event->StopPropagation(); | 409 event->StopPropagation(); |
| 408 | 410 |
| 409 // If current drag session was not started by touch, dont process this event. | 411 // If current drag session was not started by touch, dont process this event. |
| 410 if (current_drag_event_source_ != ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH) | 412 if (current_drag_event_source_ != ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH) |
| 411 return; | 413 return; |
| 412 | 414 |
| 413 // Apply kTouchDragImageVerticalOffset to the location. | 415 // Apply kTouchDragImageVerticalOffset to the location. |
| 414 ui::GestureEvent touch_offset_event(*event, | 416 ui::GestureEvent touch_offset_event(*event, |
| 415 static_cast<aura::Window*>(NULL), | 417 static_cast<aura::Window*>(NULL), |
| 416 static_cast<aura::Window*>(NULL)); | 418 static_cast<aura::Window*>(NULL)); |
| 417 gfx::Point touch_offset_location = touch_offset_event.location(); | 419 gfx::Point touch_offset_location = |
| 420 gfx::ToFlooredPoint(touch_offset_event.location()); |
| 418 gfx::Point touch_offset_root_location = touch_offset_event.root_location(); | 421 gfx::Point touch_offset_root_location = touch_offset_event.root_location(); |
| 419 touch_offset_location.Offset(0, kTouchDragImageVerticalOffset); | 422 touch_offset_location.Offset(0, kTouchDragImageVerticalOffset); |
| 420 touch_offset_root_location.Offset(0, kTouchDragImageVerticalOffset); | 423 touch_offset_root_location.Offset(0, kTouchDragImageVerticalOffset); |
| 421 touch_offset_event.set_location(touch_offset_location); | 424 touch_offset_event.set_location(touch_offset_location); |
| 422 touch_offset_event.set_root_location(touch_offset_root_location); | 425 touch_offset_event.set_root_location(touch_offset_root_location); |
| 423 | 426 |
| 424 aura::Window* translated_target = | 427 aura::Window* translated_target = |
| 425 drag_drop_tracker_->GetTarget(touch_offset_event); | 428 drag_drop_tracker_->GetTarget(touch_offset_event); |
| 426 if (!translated_target) { | 429 if (!translated_target) { |
| 427 DragCancel(); | 430 DragCancel(); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 if (drag_window_) | 556 if (drag_window_) |
| 554 drag_window_->RemoveObserver(this); | 557 drag_window_->RemoveObserver(this); |
| 555 drag_window_ = NULL; | 558 drag_window_ = NULL; |
| 556 drag_data_ = NULL; | 559 drag_data_ = NULL; |
| 557 // Cleanup can be called again while deleting DragDropTracker, so use Pass | 560 // Cleanup can be called again while deleting DragDropTracker, so use Pass |
| 558 // instead of reset to avoid double free. | 561 // instead of reset to avoid double free. |
| 559 drag_drop_tracker_.Pass(); | 562 drag_drop_tracker_.Pass(); |
| 560 } | 563 } |
| 561 | 564 |
| 562 } // namespace ash | 565 } // namespace ash |
| OLD | NEW |