Gtk +延迟白屏(flash插件+ NPAPI)

时间:2012-05-31 17:34:24

标签: c gtk npapi xlib

我创建了一个独立的应用程序,它使用NPAPI在gtk + UI上运行已编译的flash(.swf)。当我的视频运行时,有一个小屏幕(可能是1秒或2秒)。这有点烦人,我想知道我是否可以做些什么来摆脱它...通过Xlib例如(本机)。可能吗?我想是的,但我对这些东西很新,只运行了我的第一个应用程序(“hello world”)。我很确定它的水平非常低,并且需要相当多的时间来做同样的事情。如有必要,我可以提供代码。

1)在gtk +?

中可能导致白屏延迟(加载闪存之前)的原因

2)在本机Xlib中实现窗口以渲染闪存有多难?例如,设置NPWindow ......

Gtk ++(看起来像这样)

static NPWindow *
npwindow_construct (GtkWidget *widget) {
  NPWindow *npwindow;
  NPSetWindowCallbackStruct *ws_info = NULL;

  GdkWindow *parent_win = widget->window;

  GtkWidget *socketWidget = gtk_socket_new();

  gtk_widget_set_parent_window(socketWidget, parent_win);
  gtk_widget_set_uposition(socketWidget, xPosition, yPosition);

  g_signal_connect(socketWidget, "plug_removed", G_CALLBACK(plug_removed_cb), NULL);
  g_signal_connect(socketWidget, "unrealize", G_CALLBACK(socket_unrealize_cb), NULL);
  g_signal_connect(socketWidget, "destroy", G_CALLBACK(gtk_widget_destroyed), &socketWidget);

  gpointer user_data = NULL;
  gdk_window_get_user_data(parent_win, &user_data);

  GtkContainer *container = GTK_CONTAINER(user_data);
  gtk_container_add(container, socketWidget);
  gtk_widget_realize(socketWidget);

  GtkAllocation new_allocation;
  new_allocation.x = 0;
  new_allocation.y = 0;
  new_allocation.width = WINDOW_XSIZE;
  new_allocation.height = WINDOW_YSIZE;
  gtk_widget_size_allocate(socketWidget, &new_allocation);

  gtk_widget_show(socketWidget);
  gdk_flush();

  GdkNativeWindow ww = gtk_socket_get_id(GTK_SOCKET(socketWidget));
  GdkWindow *w = gdk_window_lookup(ww); 

  npwindow = malloc (sizeof (NPWindow));
  npwindow->window = (void*)(unsigned long)ww;
  npwindow->x = 0;
  npwindow->y = 0;
  npwindow->width  = WINDOW_XSIZE;
  npwindow->height = WINDOW_YSIZE;

  ws_info = malloc(sizeof (NPSetWindowCallbackStruct));
  ws_info->type = NP_SETWINDOW;
  ws_info->display = GDK_WINDOW_XDISPLAY(w);
  ws_info->colormap = GDK_COLORMAP_XCOLORMAP(gdk_drawable_get_colormap(w));
  GdkVisual* gdkVisual = gdk_drawable_get_visual(w);
  ws_info->visual = GDK_VISUAL_XVISUAL(gdkVisual);
  ws_info->depth = gdkVisual->depth;

  npwindow->ws_info = ws_info;
  npwindow->type = NPWindowTypeWindow;

  return npwindow;
}

3)Xlib与Xt有什么区别?

感谢任何建议或解决方案。

谢谢。

编辑:我尝试在我的gtk组件中嵌入Xlib。因此,在我的主 GdkWindow widget-> window )中创建一个简单的窗口( XCreateSimpleWindow )。我有点迷失在如何做到这一点......因为,gtk_socket_new()创建了一个进程,使gtk组件能够从我的npapi插件中获取(启用为“feed”)数据。那么,我如何填充(编码)NPWindow?

GtkWidget *socketWidget = gtk_drawing_area_new ();
gtk_drawing_area_size (socketWidget , WINDOW_XSIZE, WINDOW_YSIZE); 
gtk_widget_realize (socketWidget); 
XCreateSimpleWindow (GDK_WINDOW_XDISPLAY (parent_win), GDK_WINDOW_XWINDOW (parent_win), 0, 0, WINDOW_XSIZE, WINDOW_YSIZE, 0, 0);

0 个答案:

没有答案