【发布时间】:2013-12-24 15:57:07
【问题描述】:
我正在尝试从 Cairo 图像表面切换到 xlib 表面。我的代码在图像表面上运行良好,但我认为我没有正确初始化 xlib 表面。它可以编译,但会引发警告,并且不再显示任何内容。
这是我当前初始化表面的代码:
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);
编译时收到以下警告:
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,
^
我很确定这些警告会破坏代码,但我不确定如何修复它们。我尝试将第一个参数和第三个参数分别转换为(Display *) 和(Visual *),但这也不起作用。开始抛出其他警告。
*编辑 1 *
试图理解这一点,但我对指针的理解仅限于到目前为止不存在。 gdk_drawable_get_xdisplay() 返回 Display*,但我的函数正在寻找指向 struct Display * 的指针。 2 和我如何从Display* 到Display * 有什么区别。
【问题讨论】: