tests: make Gtk+ test programs compile with -DGSEAL_ENABLE

Fixes #612552, at least for now.
This commit is contained in:
Tim-Philipp Müller 2010-03-14 22:14:19 +00:00
parent 08e82cfa3c
commit 4def141e86
4 changed files with 98 additions and 34 deletions

View file

@ -92,6 +92,7 @@ find_video_sink (void)
int int
main (int argc, char **argv) main (int argc, char **argv)
{ {
GdkWindow *video_window_xwindow;
GtkWidget *window, *video_window; GtkWidget *window, *video_window;
GstElement *pipeline, *src, *sink; GstElement *pipeline, *src, *sink;
gulong embed_xid; gulong embed_xid;
@ -131,7 +132,8 @@ main (int argc, char **argv)
gtk_widget_show_all (window); gtk_widget_show_all (window);
gtk_widget_realize (window); gtk_widget_realize (window);
embed_xid = GDK_WINDOW_XID (video_window->window); video_window_xwindow = gtk_widget_get_window (video_window);
embed_xid = GDK_WINDOW_XID (video_window_xwindow);
gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (sink), embed_xid); gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (sink), embed_xid);
/* run the pipeline */ /* run the pipeline */

View file

@ -40,6 +40,14 @@
GST_DEBUG_CATEGORY_STATIC (seek_debug); GST_DEBUG_CATEGORY_STATIC (seek_debug);
#define GST_CAT_DEFAULT (seek_debug) #define GST_CAT_DEFAULT (seek_debug)
#if !GTK_CHECK_VERSION (2, 17, 7)
static void
gtk_widget_get_allocation (GtkWidget * w, GtkAllocation * a)
{
*a = w->allocation;
}
#endif
/* configuration */ /* configuration */
//#define SOURCE "filesrc" //#define SOURCE "filesrc"
@ -2429,8 +2437,13 @@ static gboolean
handle_expose_cb (GtkWidget * widget, GdkEventExpose * event, gpointer data) handle_expose_cb (GtkWidget * widget, GdkEventExpose * event, gpointer data)
{ {
if (state < GST_STATE_PAUSED) { if (state < GST_STATE_PAUSED) {
gdk_draw_rectangle (widget->window, widget->style->black_gc, TRUE, GtkAllocation allocation;
0, 0, widget->allocation.width, widget->allocation.height); GdkWindow *window = gtk_widget_get_window (widget);
GtkStyle *style = gtk_widget_get_style (widget);
gtk_widget_get_allocation (widget, &allocation);
gdk_draw_rectangle (window, style->black_gc, TRUE, 0, 0,
allocation.width, allocation.height);
} }
return FALSE; return FALSE;
} }
@ -2439,15 +2452,23 @@ static void
realize_cb (GtkWidget * widget, gpointer data) realize_cb (GtkWidget * widget, gpointer data)
{ {
#if GTK_CHECK_VERSION(2,18,0) #if GTK_CHECK_VERSION(2,18,0)
/* This is here just for pedagogical purposes, GDK_WINDOW_XID will call it {
* as well */ GdkWindow *window = gtk_widget_get_window (widget);
if (!gdk_window_ensure_native (widget->window))
g_error ("Couldn't create native window needed for GstXOverlay!"); /* This is here just for pedagogical purposes, GDK_WINDOW_XID will call it
* as well */
if (!gdk_window_ensure_native (window))
g_error ("Couldn't create native window needed for GstXOverlay!");
}
#endif #endif
#ifdef HAVE_X #ifdef HAVE_X
embed_xid = GDK_WINDOW_XID (video_window->window); {
g_print ("Window realize: video window XID = %lu\n", embed_xid); GdkWindow *window = gtk_widget_get_window (video_window);
embed_xid = GDK_WINDOW_XID (window);
g_print ("Window realize: video window XID = %lu\n", embed_xid);
}
#endif #endif
} }

View file

