Re: How to redraw the blanked section of a widget after a expose-event?



krist misra wrote:
Hi experts,

I am using GTK+ and gstreamer to capture and show the video frames, I
created a drawable widget using gtk_drawing_area_new() and using xvimage
element of gstreamer to render the video, I also connected them by a
gstreamer function gst_x_overlay_set_xwindow_id(), so the video frames
rendered  by xvimage can show in the widget, now it works well.

But I encounter a problem that if part of the drawable widget being covered
by a menu or something, when the menu disappears, the covered section keeps
blank, even other part of the widget still show the video.

I try to write a function expose_cb() and connect it with the signal
"expose-event", in that function I call gst_x_overlay_set_xwindow_id()
again and also gtk_widget_show_all(), but it seems still not work. cos it's
showing a video so I cannot save some image and redraw it again
after it exposes.

Anyone can help me? how should I do in the expose_cb or something else?
Thanks a lot
below is part of the source code
-----------------------------------------------------------------------------------------
static gboolean expose_cb(GtkWidget * widget, GdkEventExpose * event,
gpointer data)
{
    gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(data),
                                  GDK_WINDOW_XWINDOW(widget->window));
    gtk_widget_show_all(widget);
}

int main()
{
...
  gstreamer_main_video_image = gtk_drawing_area_new();
...
  screen_sink = gst_bin_get_by_name (GST_BIN (appdata.bin), "screensink");
...
  gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(screen_sink),
    GDK_WINDOW_XWINDOW(gstreamer_main_video_image->window));
   g_signal_connect(gstreamer_main_video_image, "expose-event",
G_CALLBACK(expose_cb),
                             screen_sink);
  gtk_widget_show_all(gstreamer_window);
...
}
------------------------------------------------------------
Krist.
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

I dont know if this is a correct solution, but i have drawn images to the background of gtk_drawing_area, and if you do that, then GTK will keep the background pixmap around for redrawing purposes.

Use something like this:

gdk_window_set_back_pixmap(widget->window, pixmap, FALSE);
gtk_widget_queue_draw_area(widget, 0, 0,
                          widget->allocation.width,
                          widget->allocation.height);

And create a pixmap where you draw the images, and queue redraw when the you redraw the pixmap.

--
Arto Karppinen
------------------------------
arto karppinen iki fi




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]