summaryrefslogtreecommitdiff
path: root/tests/examples
diff options
context:
space:
mode:
authorMatthew Waters <matthew@centricular.com>2016-03-22 23:10:24 +1100
committerMatthew Waters <matthew@centricular.com>2016-03-31 20:53:18 +1100
commitf9d03dd9c4f55464186d1a8d5a8af88aea2e62fe (patch)
tree75ef1099df89f1c6bb75fcaf6c1d58e8ed5ddc65 /tests/examples
parent8fe5b198bef0bf71b17e9fdfd6b10132029512d9 (diff)
downloadgstreamer-plugins-bad-f9d03dd9c4f55464186d1a8d5a8af88aea2e62fe.tar.gz
gl/examples: fix switchvideooverlay for wayland
and call XInitThreads() for X11
Diffstat (limited to 'tests/examples')
-rw-r--r--tests/examples/gl/gtk/switchvideooverlay/Makefile.am4
-rw-r--r--tests/examples/gl/gtk/switchvideooverlay/main.cpp31
2 files changed, 20 insertions, 15 deletions
diff --git a/tests/examples/gl/gtk/switchvideooverlay/Makefile.am b/tests/examples/gl/gtk/switchvideooverlay/Makefile.am
index dbe007cb3..e6ebf70bf 100644
--- a/tests/examples/gl/gtk/switchvideooverlay/Makefile.am
+++ b/tests/examples/gl/gtk/switchvideooverlay/Makefile.am
@@ -4,8 +4,8 @@ switchvideooverlay_SOURCES = main.cpp
switchvideooverlay_CXXFLAGS=-I$(top_srcdir)/gst-libs -I$(top_builddir)/gst-libs \
$(GST_PLUGINS_BASE_CFLAGS) $(GST_CXXFLAGS) \
- $(GL_CFLAGS) $(GTK3_CFLAGS)
+ $(GL_CFLAGS) $(GTK3_CFLAGS) $(X_CFLAGS)
switchvideooverlay_LDADD=../libgstgtkhelper.la \
$(GTK3_LIBS) $(GST_PLUGINS_BASE_LIBS) $(GST_LIBS) \
- $(GL_LIBS) -lgstvideo-$(GST_API_VERSION)
+ $(GL_LIBS) -lgstvideo-$(GST_API_VERSION) $(X_LIBS)
diff --git a/tests/examples/gl/gtk/switchvideooverlay/main.cpp b/tests/examples/gl/gtk/switchvideooverlay/main.cpp
index ea53ea1f6..476478d75 100644
--- a/tests/examples/gl/gtk/switchvideooverlay/main.cpp
+++ b/tests/examples/gl/gtk/switchvideooverlay/main.cpp
@@ -18,12 +18,19 @@
* Boston, MA 02110-1301, USA.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <gst/gst.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include "../gstgtk.h"
+#ifdef HAVE_X11
+#include <X11/Xlib.h>
+#endif
static GstBusSyncReply create_window (GstBus* bus, GstMessage* message, GtkWidget* widget)
{
@@ -59,7 +66,7 @@ resize_cb (GtkWidget * widget, GdkEvent * event, gpointer sink)
gtk_widget_get_allocation (widget, &allocation);
gst_video_overlay_set_render_rectangle (GST_VIDEO_OVERLAY (sink), allocation.x, allocation.y, allocation.width, allocation.height);
- return G_SOURCE_CONTINUE;
+ return FALSE;
}
static void end_stream_cb(GstBus* bus, GstMessage* message, GstElement* pipeline)
@@ -104,6 +111,7 @@ static gboolean expose_cb(GtkWidget* widget, cairo_t *cr, GstElement* videosink)
static gboolean on_click_drawing_area(GtkWidget* widget, GdkEventButton* event, GstElement* videosink)
{
GtkAllocation allocation;
+ GtkWidget *parent = gtk_widget_get_parent (widget);
g_print ("switch the drawing area %p\n", widget);
gst_video_overlay_set_gtk_window (GST_VIDEO_OVERLAY (videosink), widget);
@@ -111,6 +119,11 @@ static gboolean on_click_drawing_area(GtkWidget* widget, GdkEventButton* event,
gtk_widget_get_allocation (widget, &allocation);
gst_video_overlay_set_render_rectangle (GST_VIDEO_OVERLAY (videosink), allocation.x, allocation.y, allocation.width, allocation.height);
+ /* XXX: required on wayland as changing the window handle (subsurface)
+ * requires a wl_surface::commit from the parent */
+ if (parent)
+ gtk_widget_queue_draw (parent);
+
return FALSE;
}
@@ -153,16 +166,12 @@ static void button_state_playing_cb(GtkWidget* widget, GstElement* pipeline)
g_print ("GST_STATE_PLAYING\n");
}
-static void area_realize_cb(GtkWidget* widget, gpointer data)
-{
- g_print ("realize %p\n", widget);
- if (!gdk_window_ensure_native (gtk_widget_get_window (widget)))
- g_error ("Failed to create native window!");
-}
-
-
gint main (gint argc, gchar *argv[])
{
+#ifdef HAVE_X11
+ XInitThreads();
+#endif
+
gtk_init (&argc, &argv);
gst_init (&argc, &argv);
@@ -250,10 +259,6 @@ gint main (gint argc, gchar *argv[])
gtk_widget_set_size_request (area_top_right, 320, 240);
gtk_grid_attach (GTK_GRID (table_areas), area_top_right, 1, 0, 1, 1);
- //set window id on this event
- g_signal_connect(area_top_left, "realize", G_CALLBACK(area_realize_cb), NULL);
- g_signal_connect(area_top_right, "realize", G_CALLBACK(area_realize_cb), NULL);
-
gtk_widget_set_redraw_on_allocate (area_top_left, TRUE);
gtk_widget_set_redraw_on_allocate (area_top_right, TRUE);
gtk_widget_realize(area_top_left);