@ -34,6 +34,14 @@
#include <gst/interfaces/xoverlay.h> #include <gst/interfaces/xoverlay.h>
#include <gst/interfaces/propertyprobe.h> #include <gst/interfaces/propertyprobe.h>
#if !GTK_CHECK_VERSION (2, 17, 7)
static void
gtk_widget_get_allocation (GtkWidget * w, GtkAllocation * a)
{
*a = w->allocation;
}
#endif
static GtkWidget *video_window = NULL; static GtkWidget *video_window = NULL;
static GstElement *sink = NULL; static GstElement *sink = NULL;
static gulong embed_xid = 0; static gulong embed_xid = 0;
@ -42,20 +50,24 @@ static GdkGC *trans_gc = NULL;
static void static void
redraw_overlay (GtkWidget * widget) redraw_overlay (GtkWidget * widget)
{ {
gdk_draw_rectangle (widget->window, widget->style->white_gc, TRUE, GtkAllocation allocation;
0, 0, widget->allocation.width, widget->allocation.height); GdkWindow *window = gtk_widget_get_window (widget);
GtkStyle *style = gtk_widget_get_style (widget);
gtk_widget_get_allocation (widget, &allocation);
gdk_draw_rectangle (window, style->white_gc, TRUE, 0, 0,
allocation.width, allocation.height);
if (trans_gc) { if (trans_gc) {
guint x, y; guint x, y;
guint h = widget->allocation.height * 0.75; guint h = allocation.height * 0.75;
gdk_draw_rectangle (widget->window, trans_gc, TRUE, gdk_draw_rectangle (window, trans_gc, TRUE, 0, 0, allocation.width, h);
0, 0, widget->allocation.width, h);
for (y = h; y < widget->allocation.height; y++) { for (y = h; y < allocation.height; y++) {
for (x = 0; x < widget->allocation.width; x++) { for (x = 0; x < allocation.width; x++) {
if (((x & 1) || (y & 1)) && (x & 1) != (y & 1)) { if (((x & 1) || (y & 1)) && (x & 1) != (y & 1)) {
gdk_draw_point (widget->window, trans_gc, x, y); gdk_draw_point (window, trans_gc, x, y);
} }
} }
} }
@ -80,14 +92,22 @@ static void
realize_cb (GtkWidget * widget, gpointer data) realize_cb (GtkWidget * widget, gpointer data)
{ {
#if GTK_CHECK_VERSION(2,18,0) #if GTK_CHECK_VERSION(2,18,0)
/* This is here just for pedagogical purposes, GDK_WINDOW_XID will call it {
* as well */ GdkWindow *window = gtk_widget_get_window (widget);
if (!gdk_window_ensure_native (widget->window))
g_error ("Couldn't create native window needed for GstXOverlay!"); /* This is here just for pedagogical purposes, GDK_WINDOW_XID will call it
* as well */
if (!gdk_window_ensure_native (window))
g_error ("Couldn't create native window needed for GstXOverlay!");
}
#endif #endif
embed_xid = GDK_WINDOW_XID (video_window->window); {
g_print ("Window realize: got XID %lu\n", embed_xid); GdkWindow *window = gtk_widget_get_window (video_window);
embed_xid = GDK_WINDOW_XID (window);
g_print ("Window realize: video window XID = %lu\n", embed_xid);
}
} }
static void static void
@ -106,7 +126,9 @@ msg_state_changed (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
/* When state of the pipeline changes to paused or playing we start updating scale */ /* When state of the pipeline changes to paused or playing we start updating scale */
switch (GST_STATE_TRANSITION (old, new)) { switch (GST_STATE_TRANSITION (old, new)) {
case GST_STATE_CHANGE_READY_TO_PAUSED: case GST_STATE_CHANGE_READY_TO_PAUSED:{
GdkWindow *window = gtk_widget_get_window (video_window);
g_object_get (G_OBJECT (sink), "colorkey", &color, NULL); g_object_get (G_OBJECT (sink), "colorkey", &color, NULL);
if (color != -1) { if (color != -1) {
GdkColor trans_color = { 0, GdkColor trans_color = { 0,
@ -115,11 +137,12 @@ msg_state_changed (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
(color & 0xff) << 8 (color & 0xff) << 8
}; };
trans_gc = gdk_gc_new (video_window->window); trans_gc = gdk_gc_new (window);
gdk_gc_set_rgb_fg_color (trans_gc, &trans_color); gdk_gc_set_rgb_fg_color (trans_gc, &trans_color);
} }
handle_resize_cb (video_window, NULL, NULL); handle_resize_cb (video_window, NULL, NULL);
break; break;
}
default: default:
break; break;
} }

View file

@ -35,6 +35,14 @@
#include <gst/interfaces/xoverlay.h> #include <gst/interfaces/xoverlay.h>
#include <gst/video/gstvideosink.h> #include <gst/video/gstvideosink.h>
#if !GTK_CHECK_VERSION (2, 17, 7)
static void
gtk_widget_get_allocation (GtkWidget * w, GtkAllocation * a)
{
*a = w->allocation;
}
#endif
static struct static struct
{ {
gint w, h; gint w, h;
@ -44,7 +52,8 @@ static struct
GstVideoRectangle rect; GstVideoRectangle rect;
gboolean running; gboolean running;
} anim_state; } anim_state;
gboolean verbose = FALSE;
static gboolean verbose = FALSE;
static gboolean static gboolean
animate_render_rect (gpointer user_data) animate_render_rect (gpointer user_data)
@ -75,7 +84,7 @@ handle_resize_cb (GtkWidget * widget, GdkEventConfigure * event,
{ {
GtkAllocation allocation; GtkAllocation allocation;
allocation = widget->allocation; gtk_widget_get_allocation (widget, &allocation);
if (verbose) { if (verbose) {
g_print ("resize(%p): %dx%d\n", widget, allocation.width, g_print ("resize(%p): %dx%d\n", widget, allocation.width,
@ -93,6 +102,13 @@ handle_expose_cb (GtkWidget * widget, GdkEventExpose * event,
gpointer user_data) gpointer user_data)
{ {
GstVideoRectangle *r = &anim_state.rect; GstVideoRectangle *r = &anim_state.rect;
GtkAllocation allocation;
GdkWindow *window;
GtkStyle *style;
style = gtk_widget_get_style (widget);
window = gtk_widget_get_window (widget);
gtk_widget_get_allocation (widget, &allocation);
/* we should only redraw outside of the video rect! */ /* we should only redraw outside of the video rect! */
/* /*
@ -101,17 +117,17 @@ handle_expose_cb (GtkWidget * widget, GdkEventExpose * event,
gdk_draw_rectangle (widget->window, widget->style->bg_gc[0], TRUE, gdk_draw_rectangle (widget->window, widget->style->bg_gc[0], TRUE,
event->area.x, event->area.y, event->area.width, event->area.height); event->area.x, event->area.y, event->area.width, event->area.height);
*/ */
gdk_draw_rectangle (widget->window, widget->style->bg_gc[0], TRUE, gdk_draw_rectangle (window, style->bg_gc[0], TRUE,
0, event->area.y, r->x, event->area.height); 0, event->area.y, r->x, event->area.height);
gdk_draw_rectangle (widget->window, widget->style->bg_gc[0], TRUE, gdk_draw_rectangle (window, style->bg_gc[0], TRUE,
r->x + r->w, event->area.y, r->x + r->w, event->area.y,
widget->allocation.width - (r->x + r->w), event->area.height); allocation.width - (r->x + r->w), event->area.height);
gdk_draw_rectangle (widget->window, widget->style->bg_gc[0], TRUE, gdk_draw_rectangle (window, style->bg_gc[0], TRUE,
event->area.x, 0, event->area.width, r->y); event->area.x, 0, event->area.width, r->y);
gdk_draw_rectangle (widget->window, widget->style->bg_gc[0], TRUE, gdk_draw_rectangle (window, style->bg_gc[0], TRUE,
event->area.x, r->y + r->h, event->area.x, r->y + r->h,
event->area.width, widget->allocation.height - (r->y + r->h)); event->area.width, allocation.height - (r->y + r->h));
if (verbose) { if (verbose) {
g_print ("expose(%p)\n", widget); g_print ("expose(%p)\n", widget);
} }
@ -136,6 +152,7 @@ window_closed (GtkWidget * widget, GdkEvent * event, gpointer user_data)
gint gint
main (gint argc, gchar ** argv) main (gint argc, gchar ** argv)
{ {
GdkWindow *video_window_xwindow;
GtkWidget *window, *video_window; GtkWidget *window, *video_window;
GstElement *pipeline, *src, *sink; GstElement *pipeline, *src, *sink;
GstStateChangeReturn sret; GstStateChangeReturn sret;
@ -190,7 +207,8 @@ main (gint argc, gchar ** argv)
* asks for the XID of the window to render onto */ * asks for the XID of the window to render onto */
gtk_widget_realize (window); gtk_widget_realize (window);
embed_xid = GDK_WINDOW_XID (video_window->window); video_window_xwindow = gtk_widget_get_window (video_window);
embed_xid = GDK_WINDOW_XID (video_window_xwindow);
if (verbose) { if (verbose) {
g_print ("Window realize: got XID %lu\n", embed_xid); g_print ("Window realize: got XID %lu\n", embed_xid);
} }