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 dd8a0971a638a1b75858c277737fc10b2ab34cc8..423e1384692ddb04a0e10b91491476918cb3dca7 100644 |
--- a/ash/drag_drop/drag_drop_controller.cc |
+++ b/ash/drag_drop/drag_drop_controller.cc |
@@ -32,6 +32,12 @@ using aura::RootWindow; |
namespace { |
const base::TimeDelta kDragDropAnimationDuration = |
base::TimeDelta::FromMilliseconds(250); |
+ |
+void UnlockAndSwitchCursor(gfx::NativeCursor new_cursor) { |
+ ash::Shell::GetInstance()->cursor_manager()->UnlockCursor(); |
sky
2012/08/02 16:26:42
Unlock/Lock decrement/increment a count. So, it's
varunjain
2012/08/02 17:29:52
I have moved the cursor locking to the RootWindow.
|
+ ash::Shell::GetInstance()->cursor_manager()->SetCursor(new_cursor); |
+ ash::Shell::GetInstance()->cursor_manager()->LockCursor(); |
+} |
} // namespace |
//////////////////////////////////////////////////////////////////////////////// |
@@ -64,6 +70,7 @@ int DragDropController::StartDragAndDrop(const ui::OSExchangeData& data, |
if (capture_window) |
capture_window->ReleaseCapture(); |
drag_drop_in_progress_ = true; |
+ ash::Shell::GetInstance()->cursor_manager()->LockCursor(); |
drag_data_ = &data; |
drag_operation_ = operation; |
@@ -128,7 +135,7 @@ void DragDropController::DragUpdate(aura::Window* target, |
cursor = ui::kCursorAlias; |
else if (op & ui::DragDropTypes::DRAG_MOVE) |
cursor = ui::kCursorMove; |
- ash::Shell::GetInstance()->cursor_manager()->SetCursor(cursor); |
+ UnlockAndSwitchCursor(cursor); |
} |
} |
@@ -141,7 +148,7 @@ void DragDropController::DragUpdate(aura::Window* target, |
void DragDropController::Drop(aura::Window* target, |
const aura::LocatedEvent& event) { |
- ash::Shell::GetInstance()->cursor_manager()->SetCursor(ui::kCursorPointer); |
+ UnlockAndSwitchCursor(ui::kCursorPointer); |
aura::client::DragDropDelegate* delegate = NULL; |
// We must guarantee that a target gets a OnDragEntered before Drop. WebKit |
@@ -170,7 +177,7 @@ void DragDropController::Drop(aura::Window* target, |
} |
void DragDropController::DragCancel() { |
- ash::Shell::GetInstance()->cursor_manager()->SetCursor(ui::kCursorPointer); |
+ UnlockAndSwitchCursor(ui::kCursorPointer); |
// |drag_window_| can be NULL if we have just started the drag and have not |
// received any DragUpdates, or, if the |drag_window_| gets destroyed during |
@@ -211,9 +218,6 @@ bool DragDropController::PreHandleMouseEvent(aura::Window* target, |
case ui::ET_MOUSE_RELEASED: |
Drop(target, *event); |
break; |
- case ui::ET_MOUSE_EXITED: |
- DragCancel(); |
- 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 |
@@ -292,6 +296,8 @@ void DragDropController::Cleanup() { |
drag_window_ = NULL; |
drag_data_ = NULL; |
drag_drop_in_progress_ = false; |
+ if (ash::Shell::GetInstance()->cursor_manager()->is_cursor_locked()) |
+ ash::Shell::GetInstance()->cursor_manager()->UnlockCursor(); |
} |
} // namespace internal |