OLD | NEW |
---|---|
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 "content/browser/web_contents/web_drag_source_gtk.h" | 5 #include "content/browser/web_contents/web_drag_source_gtk.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/nix/mime_util_xdg.h" | 10 #include "base/nix/mime_util_xdg.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
157 // No-op. | 157 // No-op. |
158 } | 158 } |
159 | 159 |
160 void WebDragSourceGtk::DidProcessEvent(GdkEvent* event) { | 160 void WebDragSourceGtk::DidProcessEvent(GdkEvent* event) { |
161 if (event->type != GDK_MOTION_NOTIFY) | 161 if (event->type != GDK_MOTION_NOTIFY) |
162 return; | 162 return; |
163 | 163 |
164 GdkEventMotion* event_motion = reinterpret_cast<GdkEventMotion*>(event); | 164 GdkEventMotion* event_motion = reinterpret_cast<GdkEventMotion*>(event); |
165 gfx::Point client = ui::ClientPoint(GetContentNativeView()); | 165 gfx::Point client = ui::ClientPoint(GetContentNativeView()); |
166 | 166 |
167 if (GetRenderViewHost()) { | 167 if (GetRenderViewHost()) { |
Fady Samuel
2013/04/09 20:49:12
This guard seems weird...if (web_contents_) seems
mthiesse
2013/04/18 18:02:03
Done.
| |
168 GetRenderViewHost()->DragSourceMovedTo( | 168 web_contents_->DragSourceMovedTo( |
169 client.x(), client.y(), | 169 client.x(), client.y(), |
170 static_cast<int>(event_motion->x_root), | 170 static_cast<int>(event_motion->x_root), |
171 static_cast<int>(event_motion->y_root)); | 171 static_cast<int>(event_motion->y_root)); |
172 } | 172 } |
173 } | 173 } |
174 | 174 |
175 void WebDragSourceGtk::OnDragDataGet(GtkWidget* sender, | 175 void WebDragSourceGtk::OnDragDataGet(GtkWidget* sender, |
176 GdkDragContext* context, | 176 GdkDragContext* context, |
177 GtkSelectionData* selection_data, | 177 GtkSelectionData* selection_data, |
178 guint target_type, | 178 guint target_type, |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
293 } | 293 } |
294 | 294 |
295 gboolean WebDragSourceGtk::OnDragFailed(GtkWidget* sender, | 295 gboolean WebDragSourceGtk::OnDragFailed(GtkWidget* sender, |
296 GdkDragContext* context, | 296 GdkDragContext* context, |
297 GtkDragResult result) { | 297 GtkDragResult result) { |
298 drag_failed_ = true; | 298 drag_failed_ = true; |
299 | 299 |
300 gfx::Point root = ui::ScreenPoint(GetContentNativeView()); | 300 gfx::Point root = ui::ScreenPoint(GetContentNativeView()); |
301 gfx::Point client = ui::ClientPoint(GetContentNativeView()); | 301 gfx::Point client = ui::ClientPoint(GetContentNativeView()); |
302 | 302 |
303 if (GetRenderViewHost()) { | 303 if (GetRenderViewHost()) { |
Fady Samuel
2013/04/09 20:49:12
This guard seems weird...if (web_contents_) seems
mthiesse
2013/04/18 18:02:03
Done.
| |
304 GetRenderViewHost()->DragSourceEndedAt( | 304 web_contents_->DragSourceEndedAt( |
305 client.x(), client.y(), root.x(), root.y(), | 305 client.x(), client.y(), root.x(), root.y(), |
306 WebDragOperationNone); | 306 WebDragOperationNone); |
307 } | 307 } |
308 | 308 |
309 // Let the native failure animation run. | 309 // Let the native failure animation run. |
310 return FALSE; | 310 return FALSE; |
311 } | 311 } |
312 | 312 |
313 void WebDragSourceGtk::OnDragBegin(GtkWidget* sender, | 313 void WebDragSourceGtk::OnDragBegin(GtkWidget* sender, |
314 GdkDragContext* drag_context) { | 314 GdkDragContext* drag_context) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
365 | 365 |
366 if (!download_url_.is_empty()) { | 366 if (!download_url_.is_empty()) { |
367 gdk_property_delete(drag_context->source_window, | 367 gdk_property_delete(drag_context->source_window, |
368 ui::GetAtomForTarget(ui::DIRECT_SAVE_FILE)); | 368 ui::GetAtomForTarget(ui::DIRECT_SAVE_FILE)); |
369 } | 369 } |
370 | 370 |
371 if (!drag_failed_) { | 371 if (!drag_failed_) { |
372 gfx::Point root = ui::ScreenPoint(GetContentNativeView()); | 372 gfx::Point root = ui::ScreenPoint(GetContentNativeView()); |
373 gfx::Point client = ui::ClientPoint(GetContentNativeView()); | 373 gfx::Point client = ui::ClientPoint(GetContentNativeView()); |
374 | 374 |
375 if (GetRenderViewHost()) { | 375 if (GetRenderViewHost()) { |
Fady Samuel
2013/04/09 20:49:12
This guard seems weird...if (web_contents_) seems
mthiesse
2013/04/18 18:02:03
Done.
| |
376 GetRenderViewHost()->DragSourceEndedAt( | 376 web_contents_->DragSourceEndedAt( |
377 client.x(), client.y(), root.x(), root.y(), | 377 client.x(), client.y(), root.x(), root.y(), |
378 GdkDragActionToWebDragOp(drag_context->action)); | 378 GdkDragActionToWebDragOp(drag_context->action)); |
379 } | 379 } |
380 } | 380 } |
381 | 381 |
382 web_contents_->SystemDragEnded(); | 382 web_contents_->SystemDragEnded(); |
383 | 383 |
384 drop_data_.reset(); | 384 drop_data_.reset(); |
385 drag_context_ = NULL; | 385 drag_context_ = NULL; |
386 } | 386 } |
(...skipping 13 matching lines...) Expand all Loading... | |
400 cairo_clip(cr); | 400 cairo_clip(cr); |
401 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); | 401 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
402 gdk_cairo_set_source_pixbuf(cr, drag_pixbuf_, 0, 0); | 402 gdk_cairo_set_source_pixbuf(cr, drag_pixbuf_, 0, 0); |
403 cairo_paint(cr); | 403 cairo_paint(cr); |
404 cairo_destroy(cr); | 404 cairo_destroy(cr); |
405 | 405 |
406 return TRUE; | 406 return TRUE; |
407 } | 407 } |
408 | 408 |
409 } // namespace content | 409 } // namespace content |
OLD | NEW |