[cairo] How to draw Cairo graphic in a Motif drawing widget

Lawrence D'Oliveiro ldo at geek-central.gen.nz
Wed May 11 00:26:33 UTC 2016


On Tue, 10 May 2016 16:54:37 +0000 (UTC), George Wu wrote:

> Actually, I did follow the examples shown in Cairo.org, and
> successfully drawn graphics on X-Window created using Xlib functions,
> not using the Motif widgets.

That’s good. :)

> Here is my code of using Motif widgets to generate an X-Window with a
> drawing area, and I want to draw a red dot at the middle of the
> drawing area using Cairo functions, and I should see the red dot when
> the X-Window pops up. Unfortunately, I got the following error
> message:
> 
> ============================================================================
> 
> X Error of failed request:  BadDrawable (invalid Pixmap or Window
> parameter) Major opcode of failed request:  53 (X_CreatePixmap)
>   Resource id in failed request:  0x0
>   Serial number of failed request:  204
>   Current serial number in output stream:  213

I hacked about with your code, and got as far as determining that
your drawCB callback is being successfully entered and exited. The error
is reported after that.

Commenting out most of the body of drawCB seems to show that the error
is triggered by actual drawing. Thus

>     cairo_set_line_width(ctx, 20);
>     cairo_set_source_rgb(ctx, 1, 0, 0);
> 
>     cairo_set_line_cap(ctx, CAIRO_LINE_CAP_ROUND);
>     cairo_move_to(ctx, Width / 2.0, Height / 2.0);
>     cairo_close_path(ctx);
>     cairo_stroke(ctx);

if I comment out the cairo_stroke() call, there is no error. If I
replace the entire body of the routine with a simple cairo_paint() call
using the default colour etc, that will trigger the error.

Putting in cairo_status() and cairo_surface_status() calls at
various points indicates no error as far as Cairo is concerned.

Beyond that, I am out of my depth, sorry. :)


More information about the cairo mailing list