[cairo-commit] cairo-gtk-engine/src caligula-style.c,1.6,1.7

Owen Taylor commit at pdx.freedesktop.org
Sat Feb 12 18:23:41 PST 2005


Committed by: otaylor

Update of /cvs/cairo/cairo-gtk-engine/src
In directory gabe:/tmp/cvs-serv30977/src

Modified Files:
	caligula-style.c 
Log Message:
2005-02-12  Owen Taylor  <otaylor at redhat.com>

        * src/caligula-style.c: Clip drawing to the area passed in.
        Catch the weird drawing window background before mapping
        to allow setting the bg pixmap and ignore it.


Index: caligula-style.c
===================================================================
RCS file: /cvs/cairo/cairo-gtk-engine/src/caligula-style.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- caligula-style.c	11 Feb 2005 15:52:00 -0000	1.6
+++ caligula-style.c	13 Feb 2005 02:23:39 -0000	1.7
@@ -38,16 +38,18 @@
 static GtkStyleClass *caligula_style_parent_class;
 
 static cairo_t *
-caligula_begin_paint (GdkDrawable *window, gint *x_offset, gint *y_offset)
+caligula_begin_paint (GdkDrawable  *window,
+		      GdkRectangle *area)
 {
     Display *dpy;
     Drawable xid;
     GdkDrawable *drawable;
     cairo_t *cr;
+    int x_offset, y_offset;
   
     if (GDK_IS_WINDOW (window))
 	gdk_window_get_internal_paint_info (window, &drawable,
-					    x_offset, y_offset);
+					    &x_offset, &y_offset);
     else
 	drawable = window;
 
@@ -58,7 +60,13 @@
     cairo_set_target_drawable (cr, dpy, xid);
 
     if (GDK_IS_WINDOW (window))
-	cairo_translate (cr, -*x_offset, -*y_offset);
+	cairo_translate (cr, - x_offset, - y_offset);
+
+    if (area) {
+	cairo_rectangle (cr, area->x, area->y, area->width, area->height);
+	cairo_clip (cr);
+	cairo_new_path (cr);
+    }
 
     return cr;
 }
@@ -83,9 +91,8 @@
 		      int            height)
 {
     cairo_t *cr;
-    int x_offset, y_offset;
 
-    cr = caligula_begin_paint (window, &x_offset, &y_offset);
+    cr = caligula_begin_paint (window, area);
 
     if (shadow_type == GTK_SHADOW_IN) {
 	caligula_draw_shadowed_inset_box (cr, x, y, width, height,
@@ -114,12 +121,11 @@
 		   int            height)
 { 
     cairo_t *cr;
-    int x_offset, y_offset;
     CaligulaRcStyle *rc_style = CALIGULA_RC_STYLE (style->rc_style);
 
     caligula_srand ((unsigned)widget);
 
-    cr = caligula_begin_paint (window, &x_offset, &y_offset);
+    cr = caligula_begin_paint (window, area);
 
     switch (rc_style->drawing_style) {
     case CALIGULA_DRAWING_STYLE_SKETCHY:
@@ -146,11 +152,16 @@
     cairo_pattern_t *pattern;
     cairo_t *cr;
     int width, height;
-    int x_offset, y_offset;
+
+    /* GtkWindow paints out of realize() to allow the
+     * theme to set the window background pixmap
+     */
+    if (!GTK_WIDGET_MAPPED (widget))
+	return;
     
     gdk_drawable_get_size (window, &width, &height);
 
-    cr = caligula_begin_paint (window, &x_offset, &y_offset);
+    cr = caligula_begin_paint (window, area);
 
     pattern = cairo_pattern_create_linear (0, 0, 0, height);
     if (pattern) {




More information about the cairo-commit mailing list