summaryrefslogtreecommitdiff
path: root/src/cairo/cdcaironative_gdk.c
diff options
context:
space:
mode:
authorscuri <scuri>2010-10-15 02:36:01 +0000
committerscuri <scuri>2010-10-15 02:36:01 +0000
commit4658f8fe86dbf499b1e43db455c5172007b93d14 (patch)
treeb1679b8f8cf421dd8edfd87952c33578aa1364f1 /src/cairo/cdcaironative_gdk.c
parent26ee3a10b806df99915805516567f6ad38956ac4 (diff)
Fixed: Cairo context plus base driver when used with GDK.
Diffstat (limited to 'src/cairo/cdcaironative_gdk.c')
-rw-r--r--src/cairo/cdcaironative_gdk.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/cairo/cdcaironative_gdk.c b/src/cairo/cdcaironative_gdk.c
index 29be6c6..e233ed6 100644
--- a/src/cairo/cdcaironative_gdk.c
+++ b/src/cairo/cdcaironative_gdk.c
@@ -20,10 +20,35 @@ static void cdkillcanvas(cdCtxCanvas *ctxcanvas)
int cdactivate(cdCtxCanvas *ctxcanvas)
{
- gdk_drawable_get_size(ctxcanvas->drawable, &ctxcanvas->canvas->w, &ctxcanvas->canvas->h);
+ cdCanvas* canvas = ctxcanvas->canvas;
+ int old_w = canvas->w;
+ int old_h = canvas->h;
- ctxcanvas->canvas->w_mm = ((double)ctxcanvas->canvas->w) / ctxcanvas->canvas->xres;
- ctxcanvas->canvas->h_mm = ((double)ctxcanvas->canvas->h) / ctxcanvas->canvas->yres;
+ gdk_drawable_get_size(ctxcanvas->drawable, &canvas->w, &canvas->h);
+
+ ctxcanvas->canvas->w_mm = ((double)canvas->w) / canvas->xres;
+ ctxcanvas->canvas->h_mm = ((double)canvas->h) / canvas->yres;
+
+ if (old_w != canvas->w || old_h != canvas->h)
+ {
+ cairo_destroy(ctxcanvas->cr);
+ ctxcanvas->cr = gdk_cairo_create(ctxcanvas->drawable);
+
+ ctxcanvas->last_source = -1;
+
+ cairo_save(ctxcanvas->cr);
+ cairo_set_operator(ctxcanvas->cr, CAIRO_OPERATOR_OVER);
+
+ /* update canvas attributes */
+ canvas->cxForeground(ctxcanvas, canvas->foreground);
+ canvas->cxLineStyle(ctxcanvas, canvas->line_style);
+ canvas->cxLineWidth(ctxcanvas, canvas->line_width);
+ canvas->cxLineCap(ctxcanvas, canvas->line_cap);
+ canvas->cxLineJoin(ctxcanvas, canvas->line_join);
+ canvas->cxInteriorStyle(ctxcanvas, canvas->interior_style);
+ if (canvas->clip_mode != CD_CLIPOFF) canvas->cxClip(ctxcanvas, canvas->clip_mode);
+ if (canvas->use_matrix) canvas->cxTransform(ctxcanvas, canvas->matrix);
+ }
return CD_OK;
}
@@ -35,6 +60,9 @@ static void cdcreatecanvas(cdCanvas* canvas, void *data)
GdkScreen* screen;
GdkDrawable* drawable = (GdkDrawable*)data;
+ if (!GDK_IS_DRAWABLE(drawable))
+ return;
+
cr = gdk_cairo_create(drawable);
if (!cr)
return;