0

我正在尝试编写一个小应用程序以了解 evas 如何与 X11 一起使用。我在文档中没有找到完整的示例,只有我尝试使用的一些部分。这是代码:

#include <stdio.h>
#include <stdlib.h>
#include <X11/Xlib.h>
#include <Evas.h>
#include <Evas_Engine_Software_X11.h>

/*
gcc -o evas_software_x11 evas_software_x11.c $(pkg-config --libs --cflags x11 evas)
*/

#define WIDTH 640
#define HEIGHT 480

int main(int argc, char **argv)
{
  Evas *canevas;
  Evas_Engine_Info_Software_X11 *einfo;
  Display * display;
  Window win;
  display = XOpenDisplay(NULL);
  int s;
  XEvent e;
  s = DefaultScreen(display);
  win = XCreateSimpleWindow(  display,
                              RootWindow(display, s),
                              10,10,WIDTH,HEIGHT,1,
                              BlackPixel(display, s),
                              WhitePixel(display, s));

  XSelectInput(display, win, ExposureMask | KeyPressMask);                            

  evas_init();
  /*Création et configuration du canevas*/
  canevas = evas_new();
  evas_output_method_set(canevas, evas_render_method_lookup("software_x11"));
  evas_output_size_set(canevas, WIDTH, HEIGHT);
  evas_output_viewport_set(canevas, 0, 0, WIDTH, HEIGHT);
  einfo = NULL;
  einfo = (Evas_Engine_Info_Software_X11 *) evas_engine_info_get(canevas);
  if(!einfo)
  {
    printf("einfo not valide\n");
    exit(EXIT_FAILURE);
  }
  einfo->info.display = display;
  einfo->info.visual = DefaultVisual(display, DefaultScreen(display));
  einfo->info.colormap = DefaultColormap(display, DefaultScreen(display));
  einfo->info.drawable = win;
  einfo->info.depth = DefaultDepth(display, DefaultScreen(display));
  evas_engine_info_set(canevas, (Evas_Engine_Info *) einfo);

  /*Création d'un fond et d'un rectangle pour l'exemple*/
  Evas_Object * bg, *rect;

  bg = evas_object_rectangle_add(canevas);
  evas_object_move(bg, 0, 0);
  evas_object_resize(bg, WIDTH, HEIGHT);
  evas_object_color_set(bg, 0, 128, 0, 128); // 50% opaque vert
  eavs_object_show(bg);

  rect = evas_object_rectangle_add(canevas);
  evas_object_move(rect, 20, 20);
  evas_object_resize(rect, 100, 100);
  evas_object_color_set(rect, 255, 0, 0, 255); // opaque rouge
  eavs_object_show(rect);


  evas_render(canevas);
  while(1) {
    XnextEvent(display, &e);
    if (e.type == Expose)
    {

    }
    if (e.type == KeyPress)
      break;
  }
  evas_free(canevas);
  evas_shutdown();

  XCloseDisplay(d);
  return EXIT_SUCCESS;
}

当我编译它时,我有这个错误:

gcc -o evas_software_x11 evas_software_x11.c $(pkg-config --libs --cflags evas x11) 
evas_software_x11.c: In function ‘main’:
evas_software_x11.c:45:14: erreur: ‘struct <anonymous>’ has no member named ‘display’
einfo->info.display = display;
          ^

但部分einfo->info.display = display来自官方文档:

https://build.enlightenment.org/job/nightly_efl_gcc_x86_64/lastSuccessfulBuild/artifact/doc/html/group__Evas__Output__Method.html#details

关于我在哪里犯错的任何想法?

4

1 回答 1

0

文档不是最新的。

info 结构有一个名为 connection 而不是 display 的成员(参见文件 Evas_Engine_Software_X11.h 和http://lists.enlightenment.fr/enlightenment-devel/att-27663/expedite_merge_1.diff)。

于 2014-01-21T17:31:01.167 回答