4

I created an standalone application which run compiled flash (.swf) on a gtk+ UI with NPAPI. When my video runs, there's a small time where there's a white screen (maybe 1 or 2 sec). It's kind of annoying and I am wondering if I can do something to get rid of it.. by going with Xlib for example (native). Is it possible? I guess it is, but I'm pretty new to this stuff and only ran my first application ("hello world"). I'm pretty sure it's very low level and demands considerable amount of time to do the same thing. I could provide the code if necessary.

1) What could be possibly causing the white screen delay (before loading my flash) in gtk+?

2) How difficult could it be to implement a window in native Xlib to render flash? For example, for setting up NPWindow...

Gtk++ (would look something like this)

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) What is the difference between Xlib and Xt?

Any advice or fix is appreciated.

thank you.

EDIT: I tried to embed Xlib within my gtk components. So, create a simple window (XCreateSimpleWindow) within my main GdkWindow (widget->window). I'm kind of lost on how to do this... Because, gtk_socket_new() creates a process which enable gtk component to reach (enable to be "feed") data from my npapi plugin. So, how do I populate (code) the 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);
fneron
  • 1,057
  • 3
  • 15
  • 39

0 Answers0