OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ui/base/dragdrop/drop_target.h" | 5 #include "ui/base/dragdrop/drop_target.h" |
6 | 6 |
7 #include <shlobj.h> | 7 #include <shlobj.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 | 10 |
11 namespace ui { | 11 namespace ui { |
12 | 12 |
13 IDropTargetHelper* DropTarget::cached_drop_target_helper_ = NULL; | 13 IDropTargetHelper* DropTarget::cached_drop_target_helper_ = NULL; |
14 int32 DropTarget::drag_identity_ = 0; | |
15 | 14 |
16 DropTarget::DropTarget(HWND hwnd) | 15 DropTarget::DropTarget(HWND hwnd) |
17 : hwnd_(hwnd), | 16 : hwnd_(hwnd), |
18 suspended_(false), | 17 suspended_(false), |
19 ref_count_(0) { | 18 ref_count_(0) { |
20 DCHECK(hwnd); | 19 DCHECK(hwnd); |
21 HRESULT result = RegisterDragDrop(hwnd, this); | 20 HRESULT result = RegisterDragDrop(hwnd, this); |
22 DCHECK(SUCCEEDED(result)); | 21 DCHECK(SUCCEEDED(result)); |
23 } | 22 } |
24 | 23 |
(...skipping 23 matching lines...) Expand all Loading... |
48 drop_helper->DragEnter(GetHWND(), data_object, | 47 drop_helper->DragEnter(GetHWND(), data_object, |
49 reinterpret_cast<POINT*>(&cursor_position), *effect); | 48 reinterpret_cast<POINT*>(&cursor_position), *effect); |
50 } | 49 } |
51 | 50 |
52 // You can't drag and drop within the same HWND. | 51 // You can't drag and drop within the same HWND. |
53 if (suspended_) { | 52 if (suspended_) { |
54 *effect = DROPEFFECT_NONE; | 53 *effect = DROPEFFECT_NONE; |
55 return S_OK; | 54 return S_OK; |
56 } | 55 } |
57 | 56 |
58 // Update the drag identity, skipping 0. | |
59 if (++drag_identity_ == 0) | |
60 ++drag_identity_; | |
61 | |
62 current_data_object_ = data_object; | 57 current_data_object_ = data_object; |
63 POINT screen_pt = { cursor_position.x, cursor_position.y }; | 58 POINT screen_pt = { cursor_position.x, cursor_position.y }; |
64 *effect = OnDragEnter(current_data_object_, key_state, screen_pt, *effect); | 59 *effect = OnDragEnter(current_data_object_, key_state, screen_pt, *effect); |
65 return S_OK; | 60 return S_OK; |
66 } | 61 } |
67 | 62 |
68 HRESULT DropTarget::DragOver(DWORD key_state, | 63 HRESULT DropTarget::DragOver(DWORD key_state, |
69 POINTL cursor_position, | 64 POINTL cursor_position, |
70 DWORD* effect) { | 65 DWORD* effect) { |
71 // Tell the helper that we moved over it so it can update the drag image. | 66 // Tell the helper that we moved over it so it can update the drag image. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 } | 158 } |
164 | 159 |
165 DWORD DropTarget::OnDrop(IDataObject* data_object, | 160 DWORD DropTarget::OnDrop(IDataObject* data_object, |
166 DWORD key_state, | 161 DWORD key_state, |
167 POINT cursor_position, | 162 POINT cursor_position, |
168 DWORD effect) { | 163 DWORD effect) { |
169 return DROPEFFECT_NONE; | 164 return DROPEFFECT_NONE; |
170 } | 165 } |
171 | 166 |
172 } // namespace ui | 167 } // namespace ui |
OLD | NEW |