[libwnck] xutils: Use beautiful code for getting icon pixbufs from X



commit e1001b4634990f8f84605d3309afe852ad643303
Author: Benjamin Otte <otte redhat com>
Date:   Wed Jan 19 22:11:16 2011 +0100

    xutils: Use beautiful code for getting icon pixbufs from X
    
    After 20 minutes of discussion about code beauty in #cairo, this
    approach was agreed to be the most beautiful and easy to understand.
    Don't you just love IRC?

 libwnck/xutils.c |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)
---
diff --git a/libwnck/xutils.c b/libwnck/xutils.c
index 7213be7..394c1d5 100644
--- a/libwnck/xutils.c
+++ b/libwnck/xutils.c
@@ -1670,29 +1670,29 @@ try_pixmap_and_mask (Pixmap      src_pixmap,
    */
   if (cairo_surface_get_content (surface) & CAIRO_CONTENT_ALPHA)
     {
+      cairo_push_group (cr);
+
       /* black background */
       cairo_set_source_rgb (cr, 0, 0, 0);
       cairo_paint (cr);
       /* mask with white foreground */
       cairo_set_source_rgb (cr, 1, 1, 1);
       cairo_mask_surface (cr, surface, 0, 0);
+
+      cairo_pop_group_to_source (cr);
     }
   else
-    {
-      cairo_set_source_surface (cr, surface, 0, 0);
-      cairo_paint (cr);
-    }
-
-  cairo_surface_destroy (surface);
+    cairo_set_source_surface (cr, surface, 0, 0);
 
   if (mask_surface)
     {
-      cairo_set_operator (cr, CAIRO_OPERATOR_DEST_IN);
-      cairo_set_source_surface (cr, mask_surface, 0, 0);
-      cairo_paint (cr);
+      cairo_mask_surface (cr, mask_surface, 0, 0);
       cairo_surface_destroy (mask_surface);
     }
+  else
+    cairo_paint (cr);
 
+  cairo_surface_destroy (surface);
   cairo_destroy (cr);
 
   unscaled = gdk_pixbuf_get_from_surface (image,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]