[cairo] Paint a image in Cairo surface X11

Uli Schlachter psychon at znc.in
Fri Feb 5 09:15:34 PST 2016


Hi,

Am 05.02.2016 um 15:13 schrieb Alex Vazquez:
> I have a problem when I paint a image using Cairo and X11.
> The test is simple I try paint a image in a  X11 Windows using Cairo.
> If the size of surface  is less that size of image, X11 don't show the
> image but If the  size of surface  is bigger that the size of image  X11
> show fine the image.
> 
> Why is happen?

In X11, you have to handle redraws (Expose events).

For example, with your version, remove the code that handles a ButtonPress and
switch to another window, move it above of your window and then switch back to
your window. The content of the window will be lost.

> How can i fix this problem?

Redraw when the server tells you to.

> I add a test where you can test this problem.

Thanks, attached is a fixed version (well, I am lazy; an Expose event contains
information about which part of the window needs to be redrawn; the code just
redraws everything).

Cheers,
Uli

P.S.: No idea why this has something to do with the size of the image for you.
If you want me to guess it is because with a larger it takes a tiny bit longer
to upload the image and thus the race against the window manager more often ends
with "paint only after the window is shown".

P.P.S.: The program still exits by segfaulting, just as your version...
-- 
- Captain, I think I should tell you I've never
  actually landed a starship before.
- That's all right, Lieutenant, neither have I.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cairo_xlib_simple.c
Type: text/x-csrc
Size: 2611 bytes
Desc: not available
URL: <http://lists.cairographics.org/archives/cairo/attachments/20160205/425294fc/attachment.c>


More information about the cairo mailing list