mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
tests: make Gtk+ test programs compile with -DGSEAL_ENABLE
Fixes #612552, at least for now.
This commit is contained in:
parent
08e82cfa3c
commit
4def141e86
4 changed files with 98 additions and 34 deletions
|
@ -92,6 +92,7 @@ find_video_sink (void)
|
|||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
GdkWindow *video_window_xwindow;
|
||||
GtkWidget *window, *video_window;
|
||||
GstElement *pipeline, *src, *sink;
|
||||
gulong embed_xid;
|
||||
|
@ -131,7 +132,8 @@ main (int argc, char **argv)
|
|||
gtk_widget_show_all (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);
|
||||
|
||||
/* run the pipeline */
|
||||
|
|
|
@ -40,6 +40,14 @@
|
|||
GST_DEBUG_CATEGORY_STATIC (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 */
|
||||
|
||||
//#define SOURCE "filesrc"
|
||||
|
@ -2429,8 +2437,13 @@ static gboolean
|
|||
handle_expose_cb (GtkWidget * widget, GdkEventExpose * event, gpointer data)
|
||||
{
|
||||
if (state < GST_STATE_PAUSED) {
|
||||
gdk_draw_rectangle (widget->window, widget->style->black_gc, TRUE,
|
||||
0, 0, widget->allocation.width, widget->allocation.height);
|
||||
GtkAllocation allocation;
|
||||
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;
|
||||
}
|
||||
|
@ -2439,15 +2452,23 @@ static void
|
|||
realize_cb (GtkWidget * widget, gpointer data)
|
||||
{
|
||||
#if GTK_CHECK_VERSION(2,18,0)
|
||||
/* This is here just for pedagogical purposes, GDK_WINDOW_XID will call it
|
||||
* as well */
|
||||
if (!gdk_window_ensure_native (widget->window))
|
||||
g_error ("Couldn't create native window needed for GstXOverlay!");
|
||||
{
|
||||
GdkWindow *window = gtk_widget_get_window (widget);
|
||||
|
||||
/* 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
|
||||
|
||||
#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
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,14 @@
|
|||
#include <gst/interfaces/xoverlay.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 GstElement *sink = NULL;
|
||||
static gulong embed_xid = 0;
|
||||
|
@ -42,20 +50,24 @@ static GdkGC *trans_gc = NULL;
|
|||
static void
|
||||
redraw_overlay (GtkWidget * widget)
|
||||
{
|
||||
gdk_draw_rectangle (widget->window, widget->style->white_gc, TRUE,
|
||||
0, 0, widget->allocation.width, widget->allocation.height);
|
||||
GtkAllocation allocation;
|
||||
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) {
|
||||
guint x, y;
|
||||
guint h = widget->allocation.height * 0.75;
|
||||
guint h = allocation.height * 0.75;
|
||||
|
||||
gdk_draw_rectangle (widget->window, trans_gc, TRUE,
|
||||
0, 0, widget->allocation.width, h);
|
||||
gdk_draw_rectangle (window, trans_gc, TRUE, 0, 0, allocation.width, h);
|
||||
|
||||
for (y = h; y < widget->allocation.height; y++) {
|
||||
for (x = 0; x < widget->allocation.width; x++) {
|
||||
for (y = h; y < allocation.height; y++) {
|
||||
for (x = 0; x < allocation.width; x++) {
|
||||
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)
|
||||
{
|
||||
#if GTK_CHECK_VERSION(2,18,0)
|
||||
/* This is here just for pedagogical purposes, GDK_WINDOW_XID will call it
|
||||
* as well */
|
||||
if (!gdk_window_ensure_native (widget->window))
|
||||
g_error ("Couldn't create native window needed for GstXOverlay!");
|
||||
{
|
||||
GdkWindow *window = gtk_widget_get_window (widget);
|
||||
|
||||
/* 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
|
||||
|
||||
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
|
||||
|
@ -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 */
|
||||
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);
|
||||
if (color != -1) {
|
||||
GdkColor trans_color = { 0,
|
||||
|
@ -115,11 +137,12 @@ msg_state_changed (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
|
|||
(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);
|
||||
}
|
||||
handle_resize_cb (video_window, NULL, NULL);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -35,6 +35,14 @@
|
|||
#include <gst/interfaces/xoverlay.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
|
||||
{
|
||||
gint w, h;
|
||||
|
@ -44,7 +52,8 @@ static struct
|
|||
GstVideoRectangle rect;
|
||||
gboolean running;
|
||||
} anim_state;
|
||||
gboolean verbose = FALSE;
|
||||
|
||||
static gboolean verbose = FALSE;
|
||||
|
||||
static gboolean
|
||||
animate_render_rect (gpointer user_data)
|
||||
|
@ -75,7 +84,7 @@ handle_resize_cb (GtkWidget * widget, GdkEventConfigure * event,
|
|||
{
|
||||
GtkAllocation allocation;
|
||||
|
||||
allocation = widget->allocation;
|
||||
gtk_widget_get_allocation (widget, &allocation);
|
||||
|
||||
if (verbose) {
|
||||
g_print ("resize(%p): %dx%d\n", widget, allocation.width,
|
||||
|
@ -93,6 +102,13 @@ handle_expose_cb (GtkWidget * widget, GdkEventExpose * event,
|
|||
gpointer user_data)
|
||||
{
|
||||
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! */
|
||||
/*
|
||||
|
@ -101,17 +117,17 @@ handle_expose_cb (GtkWidget * widget, GdkEventExpose * event,
|
|||
gdk_draw_rectangle (widget->window, widget->style->bg_gc[0], TRUE,
|
||||
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);
|
||||
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,
|
||||
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);
|
||||
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.width, widget->allocation.height - (r->y + r->h));
|
||||
event->area.width, allocation.height - (r->y + r->h));
|
||||
if (verbose) {
|
||||
g_print ("expose(%p)\n", widget);
|
||||
}
|
||||
|
@ -136,6 +152,7 @@ window_closed (GtkWidget * widget, GdkEvent * event, gpointer user_data)
|
|||
gint
|
||||
main (gint argc, gchar ** argv)
|
||||
{
|
||||
GdkWindow *video_window_xwindow;
|
||||
GtkWidget *window, *video_window;
|
||||
GstElement *pipeline, *src, *sink;
|
||||
GstStateChangeReturn sret;
|
||||
|
@ -190,7 +207,8 @@ main (gint argc, gchar ** argv)
|
|||
* asks for the XID of the window to render onto */
|
||||
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) {
|
||||
g_print ("Window realize: got XID %lu\n", embed_xid);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue