]> Pileus Git - ~andy/gtk/commitdiff
Add gdk_cairo_reset_clip
authorAlexander Larsson <alexl@redhat.com>
Tue, 1 Sep 2009 15:05:50 +0000 (17:05 +0200)
committerAlexander Larsson <alexl@redhat.com>
Tue, 1 Sep 2009 15:06:41 +0000 (17:06 +0200)
This is required to get back the original drawable clip due to
non-native windows on a cairo_t.

gdk/gdk.symbols
gdk/gdkcairo.c
gdk/gdkcairo.h

index 658fc49ef303a7ed5320e7238fad11f266455296..7956390d25a61f138fb1ef6d71f4f2947ec6cbd6 100644 (file)
@@ -299,6 +299,7 @@ gdk_fontset_load_for_display
 #if IN_HEADER(__GDK_CAIRO_H__)
 #if IN_FILE(__GDK_CAIRO_C__)
 gdk_cairo_create
+gdk_cairo_reset_clip
 gdk_cairo_set_source_color
 gdk_cairo_set_source_pixbuf
 gdk_cairo_set_source_pixmap
index 9d3ce2d6491407830ab332738b8a7d96f100951e..ef8ec25627553eefd8994c63e93f0aa9ae8ef9c2 100644 (file)
@@ -59,6 +59,34 @@ gdk_cairo_create (GdkDrawable *drawable)
   return cr;
 }
 
+/**
+ * gdk_cairo_reset_clip:
+ * @cr: a #cairo_t
+ * @drawable: a #GdkDrawable
+ *
+ * Resets the clip region for a Cairo context created by gdk_cairo_create().
+ *
+ * This resets the clip region to the "empty" state for the given drawable.
+ * This is required for non-native windows since a direct call to
+ * cairo_reset_clip() would unset the clip region inherited from the
+ * drawable (i.e. the window clip region), and thus let you e.g.
+ * draw outside your window.
+ *
+ * This is rarely needed though, since most code just create a new cairo_t
+ * using gdk_cairo_create() each time they want to draw something.
+ *
+ * Since: 2.18
+ **/
+void
+gdk_cairo_reset_clip (cairo_t            *cr,
+                     GdkDrawable        *drawable)
+{
+  cairo_reset_clip (cr);
+
+  if (GDK_DRAWABLE_GET_CLASS (drawable)->set_cairo_clip)
+    GDK_DRAWABLE_GET_CLASS (drawable)->set_cairo_clip (drawable, cr);
+}
+
 /**
  * gdk_cairo_set_source_color:
  * @cr: a #cairo_t
index 70d79de88221187d75fb1813245a5dee3a6c884b..d74182d0f8ce803dae36cefbf5a4ab124d8173be 100644 (file)
@@ -31,6 +31,8 @@
 G_BEGIN_DECLS
 
 cairo_t *gdk_cairo_create            (GdkDrawable        *drawable);
+void     gdk_cairo_reset_clip        (cairo_t            *cairo_t,
+                                     GdkDrawable        *drawable);
 
 void     gdk_cairo_set_source_color  (cairo_t            *cr,
                                       const GdkColor     *color);