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

Side by Side Diff: ash/drag_drop/drag_drop_controller.cc

Issue 9463003: aura-x11: Add custom web cursor support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ash/shell.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_image_view.h" 7 #include "ash/drag_drop/drag_image_view.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "ui/aura/client/drag_drop_delegate.h" 10 #include "ui/aura/client/drag_drop_delegate.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 delegate->OnDragEntered(e); 107 delegate->OnDragEntered(e);
108 } 108 }
109 } else { 109 } else {
110 if ((delegate = aura::client::GetDragDropDelegate(drag_window_))) { 110 if ((delegate = aura::client::GetDragDropDelegate(drag_window_))) {
111 aura::DropTargetEvent e(*drag_data_, 111 aura::DropTargetEvent e(*drag_data_,
112 event.location(), 112 event.location(),
113 event.root_location(), 113 event.root_location(),
114 drag_operation_); 114 drag_operation_);
115 int op = delegate->OnDragUpdated(e); 115 int op = delegate->OnDragUpdated(e);
116 gfx::NativeCursor cursor = (op == ui::DragDropTypes::DRAG_NONE)? 116 gfx::NativeCursor cursor = (op == ui::DragDropTypes::DRAG_NONE)?
117 aura::kCursorMove : aura::kCursorHand; 117 ui::kCursorMove : ui::kCursorHand;
118 Shell::GetRootWindow()->SetCursor(cursor); 118 Shell::GetRootWindow()->SetCursor(cursor);
119 } 119 }
120 } 120 }
121 121
122 DCHECK(drag_image_.get()); 122 DCHECK(drag_image_.get());
123 if (drag_image_->visible()) { 123 if (drag_image_->visible()) {
124 drag_image_->SetScreenPosition( 124 drag_image_->SetScreenPosition(
125 event.root_location().Add(kDragDropWidgetOffset)); 125 event.root_location().Add(kDragDropWidgetOffset));
126 } 126 }
127 } 127 }
128 128
129 void DragDropController::Drop(aura::Window* target, 129 void DragDropController::Drop(aura::Window* target,
130 const aura::LocatedEvent& event) { 130 const aura::LocatedEvent& event) {
131 Shell::GetRootWindow()->SetCursor(aura::kCursorPointer); 131 Shell::GetRootWindow()->SetCursor(ui::kCursorPointer);
132 aura::client::DragDropDelegate* delegate = NULL; 132 aura::client::DragDropDelegate* delegate = NULL;
133 133
134 // |drag_window_| can be NULL if we have just started the drag and have not 134 // |drag_window_| can be NULL if we have just started the drag and have not
135 // received any DragUpdates, or, if the |drag_window_| gets destroyed during 135 // received any DragUpdates, or, if the |drag_window_| gets destroyed during
136 // a drag/drop. Otherwise, target should be equal to the |drag_window_|. 136 // a drag/drop. Otherwise, target should be equal to the |drag_window_|.
137 DCHECK(target == drag_window_ || !drag_window_); 137 DCHECK(target == drag_window_ || !drag_window_);
138 if ((delegate = aura::client::GetDragDropDelegate(target))) { 138 if ((delegate = aura::client::GetDragDropDelegate(target))) {
139 aura::DropTargetEvent e( 139 aura::DropTargetEvent e(
140 *drag_data_, event.location(), event.root_location(), drag_operation_); 140 *drag_data_, event.location(), event.root_location(), drag_operation_);
141 drag_operation_ = delegate->OnPerformDrop(e); 141 drag_operation_ = delegate->OnPerformDrop(e);
142 if (drag_operation_ == 0) 142 if (drag_operation_ == 0)
143 StartCanceledAnimation(); 143 StartCanceledAnimation();
144 else 144 else
145 drag_image_.reset(); 145 drag_image_.reset();
146 } else { 146 } else {
147 drag_image_.reset(); 147 drag_image_.reset();
148 } 148 }
149 149
150 Cleanup(); 150 Cleanup();
151 if (should_block_during_drag_drop_) 151 if (should_block_during_drag_drop_)
152 MessageLoop::current()->Quit(); 152 MessageLoop::current()->Quit();
153 } 153 }
154 154
155 void DragDropController::DragCancel() { 155 void DragDropController::DragCancel() {
156 Shell::GetRootWindow()->SetCursor(aura::kCursorPointer); 156 Shell::GetRootWindow()->SetCursor(ui::kCursorPointer);
157 aura::client::DragDropDelegate* delegate = NULL; 157 aura::client::DragDropDelegate* delegate = NULL;
158 if ((delegate = aura::client::GetDragDropDelegate(drag_window_))) { 158 if ((delegate = aura::client::GetDragDropDelegate(drag_window_))) {
159 delegate->OnDragExited(); 159 delegate->OnDragExited();
160 } 160 }
161 Cleanup(); 161 Cleanup();
162 drag_operation_ = 0; 162 drag_operation_ = 0;
163 StartCanceledAnimation(); 163 StartCanceledAnimation();
164 if (should_block_during_drag_drop_) 164 if (should_block_during_drag_drop_)
165 MessageLoop::current()->Quit(); 165 MessageLoop::current()->Quit();
166 } 166 }
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 void DragDropController::Cleanup() { 259 void DragDropController::Cleanup() {
260 if (drag_window_) 260 if (drag_window_)
261 drag_window_->RemoveObserver(this); 261 drag_window_->RemoveObserver(this);
262 drag_window_ = NULL; 262 drag_window_ = NULL;
263 drag_data_ = NULL; 263 drag_data_ = NULL;
264 drag_drop_in_progress_ = false; 264 drag_drop_in_progress_ = false;
265 } 265 }
266 266
267 } // namespace internal 267 } // namespace internal
268 } // namespace ash 268 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698