Commit f48977fe authored by Alexander Larsson's avatar Alexander Larsson Committed by Alexander Larsson

Support alpha icons during DnD on composited screens. (#500084) Patch from

2008-02-13  Alexander Larsson  <alexl@redhat.com>

        * libnautilus-private/nautilus-icon-canvas-item.[ch]:
        * libnautilus-private/nautilus-icon-dnd.c:
	Support alpha icons during DnD on composited screens. (#500084)
	Patch from Alexander "weej" Jones


svn path=/trunk/; revision=13737
parent a608aabc
2008-02-13 Alexander Larsson <alexl@redhat.com>
* libnautilus-private/nautilus-icon-canvas-item.[ch]:
* libnautilus-private/nautilus-icon-dnd.c:
Support alpha icons during DnD on composited screens. (#500084)
Patch from Alexander "weej" Jones
2008-02-13 Alexander Larsson <alexl@redhat.com>
* libnautilus-private/nautilus-link.c:
......
......@@ -454,12 +454,12 @@ nautilus_icon_canvas_item_get_property (GObject *object,
GdkPixmap *
nautilus_icon_canvas_item_get_image (NautilusIconCanvasItem *item,
GdkBitmap **mask)
GdkBitmap **mask,
GdkColormap *colormap)
{
GdkPixmap *pixmap;
EelCanvas *canvas;
GdkScreen *screen;
GdkColormap *colormap;
GdkGC *gc;
int width, height;
int item_offset_x, item_offset_y;
......@@ -474,7 +474,6 @@ nautilus_icon_canvas_item_get_image (NautilusIconCanvasItem *item,
g_return_val_if_fail (NAUTILUS_IS_ICON_CANVAS_ITEM (item), NULL);
canvas = EEL_CANVAS_ITEM (item)->canvas;
colormap = gtk_widget_get_colormap (GTK_WIDGET (canvas));
screen = gdk_colormap_get_screen (colormap);
/* Assume we're updated so canvas item data is right */
......@@ -529,11 +528,14 @@ nautilus_icon_canvas_item_get_image (NautilusIconCanvasItem *item,
GDK_INTERP_BILINEAR, 255);
}
/* clear the pixmap */
cairo_t *cr;
cr = gdk_cairo_create (pixmap);
cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
cairo_paint (cr);
cairo_destroy (cr);
gc = gdk_gc_new (pixmap);
gdk_draw_rectangle (pixmap, GTK_WIDGET (canvas)->style->white_gc,
TRUE,
0, 0,
width, height);
gdk_draw_pixbuf (pixmap, gc, pixbuf,
0, 0, 0, 0,
gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf),
......
......@@ -62,7 +62,8 @@ GType nautilus_icon_canvas_item_get_type (void);
void nautilus_icon_canvas_item_set_image (NautilusIconCanvasItem *item,
GdkPixbuf *image);
GdkPixmap * nautilus_icon_canvas_item_get_image (NautilusIconCanvasItem *item,
GdkBitmap **mask);
GdkBitmap **mask,
GdkColormap *colormap);
void nautilus_icon_canvas_item_set_emblems (NautilusIconCanvasItem *item,
GList *emblem_pixbufs);
void nautilus_icon_canvas_item_set_show_stretch_handles (NautilusIconCanvasItem *item,
......
......@@ -1417,19 +1417,37 @@ drag_begin_callback (GtkWidget *widget,
gpointer data)
{
NautilusIconContainer *container;
GdkScreen *screen;
GdkColormap *colormap;
GdkPixmap *pixmap;
GdkBitmap *mask;
double x1, y1, x2, y2, winx, winy;
int x_offset, y_offset;
int start_x, start_y;
gboolean use_mask;
container = NAUTILUS_ICON_CONTAINER (widget);
screen = gtk_widget_get_screen (widget);
colormap = NULL;
if (gdk_screen_is_composited (screen)) {
colormap = gdk_screen_get_rgba_colormap (screen);
if (colormap != NULL) {
use_mask = FALSE;
}
}
/* Fall back on using the same colormap as the widget */
if (colormap == NULL) {
colormap = gtk_widget_get_colormap (widget);
use_mask = TRUE;
}
start_x = container->details->dnd_info->drag_info.start_x + gtk_adjustment_get_value (gtk_layout_get_hadjustment (GTK_LAYOUT (container)));
start_y = container->details->dnd_info->drag_info.start_y + gtk_adjustment_get_value (gtk_layout_get_vadjustment (GTK_LAYOUT (container)));
/* create a pixmap and mask to drag with */
pixmap = nautilus_icon_canvas_item_get_image (container->details->drag_icon->item, &mask);
pixmap = nautilus_icon_canvas_item_get_image (container->details->drag_icon->item, &mask, colormap);
/* we want to drag semi-transparent pixbufs, but X is too slow dealing with
stippled masks, so we had to remove the code; this comment is left as a memorial
......@@ -1444,8 +1462,8 @@ drag_begin_callback (GtkWidget *widget,
y_offset = start_y - winy;
gtk_drag_set_icon_pixmap (context,
gtk_widget_get_colormap (GTK_WIDGET (container)),
pixmap, mask,
colormap,
pixmap, (use_mask ? mask : NULL),
x_offset, y_offset);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment