[Xfce4-commits] <xfdesktop:master> don't paint more than is necessary

Brian J. Tarricone brian at tarricone.org
Sat Aug 22 10:56:01 CEST 2009


Updating branch refs/heads/master
         to b20444e8036ee973f1042bae67e3c6b21a080b61 (commit)
       from e4180db7a4813014f5c40dfdd21b74671db1f56f (commit)

commit b20444e8036ee973f1042bae67e3c6b21a080b61
Author: Brian J. Tarricone <brian at tarricone.org>
Date:   Sat Aug 22 01:54:30 2009 -0700

    don't paint more than is necessary

 src/xfdesktop-icon-view.c |   30 +++++++++++++++++++++---------
 1 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/src/xfdesktop-icon-view.c b/src/xfdesktop-icon-view.c
index 69169e8..3cb3bda 100644
--- a/src/xfdesktop-icon-view.c
+++ b/src/xfdesktop-icon-view.c
@@ -1793,19 +1793,26 @@ xfdesktop_icon_view_expose(GtkWidget *widget,
                 continue;
             }
 
+            cairo_save(cr);
+
+            /* paint the inner rubber band area.  we clip to the
+             * rectangle in order to properly handle the border below */
             gdk_cairo_rectangle(cr, &intersect);
+            cairo_clip_preserve(cr);
             cairo_fill(cr);
+
+            /* paint whatever part of the rubber band border is inside
+             * this rectangle */
+            gdk_cairo_set_source_color(cr, icon_view->priv->selection_box_color);
+            cairo_rectangle(cr, icon_view->priv->band_rect.x + 0.5,
+                            icon_view->priv->band_rect.y + 0.5,
+                            icon_view->priv->band_rect.width - 1,
+                            icon_view->priv->band_rect.height - 1);
+            cairo_stroke(cr);
+
+            cairo_restore(cr);
         }
 
-        /* paint the border with full opacity; to avoid annoying calculations,
-         * we'll just paint the entire border even if it's not in the exposed
-         * region */
-        gdk_cairo_set_source_color(cr, icon_view->priv->selection_box_color);
-        cairo_rectangle(cr, icon_view->priv->band_rect.x + 0.5,
-                        icon_view->priv->band_rect.y + 0.5,
-                        icon_view->priv->band_rect.width - 1,
-                        icon_view->priv->band_rect.height - 1);
-        cairo_stroke(cr);
         cairo_destroy(cr);
     }
 
@@ -2463,6 +2470,11 @@ xfdesktop_paint_rounded_box(XfdesktopIconView *icon_view,
                               style->base[state].blue / 65535.,
                               alpha);
 
+        /* restrict painting to expose area */
+        cairo_rectangle(cr, expose_area->x, expose_area->y,
+                        expose_area->width, expose_area->height);
+        cairo_clip(cr);
+
         if(label_radius < 0.1) {
             cairo_rectangle(cr, box_area.x, box_area.y,
                             box_area.width, box_area.height);



More information about the Xfce4-commits mailing list