Reputation: 1229
I'm trying to switch from a Cairo image surface to an xlib surface. My code worked fine with the image surface but I don't think I'm initializing the xlib surface properly. It compiles but it throws warnings and nothing shows anymore.
Here's my current code to initialize the surface:
int width, height;
gdk_threads_enter();
gdk_drawable_get_size(pixmap, &width, &height);
gdk_threads_leave();
/*** Create surface to draw on ***/
cairo_surface_t *cst = cairo_xlib_surface_create(gdk_x11_drawable_get_xdisplay(pixmap),
gdk_x11_drawable_get_xid(pixmap),
gdk_x11_visual_get_xvisual(gvis),
width, height);
Getting following warnings when compiling:
In function 'do_draw':
evis.c:112:11: warning: passing argument 1 of 'cairo_xlib_surface_create' makes pointer from integer without a cast [enabled by default]
width, height);
^
In file included from evis.c:6:0:
/usr/include/cairo/cairo-xlib.h:49:1: note: expected 'struct Display *' but argument is of type 'int'
cairo_xlib_surface_create (Display *dpy,
^
evis.c:112:11: warning: passing argument 3 of 'cairo_xlib_surface_create' makes pointer from integer without a cast [enabled by default]
width, height);
^
In file included from evis.c:6:0:
/usr/include/cairo/cairo-xlib.h:49:1: note: expected 'struct Visual *' but argument is of type 'int'
cairo_xlib_surface_create (Display *dpy,
^
I'm pretty sure these warnings break the code and I'm not sure how to fix them. I tried casting the first argument and third arguments to (Display *)
and (Visual *)
respectively but that didn't work either. Started throwing other warnings.
*EDIT 1 *
Trying to understand this but my understanding of pointers is limited to non existent so far. gdk_drawable_get_xdisplay()
returns a Display*
but my function is looking for a pointer to an struct Display *
. What's the difference between the 2 and how do I get from Display*
to Display *
.
Upvotes: 0
Views: 1024
Reputation: 1761
The "usual" reason for the compiler thinking a function returns an int (which is what is happening here, since it's complaining about the results of those two functions) is that it can't find a prototype for the function, meaning you're missing an #include. (Although I would expect to find other warnings in that case?)
Upvotes: 1