From: Owen Taylor Date: Thu, 7 Nov 2002 22:27:22 +0000 (+0000) Subject: Don't try to use render if we can't get a picture for the drawable. (Fixes X-Git-Url: http://pileus.org/git/?a=commitdiff_plain;h=d2caca5e20afee7885eeab51791ef1e38cbe229e;p=~andy%2Fgtk Don't try to use render if we can't get a picture for the drawable. (Fixes Thu Nov 7 17:18:06 2002 Owen Taylor * gdk/x11/gdkdrawable-x11.c (gdk_x11_draw_pixbuf): Don't try to use render if we can't get a picture for the drawable. (Fixes #97220, reported by Jamie Zawinski) * gtk/gtkimage.c: Force requisition calculation when we get a expose prior to size_request(). (#91711, reported by Sven Neumann, debugging help from Matthias Clasen, Soeren Sandmann) --- diff --git a/ChangeLog b/ChangeLog index bed9bc1c8..5589d31eb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +Thu Nov 7 17:18:06 2002 Owen Taylor + + * gdk/x11/gdkdrawable-x11.c (gdk_x11_draw_pixbuf): + Don't try to use render if we can't get a picture for + the drawable. (Fixes #97220, reported by + Jamie Zawinski) + + * gtk/gtkimage.c: Force requisition calculation + when we get a expose prior to size_request(). + (#91711, reported by Sven Neumann, debugging + help from Matthias Clasen, Soeren Sandmann) + Thu Nov 7 16:45:54 2002 Owen Taylor * gdk/x11/gdkx.h: Fix misplaced display_grab()/display_ungrab(); diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index bed9bc1c8..5589d31eb 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,15 @@ +Thu Nov 7 17:18:06 2002 Owen Taylor + + * gdk/x11/gdkdrawable-x11.c (gdk_x11_draw_pixbuf): + Don't try to use render if we can't get a picture for + the drawable. (Fixes #97220, reported by + Jamie Zawinski) + + * gtk/gtkimage.c: Force requisition calculation + when we get a expose prior to size_request(). + (#91711, reported by Sven Neumann, debugging + help from Matthias Clasen, Soeren Sandmann) + Thu Nov 7 16:45:54 2002 Owen Taylor * gdk/x11/gdkx.h: Fix misplaced display_grab()/display_ungrab(); diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index bed9bc1c8..5589d31eb 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,15 @@ +Thu Nov 7 17:18:06 2002 Owen Taylor + + * gdk/x11/gdkdrawable-x11.c (gdk_x11_draw_pixbuf): + Don't try to use render if we can't get a picture for + the drawable. (Fixes #97220, reported by + Jamie Zawinski) + + * gtk/gtkimage.c: Force requisition calculation + when we get a expose prior to size_request(). + (#91711, reported by Sven Neumann, debugging + help from Matthias Clasen, Soeren Sandmann) + Thu Nov 7 16:45:54 2002 Owen Taylor * gdk/x11/gdkx.h: Fix misplaced display_grab()/display_ungrab(); diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index bed9bc1c8..5589d31eb 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,15 @@ +Thu Nov 7 17:18:06 2002 Owen Taylor + + * gdk/x11/gdkdrawable-x11.c (gdk_x11_draw_pixbuf): + Don't try to use render if we can't get a picture for + the drawable. (Fixes #97220, reported by + Jamie Zawinski) + + * gtk/gtkimage.c: Force requisition calculation + when we get a expose prior to size_request(). + (#91711, reported by Sven Neumann, debugging + help from Matthias Clasen, Soeren Sandmann) + Thu Nov 7 16:45:54 2002 Owen Taylor * gdk/x11/gdkx.h: Fix misplaced display_grab()/display_ungrab(); diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index bed9bc1c8..5589d31eb 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,15 @@ +Thu Nov 7 17:18:06 2002 Owen Taylor + + * gdk/x11/gdkdrawable-x11.c (gdk_x11_draw_pixbuf): + Don't try to use render if we can't get a picture for + the drawable. (Fixes #97220, reported by + Jamie Zawinski) + + * gtk/gtkimage.c: Force requisition calculation + when we get a expose prior to size_request(). + (#91711, reported by Sven Neumann, debugging + help from Matthias Clasen, Soeren Sandmann) + Thu Nov 7 16:45:54 2002 Owen Taylor * gdk/x11/gdkx.h: Fix misplaced display_grab()/display_ungrab(); diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index bed9bc1c8..5589d31eb 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,15 @@ +Thu Nov 7 17:18:06 2002 Owen Taylor + + * gdk/x11/gdkdrawable-x11.c (gdk_x11_draw_pixbuf): + Don't try to use render if we can't get a picture for + the drawable. (Fixes #97220, reported by + Jamie Zawinski) + + * gtk/gtkimage.c: Force requisition calculation + when we get a expose prior to size_request(). + (#91711, reported by Sven Neumann, debugging + help from Matthias Clasen, Soeren Sandmann) + Thu Nov 7 16:45:54 2002 Owen Taylor * gdk/x11/gdkx.h: Fix misplaced display_grab()/display_ungrab(); diff --git a/gdk/x11/gdkdrawable-x11.c b/gdk/x11/gdkdrawable-x11.c index 54db5a89c..7aed12ee9 100644 --- a/gdk/x11/gdkdrawable-x11.c +++ b/gdk/x11/gdkdrawable-x11.c @@ -1441,7 +1441,8 @@ gdk_x11_draw_pixbuf (GdkDrawable *drawable, if (format_type == FORMAT_NONE || !gdk_pixbuf_get_has_alpha (pixbuf) || - (dither == GDK_RGB_DITHER_MAX && gdk_drawable_get_depth (drawable) != 24)) + (dither == GDK_RGB_DITHER_MAX && gdk_drawable_get_depth (drawable) != 24) || + gdk_x11_drawable_get_picture (drawable) == None) { GdkDrawable *wrapper = GDK_DRAWABLE_IMPL_X11 (drawable)->wrapper; GDK_DRAWABLE_CLASS (parent_class)->draw_pixbuf (wrapper, gc, pixbuf, diff --git a/gtk/gtkimage.c b/gtk/gtkimage.c index e9505705a..9b25a9d87 100644 --- a/gtk/gtkimage.c +++ b/gtk/gtkimage.c @@ -45,6 +45,8 @@ static void gtk_image_size_request (GtkWidget *widget, static void gtk_image_destroy (GtkObject *object); static void gtk_image_clear (GtkImage *image); static void gtk_image_reset (GtkImage *image); +static void gtk_image_calc_size (GtkImage *image); + static void gtk_image_update_size (GtkImage *image, gint image_width, gint image_height); @@ -1227,6 +1229,14 @@ gtk_image_expose (GtkWidget *widget, misc = GTK_MISC (widget); area = event->area; + + /* For stock items and icon sets, we lazily calculate + * the size; we might get here between a queue_resize() + * and size_request() if something explicitely forces + * a redraw. + */ + if (widget->requisition.width == 0 && widget->requisition.height == 0) + gtk_image_calc_size (image); if (!gdk_rectangle_intersect (&area, &widget->allocation, &area)) return FALSE; @@ -1591,29 +1601,25 @@ gtk_image_reset (GtkImage *image) } static void -gtk_image_size_request (GtkWidget *widget, - GtkRequisition *requisition) +gtk_image_calc_size (GtkImage *image) { - GtkImage *image; + GtkWidget *widget = GTK_WIDGET (image); GdkPixbuf *pixbuf = NULL; - image = GTK_IMAGE (widget); - /* We update stock/icon set on every size request, because * the theme could have affected the size; for other kinds of * image, we just update the requisition when the image data * is set. */ - switch (image->storage_type) { case GTK_IMAGE_STOCK: - pixbuf = gtk_widget_render_icon (GTK_WIDGET (image), + pixbuf = gtk_widget_render_icon (widget, image->data.stock.stock_id, image->icon_size, NULL); break; - + case GTK_IMAGE_ICON_SET: pixbuf = gtk_icon_set_render_icon (image->data.icon_set.icon_set, widget->style, @@ -1630,11 +1636,22 @@ gtk_image_size_request (GtkWidget *widget, if (pixbuf) { - GTK_WIDGET (image)->requisition.width = gdk_pixbuf_get_width (pixbuf) + GTK_MISC (image)->xpad * 2; - GTK_WIDGET (image)->requisition.height = gdk_pixbuf_get_height (pixbuf) + GTK_MISC (image)->ypad * 2; + widget->requisition.width = gdk_pixbuf_get_width (pixbuf) + GTK_MISC (image)->xpad * 2; + widget->requisition.height = gdk_pixbuf_get_height (pixbuf) + GTK_MISC (image)->ypad * 2; g_object_unref (pixbuf); } +} + +static void +gtk_image_size_request (GtkWidget *widget, + GtkRequisition *requisition) +{ + GtkImage *image; + + image = GTK_IMAGE (widget); + + gtk_image_calc_size (image); /* Chain up to default that simply reads current requisition */ GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition); @@ -1651,5 +1668,3 @@ gtk_image_update_size (GtkImage *image, if (GTK_WIDGET_VISIBLE (image)) gtk_widget_queue_resize (GTK_WIDGET (image)); } - -