| 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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 return !!drag_drop_tracker_.get(); | 285 return !!drag_drop_tracker_.get(); |
| 286 } | 286 } |
| 287 | 287 |
| 288 void DragDropController::OnKeyEvent(ui::KeyEvent* event) { | 288 void DragDropController::OnKeyEvent(ui::KeyEvent* event) { |
| 289 if (IsDragDropInProgress() && event->key_code() == ui::VKEY_ESCAPE) { | 289 if (IsDragDropInProgress() && event->key_code() == ui::VKEY_ESCAPE) { |
| 290 DragCancel(); | 290 DragCancel(); |
| 291 event->StopPropagation(); | 291 event->StopPropagation(); |
| 292 } | 292 } |
| 293 } | 293 } |
| 294 | 294 |
| 295 ui::EventResult DragDropController::OnMouseEvent(ui::MouseEvent* event) { | 295 void DragDropController::OnMouseEvent(ui::MouseEvent* event) { |
| 296 if (!IsDragDropInProgress()) | 296 if (!IsDragDropInProgress()) |
| 297 return ui::ER_UNHANDLED; | 297 return; |
| 298 | 298 |
| 299 // If current drag session was not started by mouse, dont process this mouse | 299 // If current drag session was not started by mouse, dont process this mouse |
| 300 // event, but consume it so it does not interfere with current drag session. | 300 // event, but consume it so it does not interfere with current drag session. |
| 301 if (current_drag_event_source_ != ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE) | 301 if (current_drag_event_source_ != |
| 302 return ui::ER_CONSUMED; | 302 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE) { |
| 303 event->StopPropagation(); |
| 304 return; |
| 305 } |
| 303 | 306 |
| 304 aura::Window* translated_target = drag_drop_tracker_->GetTarget(*event); | 307 aura::Window* translated_target = drag_drop_tracker_->GetTarget(*event); |
| 305 if (!translated_target) { | 308 if (!translated_target) { |
| 306 DragCancel(); | 309 DragCancel(); |
| 307 return ui::ER_CONSUMED; | 310 event->StopPropagation(); |
| 311 return; |
| 308 } | 312 } |
| 309 scoped_ptr<ui::LocatedEvent> translated_event( | 313 scoped_ptr<ui::LocatedEvent> translated_event( |
| 310 drag_drop_tracker_->ConvertEvent(translated_target, *event)); | 314 drag_drop_tracker_->ConvertEvent(translated_target, *event)); |
| 311 switch (translated_event->type()) { | 315 switch (translated_event->type()) { |
| 312 case ui::ET_MOUSE_DRAGGED: | 316 case ui::ET_MOUSE_DRAGGED: |
| 313 DragUpdate(translated_target, *translated_event.get()); | 317 DragUpdate(translated_target, *translated_event.get()); |
| 314 break; | 318 break; |
| 315 case ui::ET_MOUSE_RELEASED: | 319 case ui::ET_MOUSE_RELEASED: |
| 316 Drop(translated_target, *translated_event.get()); | 320 Drop(translated_target, *translated_event.get()); |
| 317 break; | 321 break; |
| 318 default: | 322 default: |
| 319 // We could also reach here because RootWindow may sometimes generate a | 323 // We could also reach here because RootWindow may sometimes generate a |
| 320 // bunch of fake mouse events | 324 // bunch of fake mouse events |
| 321 // (aura::RootWindow::PostMouseMoveEventAfterWindowChange). | 325 // (aura::RootWindow::PostMouseMoveEventAfterWindowChange). |
| 322 break; | 326 break; |
| 323 } | 327 } |
| 324 return ui::ER_CONSUMED; | 328 event->StopPropagation(); |
| 325 } | 329 } |
| 326 | 330 |
| 327 void DragDropController::OnTouchEvent(ui::TouchEvent* event) { | 331 void DragDropController::OnTouchEvent(ui::TouchEvent* event) { |
| 328 if (!IsDragDropInProgress()) | 332 if (!IsDragDropInProgress()) |
| 329 return; | 333 return; |
| 330 | 334 |
| 331 // If current drag session was not started by touch, dont process this touch | 335 // If current drag session was not started by touch, dont process this touch |
| 332 // event, but consume it so it does not interfere with current drag session. | 336 // event, but consume it so it does not interfere with current drag session. |
| 333 if (current_drag_event_source_ != ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH) | 337 if (current_drag_event_source_ != ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH) |
| 334 event->StopPropagation(); | 338 event->StopPropagation(); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 drag_window_->RemoveObserver(this); | 502 drag_window_->RemoveObserver(this); |
| 499 drag_window_ = NULL; | 503 drag_window_ = NULL; |
| 500 drag_data_ = NULL; | 504 drag_data_ = NULL; |
| 501 // Cleanup can be called again while deleting DragDropTracker, so use Pass | 505 // Cleanup can be called again while deleting DragDropTracker, so use Pass |
| 502 // instead of reset to avoid double free. | 506 // instead of reset to avoid double free. |
| 503 drag_drop_tracker_.Pass(); | 507 drag_drop_tracker_.Pass(); |
| 504 } | 508 } |
| 505 | 509 |
| 506 } // namespace internal | 510 } // namespace internal |
| 507 } // namespace ash | 511 } // namespace ash |
| OLD | NEW |