| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/gtk/tab_contents_drag_source.h" | 5 #include "chrome/browser/gtk/tab_contents_drag_source.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "app/gtk_dnd_util.h" | 9 #include "app/gtk_dnd_util.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 reinterpret_cast<const guchar*>( | 312 reinterpret_cast<const guchar*>( |
| 313 generated_download_file_name.value().c_str()), | 313 generated_download_file_name.value().c_str()), |
| 314 generated_download_file_name.value().length()); | 314 generated_download_file_name.value().length()); |
| 315 } | 315 } |
| 316 | 316 |
| 317 if (drag_pixbuf_) { | 317 if (drag_pixbuf_) { |
| 318 gtk_widget_set_size_request(drag_icon_, | 318 gtk_widget_set_size_request(drag_icon_, |
| 319 gdk_pixbuf_get_width(drag_pixbuf_), | 319 gdk_pixbuf_get_width(drag_pixbuf_), |
| 320 gdk_pixbuf_get_height(drag_pixbuf_)); | 320 gdk_pixbuf_get_height(drag_pixbuf_)); |
| 321 | 321 |
| 322 GdkScreen* screen = gtk_widget_get_screen(drag_icon_); | 322 // We only need to do this once. |
| 323 GdkColormap* rgba = gdk_screen_get_rgba_colormap(screen); | 323 if (!GTK_WIDGET_REALIZED(drag_icon_)) { |
| 324 if (rgba) | 324 GdkScreen* screen = gtk_widget_get_screen(drag_icon_); |
| 325 gtk_widget_set_colormap(drag_icon_, rgba); | 325 GdkColormap* rgba = gdk_screen_get_rgba_colormap(screen); |
| 326 if (rgba) |
| 327 gtk_widget_set_colormap(drag_icon_, rgba); |
| 328 } |
| 326 | 329 |
| 327 gtk_drag_set_icon_widget(drag_context, drag_icon_, | 330 gtk_drag_set_icon_widget(drag_context, drag_icon_, |
| 328 image_offset_.x(), image_offset_.y()); | 331 image_offset_.x(), image_offset_.y()); |
| 329 } | 332 } |
| 330 } | 333 } |
| 331 | 334 |
| 332 void TabContentsDragSource::OnDragEnd(GtkWidget* sender, | 335 void TabContentsDragSource::OnDragEnd(GtkWidget* sender, |
| 333 GdkDragContext* drag_context) { | 336 GdkDragContext* drag_context) { |
| 334 if (drag_pixbuf_) { | 337 if (drag_pixbuf_) { |
| 335 g_object_unref(drag_pixbuf_); | 338 g_object_unref(drag_pixbuf_); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 cairo_t* cr = gdk_cairo_create(event->window); | 373 cairo_t* cr = gdk_cairo_create(event->window); |
| 371 gdk_cairo_rectangle(cr, &event->area); | 374 gdk_cairo_rectangle(cr, &event->area); |
| 372 cairo_clip(cr); | 375 cairo_clip(cr); |
| 373 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); | 376 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
| 374 gdk_cairo_set_source_pixbuf(cr, drag_pixbuf_, 0, 0); | 377 gdk_cairo_set_source_pixbuf(cr, drag_pixbuf_, 0, 0); |
| 375 cairo_paint(cr); | 378 cairo_paint(cr); |
| 376 cairo_destroy(cr); | 379 cairo_destroy(cr); |
| 377 | 380 |
| 378 return TRUE; | 381 return TRUE; |
| 379 } | 382 } |
| OLD | NEW |