diff --git a/tests/examples/gtk/fxtest/fxtest.c b/tests/examples/gtk/fxtest/fxtest.c index a02272fa59..7242c9ba4b 100644 --- a/tests/examples/gtk/fxtest/fxtest.c +++ b/tests/examples/gtk/fxtest/fxtest.c @@ -3,11 +3,7 @@ #include #include -#ifdef WIN32 -#include -#else -#include -#endif +#include "../gstgtk.h" #include @@ -19,12 +15,8 @@ expose_cb (GtkWidget * widget, GdkEventExpose * event, gpointer data) GstXOverlay *overlay = GST_X_OVERLAY (gst_bin_get_by_interface (GST_BIN (data), GST_TYPE_X_OVERLAY)); -#ifdef WIN32 - gst_x_overlay_set_xwindow_id (overlay, - (gulong) GDK_WINDOW_HWND (widget->window)); -#else - gst_x_overlay_set_xwindow_id (overlay, GDK_WINDOW_XWINDOW (widget->window)); -#endif + + gst_x_overlay_set_gtk_window (overlay, widget); return FALSE; } diff --git a/tests/examples/gtk/fxtest/pixbufdrop.c b/tests/examples/gtk/fxtest/pixbufdrop.c index 4dba23c36e..9ebe166c45 100644 --- a/tests/examples/gtk/fxtest/pixbufdrop.c +++ b/tests/examples/gtk/fxtest/pixbufdrop.c @@ -3,11 +3,7 @@ #include #include -#ifdef WIN32 -#include -#else -#include -#endif +#include "../gstgtk.h" #include @@ -33,13 +29,7 @@ create_window (GstBus * bus, GstMessage * message, GtkWidget * widget) if (!gst_structure_has_name (message->structure, "prepare-xwindow-id")) return GST_BUS_PASS; -#ifdef WIN32 - gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (GST_MESSAGE_SRC (message)), - (gulong) GDK_WINDOW_HWND (widget->window)); -#else - gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (GST_MESSAGE_SRC (message)), - GDK_WINDOW_XWINDOW (widget->window)); -#endif + gst_x_overlay_set_gtk_window (GST_X_OVERLAY (GST_MESSAGE_SRC (message)), widget); gst_message_unref (message); diff --git a/tests/examples/gtk/gstgtk.c b/tests/examples/gtk/gstgtk.c new file mode 100644 index 0000000000..3685c87719 --- /dev/null +++ b/tests/examples/gtk/gstgtk.c @@ -0,0 +1,32 @@ + +#include "gstgtk.h" + +#if defined(GDK_WINDOWING_WIN32) +#include +#elif defined(GDK_WINDOWING_X11) +#include +#elif defined(GDK_WINDOWING_QUARTZ) +#include +#else +#error unimplemented GTK backend +#endif + + +void +gst_x_overlay_set_gtk_window (GstXOverlay *xoverlay, GtkWidget *window) +{ + +#if defined(GDK_WINDOWING_WIN32) + gst_x_overlay_set_xwindow_id (xoverlay, (gulong)GDK_WINDOW_HWND(window->window)); +#elif defined(GDK_WINDOWING_QUARTZ) + gst_x_overlay_set_xwindow_id (xoverlay, + (gulong)gdk_quartz_window_get_nswindow (window->window)); +#elif defined(GDK_WINDOWING_X11) + gst_x_overlay_set_xwindow_id (xoverlay, GDK_WINDOW_XWINDOW(window->window)); +#else +#error unimplemented GTK backend +#endif + +} + +