From ecf812db833db5bf663c5e6b2fa02856f890a47e Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 20 Sep 2010 20:44:23 +0200 Subject: [PATCH] frames.c: Do not create pixmaps when there's nothing to draw https://bugzilla.gnome.org/show_bug.cgi?id=630203 Take advantage of existing handling for CachedFramePiece.piece == NULL to avoid generating pixmaps when width/height are 0 --- src/ui/frames.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/ui/frames.c b/src/ui/frames.c index e2efea645..bb37c2006 100644 --- a/src/ui/frames.c +++ b/src/ui/frames.c @@ -2115,13 +2115,17 @@ generate_pixmap (MetaFrames *frames, MetaRegion *region; GdkPixmap *result; + /* do not create a pixmap for nonexisting areas */ + if (rect.width <= 0 || rect.height <= 0) + return NULL; + rectangle.x = rect.x; rectangle.y = rect.y; - rectangle.width = MAX (rect.width, 1); - rectangle.height = MAX (rect.height, 1); + rectangle.width = rect.width; + rectangle.height = rect.height; result = gdk_pixmap_new (frame->window, - rectangle.width, rectangle.height, -1); + rect.width, rect.height, -1); clear_backing (result, frame->window, rectangle.x, rectangle.y); @@ -2200,6 +2204,8 @@ populate_cache (MetaFrames *frames, for (i = 0; i < 4; i++) { CachedFramePiece *piece = &pixels->piece[i]; + /* generate_pixmap() returns NULL for 0 width/height pieces, but + * does so cheaply so we don't need to cache the NULL return */ if (!piece->pixmap) piece->pixmap = generate_pixmap (frames, frame, piece->rect); }