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

Side by Side Diff: views/widget/drop_target_gtk.cc

Issue 7015051: Re-land: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 7 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 | « views/view_unittest.cc ('k') | views/widget/native_widget.h » ('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) 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
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
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
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
OLDNEW
« no previous file with comments | « views/view_unittest.cc ('k') | views/widget/native_widget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698