[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gstreamer-cvs
Subject:    gst-plugins-bad: gl/examples: fix switchvideooverlay for wayland
From:       ystreet () kemper ! freedesktop ! org (Matthew Waters)
Date:       2016-03-31 10:17:07
Message-ID: 20160331101707.4CF24761E0 () kemper ! freedesktop ! org
[Download RAW message or body]

Module: gst-plugins-bad
Branch: master
Commit: f9d03dd9c4f55464186d1a8d5a8af88aea2e62fe
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/commit/?id=f9d03dd9c4f55464186d1a8d5a8af88aea2e62fe


Author: Matthew Waters <matthew@centricular.com>
Date:   Tue Mar 22 23:10:24 2016 +1100

gl/examples: fix switchvideooverlay for wayland

and call XInitThreads() for X11

---

 .../examples/gl/gtk/switchvideooverlay/Makefile.am |  4 +--
 tests/examples/gl/gtk/switchvideooverlay/main.cpp  | 31 +++++++++++++---------
 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 dbe007c..e6ebf70 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 ea53ea1..476478d 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);

_______________________________________________
gstreamer-commits mailing list
gstreamer-commits@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/gstreamer-commits


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic