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 "views/widget/drop_target_gtk.h" | 5 #include "views/widget/drop_target_gtk.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 | 160 |
161 gboolean DropTargetGtk::OnDragDrop(GdkDragContext* context, | 161 gboolean DropTargetGtk::OnDragDrop(GdkDragContext* context, |
162 gint x, | 162 gint x, |
163 gint y, | 163 gint y, |
164 guint time) { | 164 guint time) { |
165 received_drop_ = true; | 165 received_drop_ = true; |
166 OnDragMotion(context, x, y, time); | 166 OnDragMotion(context, x, y, time); |
167 if (!pending_view_) { | 167 if (!pending_view_) { |
168 // User isn't over a view, no drop can occur. | 168 // User isn't over a view, no drop can occur. |
169 static_cast<WidgetGtk*>( | 169 static_cast<WidgetGtk*>( |
170 helper_.root_view()->GetWidget())->ResetDropTarget(); | 170 helper_.root_view()->GetWidget()->native_widget())->ResetDropTarget(); |
171 // WARNING: we've been deleted. | 171 // WARNING: we've been deleted. |
172 return FALSE; | 172 return FALSE; |
173 } | 173 } |
174 | 174 |
175 if (!waiting_for_data_) { | 175 if (!waiting_for_data_) { |
176 // We've got all the data now. | 176 // We've got all the data now. |
177 FinishDrop(context, x, y, time); | 177 FinishDrop(context, x, y, time); |
178 // WARNING: we've been deleted. | 178 // WARNING: we've been deleted. |
179 return TRUE; | 179 return TRUE; |
180 } | 180 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 int drag_operation = ui::DragDropTypes::GdkDragActionToDragOperation( | 239 int drag_operation = ui::DragDropTypes::GdkDragActionToDragOperation( |
240 context->actions); | 240 context->actions); |
241 drag_operation = helper_.OnDrop(*data_, root_view_location, | 241 drag_operation = helper_.OnDrop(*data_, root_view_location, |
242 drag_operation); | 242 drag_operation); |
243 GdkDragAction gdk_action = | 243 GdkDragAction gdk_action = |
244 static_cast<GdkDragAction>( | 244 static_cast<GdkDragAction>( |
245 ui::DragDropTypes::DragOperationToGdkDragAction(drag_operation)); | 245 ui::DragDropTypes::DragOperationToGdkDragAction(drag_operation)); |
246 gtk_drag_finish(context, gdk_action != 0, (gdk_action & GDK_ACTION_MOVE), | 246 gtk_drag_finish(context, gdk_action != 0, (gdk_action & GDK_ACTION_MOVE), |
247 time); | 247 time); |
248 | 248 |
249 static_cast<WidgetGtk*>(helper_.root_view()->GetWidget())->ResetDropTarget(); | 249 static_cast<WidgetGtk*>(helper_.root_view()->GetWidget()->native_widget())-> |
| 250 ResetDropTarget(); |
250 // WARNING: we've been deleted. | 251 // WARNING: we've been deleted. |
251 } | 252 } |
252 | 253 |
253 void DropTargetGtk::IntersectFormats(int f1, const std::set<GdkAtom>& cf1, | 254 void DropTargetGtk::IntersectFormats(int f1, const std::set<GdkAtom>& cf1, |
254 int* f2, std::set<GdkAtom>* cf2) { | 255 int* f2, std::set<GdkAtom>* cf2) { |
255 *f2 = (*f2 & f1); | 256 *f2 = (*f2 & f1); |
256 std::set<GdkAtom> cf; | 257 std::set<GdkAtom> cf; |
257 std::set_intersection( | 258 std::set_intersection( |
258 cf1.begin(), cf1.end(), cf2->begin(), cf2->end(), | 259 cf1.begin(), cf1.end(), cf2->begin(), cf2->end(), |
259 std::insert_iterator<std::set<GdkAtom> >(cf, cf.begin())); | 260 std::insert_iterator<std::set<GdkAtom> >(cf, cf.begin())); |
260 cf.swap(*cf2); | 261 cf.swap(*cf2); |
261 } | 262 } |
262 | 263 |
263 void DropTargetGtk::RequestFormats(GdkDragContext* context, | 264 void DropTargetGtk::RequestFormats(GdkDragContext* context, |
264 int formats, | 265 int formats, |
265 const std::set<GdkAtom>& custom_formats, | 266 const std::set<GdkAtom>& custom_formats, |
266 guint time) { | 267 guint time) { |
267 GtkWidget* widget = | 268 GtkWidget* widget = static_cast<WidgetGtk*>(helper_.root_view()->GetWidget()-> |
268 static_cast<WidgetGtk*>(helper_.root_view()->GetWidget())-> | 269 native_widget())->window_contents(); |
269 window_contents(); | |
270 | 270 |
271 const std::set<GdkAtom>& known_formats = | 271 const std::set<GdkAtom>& known_formats = |
272 data_provider().known_custom_formats(); | 272 data_provider().known_custom_formats(); |
273 if ((formats & OSExchangeData::STRING) != 0 && | 273 if ((formats & OSExchangeData::STRING) != 0 && |
274 (requested_formats_ & OSExchangeData::STRING) == 0) { | 274 (requested_formats_ & OSExchangeData::STRING) == 0) { |
275 requested_formats_ |= OSExchangeData::STRING; | 275 requested_formats_ |= OSExchangeData::STRING; |
276 if (known_formats.count(gdk_atom_intern("UTF8_STRING", false))) { | 276 if (known_formats.count(gdk_atom_intern("UTF8_STRING", false))) { |
277 gtk_drag_get_data(widget, context, | 277 gtk_drag_get_data(widget, context, |
278 gdk_atom_intern("UTF8_STRING", false), time); | 278 gdk_atom_intern("UTF8_STRING", false), time); |
279 } else if (known_formats.count(gdk_atom_intern("text/plain;charset=utf-8", | 279 } else if (known_formats.count(gdk_atom_intern("text/plain;charset=utf-8", |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 gtk_drag_get_data(widget, context, *i, time); | 320 gtk_drag_get_data(widget, context, *i, time); |
321 } | 321 } |
322 } | 322 } |
323 } | 323 } |
324 | 324 |
325 OSExchangeDataProviderGtk& DropTargetGtk::data_provider() const { | 325 OSExchangeDataProviderGtk& DropTargetGtk::data_provider() const { |
326 return static_cast<OSExchangeDataProviderGtk&>(data_->provider()); | 326 return static_cast<OSExchangeDataProviderGtk&>(data_->provider()); |
327 } | 327 } |
328 | 328 |
329 } // namespace views | 329 } // namespace views |
OLD | NEW |