From b407d73073527d3ffe5fe2dbe715c480ef9a2ca7 Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Thu, 7 Nov 2002 22:39:56 +0000 Subject: [PATCH] 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) --- ChangeLog | 12 ++++++++++++ ChangeLog.pre-2-10 | 12 ++++++++++++ ChangeLog.pre-2-2 | 12 ++++++++++++ ChangeLog.pre-2-4 | 12 ++++++++++++ ChangeLog.pre-2-6 | 12 ++++++++++++ ChangeLog.pre-2-8 | 12 ++++++++++++ gdk/x11/gdkdrawable-x11.c | 3 ++- gtk/gtkimage.c | 35 +++++++++++++++++++++++++---------- 8 files changed, 99 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 21572efe2e..21bfbc6eb8 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 14:59:43 2002 Owen Taylor * tests/testcalendar.c: Back out last change, should have gone in diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 21572efe2e..21bfbc6eb8 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 14:59:43 2002 Owen Taylor * tests/testcalendar.c: Back out last change, should have gone in diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 21572efe2e..21bfbc6eb8 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 14:59:43 2002 Owen Taylor * tests/testcalendar.c: Back out last change, should have gone in diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 21572efe2e..21bfbc6eb8 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 14:59:43 2002 Owen Taylor * tests/testcalendar.c: Back out last change, should have gone in diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 21572efe2e..21bfbc6eb8 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 14:59:43 2002 Owen Taylor * tests/testcalendar.c: Back out last change, should have gone in diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 21572efe2e..21bfbc6eb8 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 14:59:43 2002 Owen Taylor * tests/testcalendar.c: Back out last change, should have gone in diff --git a/gdk/x11/gdkdrawable-x11.c b/gdk/x11/gdkdrawable-x11.c index 147a356f75..d86c18418b 100644 --- a/gdk/x11/gdkdrawable-x11.c +++ b/gdk/x11/gdkdrawable-x11.c @@ -1285,7 +1285,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 8469713e7f..5b3d0c6a15 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); @@ -1225,6 +1227,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; @@ -1589,29 +1599,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, @@ -1633,7 +1639,18 @@ gtk_image_size_request (GtkWidget *widget, g_object_unref (G_OBJECT (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); } @@ -1649,5 +1666,3 @@ gtk_image_update_size (GtkImage *image, if (GTK_WIDGET_VISIBLE (image)) gtk_widget_queue_resize (GTK_WIDGET (image)); } - -