diff --git a/lib/gst/clapper/gtk4/gstgtkbasesink.c b/lib/gst/clapper/gtk4/gstgtkbasesink.c index 1f35a9de..95e1871f 100644 --- a/lib/gst/clapper/gtk4/gstgtkbasesink.c +++ b/lib/gst/clapper/gtk4/gstgtkbasesink.c @@ -117,14 +117,6 @@ gst_gtk_base_sink_class_init (GstGtkBaseSinkClass * klass) "The pixel aspect ratio of the device", DEFAULT_PAR_N, DEFAULT_PAR_D, G_MAXINT, 1, 1, 1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - /* Disabling alpha was removed in GTK4 */ -#if !defined(BUILD_FOR_GTK4) - g_object_class_install_property (gobject_class, PROP_IGNORE_ALPHA, - g_param_spec_boolean ("ignore-alpha", "Ignore Alpha", - "When enabled, alpha will be ignored and converted to black", - DEFAULT_IGNORE_ALPHA, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); -#endif - g_object_class_install_property (gobject_class, PROP_IGNORE_TEXTURES, g_param_spec_boolean ("ignore-textures", "Ignore Textures", "When enabled, textures will be ignored and not drawn", @@ -204,11 +196,7 @@ gst_gtk_base_sink_get_widget (GstGtkBaseSink * gtk_sink) /* Ensure GTK is initialized, this has no side effect if it was already * initialized. Also, we do that lazily, so the application can be first */ - if (!gtk_init_check ( -#if !defined(BUILD_FOR_GTK4) - NULL, NULL -#endif - )) { + if (!gtk_init_check ()) { GST_ERROR_OBJECT (gtk_sink, "Could not ensure GTK initialization."); return NULL; } @@ -223,12 +211,6 @@ gst_gtk_base_sink_get_widget (GstGtkBaseSink * gtk_sink) gtk_sink->bind_pixel_aspect_ratio = g_object_bind_property (gtk_sink, "pixel-aspect-ratio", gtk_sink->widget, "pixel-aspect-ratio", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); -#if !defined(BUILD_FOR_GTK4) - gtk_sink->bind_ignore_alpha = - g_object_bind_property (gtk_sink, "ignore-alpha", gtk_sink->widget, - "ignore-alpha", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); -#endif - gtk_sink->bind_ignore_textures = g_object_bind_property (gtk_sink, "ignore-textures", gtk_sink->widget, "ignore-textures", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); @@ -352,16 +334,13 @@ gst_gtk_base_sink_start_on_main (GstBaseSink * bsink) GstGtkBaseSink *gst_sink = GST_GTK_BASE_SINK (bsink); GstGtkBaseSinkClass *klass = GST_GTK_BASE_SINK_GET_CLASS (bsink); GtkWidget *toplevel; -#if defined(BUILD_FOR_GTK4) GtkRoot *root; -#endif if (gst_gtk_base_sink_get_widget (gst_sink) == NULL) return FALSE; /* After this point, gtk_sink->widget will always be set */ -#if defined(BUILD_FOR_GTK4) root = gtk_widget_get_root (GTK_WIDGET (gst_sink->widget)); if (!GTK_IS_ROOT (root)) { GtkWidget *parent = gtk_widget_get_parent (GTK_WIDGET (gst_sink->widget)); @@ -371,35 +350,19 @@ gst_gtk_base_sink_start_on_main (GstBaseSink * bsink) parent = temp_parent; } toplevel = (parent) ? parent : GTK_WIDGET (gst_sink->widget); -#else - toplevel = gtk_widget_get_toplevel (GTK_WIDGET (gst_sink->widget)); - if (!gtk_widget_is_toplevel (toplevel)) { -#endif + /* sanity check */ g_assert (klass->window_title); /* User did not add widget its own UI, let's popup a new GtkWindow to * make gst-launch-1.0 work. */ - gst_sink->window = gtk_window_new ( -#if !defined(BUILD_FOR_GTK4) - GTK_WINDOW_TOPLEVEL -#endif - ); + gst_sink->window = gtk_window_new (); gtk_window_set_default_size (GTK_WINDOW (gst_sink->window), 640, 480); gtk_window_set_title (GTK_WINDOW (gst_sink->window), klass->window_title); -#if defined(BUILD_FOR_GTK4) - gtk_window_set_child (GTK_WINDOW ( -#else - gtk_container_add (GTK_CONTAINER ( -#endif - gst_sink->window), toplevel); + gtk_window_set_child (GTK_WINDOW (gst_sink->window), toplevel); gst_sink->window_destroy_id = g_signal_connect ( -#if defined(BUILD_FOR_GTK4) GTK_WINDOW (gst_sink->window), -#else - gst_sink->window, -#endif "destroy", G_CALLBACK (window_destroy_cb), gst_sink); } @@ -419,11 +382,7 @@ gst_gtk_base_sink_stop_on_main (GstBaseSink * bsink) GstGtkBaseSink *gst_sink = GST_GTK_BASE_SINK (bsink); if (gst_sink->window) { -#if defined(BUILD_FOR_GTK4) gtk_window_destroy (GTK_WINDOW (gst_sink->window)); -#else - gtk_widget_destroy (gst_sink->window); -#endif gst_sink->window = NULL; gst_sink->widget = NULL; } @@ -446,11 +405,7 @@ gst_gtk_base_sink_stop (GstBaseSink * bsink) static void gst_gtk_window_show_all_and_unref (GtkWidget * window) { -#if defined(BUILD_FOR_GTK4) gtk_window_present (GTK_WINDOW (window)); -#else - gtk_widget_show_all (window); -#endif g_object_unref (window); } diff --git a/lib/gst/clapper/gtk4/gtkconfig.h b/lib/gst/clapper/gtk4/gtkconfig.h index ecbf9558..76ee9d11 100644 --- a/lib/gst/clapper/gtk4/gtkconfig.h +++ b/lib/gst/clapper/gtk4/gtkconfig.h @@ -18,14 +18,7 @@ * Boston, MA 02110-1301, USA. */ -#if defined(BUILD_FOR_GTK4) #define GTKCONFIG_PLUGIN gtk4 #define GTKCONFIG_NAME "GTK4" #define GTKCONFIG_SINK "gtk4sink" #define GTKCONFIG_GLSINK "gtk4glsink" -#else -#define GTKCONFIG_PLUGIN gtk -#define GTKCONFIG_NAME "GTK" -#define GTKCONFIG_SINK "gtksink" -#define GTKCONFIG_GLSINK "gtkglsink" -#endif diff --git a/lib/gst/clapper/gtk4/gtkgstbasewidget.c b/lib/gst/clapper/gtk4/gtkgstbasewidget.c index 5ed70f3c..6a1079b6 100644 --- a/lib/gst/clapper/gtk4/gtkgstbasewidget.c +++ b/lib/gst/clapper/gtk4/gtkgstbasewidget.c @@ -77,7 +77,6 @@ gtk_gst_base_widget_get_preferred_height (GtkWidget * widget, gint * min, *natural = video_height; } -#if defined(BUILD_FOR_GTK4) static void gtk_gst_base_widget_measure (GtkWidget * widget, GtkOrientation orientation, gint for_size, gint * min, gint * natural, @@ -108,7 +107,6 @@ gtk_gst_base_widget_size_allocate (GtkWidget * widget, gtk_gl_area_queue_render (GTK_GL_AREA (widget)); } -#endif static void gtk_gst_base_widget_set_property (GObject * object, guint prop_id, @@ -276,25 +274,6 @@ _gdk_key_to_navigation_string (guint keyval) } } -static GdkEvent * -_get_current_event (GtkEventController * controller) -{ -#if defined(BUILD_FOR_GTK4) - return gtk_event_controller_get_current_event (controller); -#else - return gtk_get_current_event (); -#endif -} - -static void -_gdk_event_free (GdkEvent * event) -{ -#if !defined(BUILD_FOR_GTK4) - if (event) - gdk_event_free (event); -#endif -} - static gboolean gtk_gst_base_widget_key_event (GtkEventControllerKey * key_controller, guint keyval, guint keycode, GdkModifierType state) @@ -306,7 +285,7 @@ gtk_gst_base_widget_key_event (GtkEventControllerKey * key_controller, if ((element = g_weak_ref_get (&base_widget->element))) { if (GST_IS_NAVIGATION (element)) { - GdkEvent *event = _get_current_event (controller); + GdkEvent *event = gtk_event_controller_get_current_event (controller); const gchar *str = _gdk_key_to_navigation_string (keyval); if (str) { @@ -315,7 +294,6 @@ gtk_gst_base_widget_key_event (GtkEventControllerKey * key_controller, GDK_KEY_PRESS ? "key-press" : "key-release"; gst_navigation_send_key_event (GST_NAVIGATION (element), key_type, str); } - _gdk_event_free (event); } g_object_unref (element); } @@ -387,12 +365,7 @@ _display_size_to_stream_size (GtkGstBaseWidget * base_widget, gdouble x, } static gboolean -gtk_gst_base_widget_button_event ( -#if defined(BUILD_FOR_GTK4) - GtkGestureClick * gesture, -#else - GtkGestureMultiPress * gesture, -#endif +gtk_gst_base_widget_button_event (GtkGestureClick * gesture, gint n_press, gdouble x, gdouble y) { GtkEventController *controller = GTK_EVENT_CONTROLLER (gesture); @@ -402,28 +375,18 @@ gtk_gst_base_widget_button_event ( if ((element = g_weak_ref_get (&base_widget->element))) { if (GST_IS_NAVIGATION (element)) { - GdkEvent *event = _get_current_event (controller); + GdkEvent *event = gtk_event_controller_get_current_event (controller); const gchar *key_type = gdk_event_get_event_type (event) == GDK_BUTTON_PRESS ? "mouse-button-press" : "mouse-button-release"; gdouble stream_x, stream_y; -#if !defined(BUILD_FOR_GTK4) - guint button; - gdk_event_get_button (event, &button); -#endif _display_size_to_stream_size (base_widget, x, y, &stream_x, &stream_y); gst_navigation_send_mouse_event (GST_NAVIGATION (element), key_type, -#if defined(BUILD_FOR_GTK4) /* Gesture is set to ignore other buttons so we do not have to check */ GDK_BUTTON_PRIMARY, -#else - button, -#endif stream_x, stream_y); - - _gdk_event_free (event); } g_object_unref (element); } @@ -486,13 +449,8 @@ gtk_gst_base_widget_class_init (GtkGstBaseWidgetClass * klass) "When enabled, textures will be ignored and not drawn", DEFAULT_IGNORE_TEXTURES, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); -#if defined(BUILD_FOR_GTK4) widget_klass->measure = gtk_gst_base_widget_measure; widget_klass->size_allocate = gtk_gst_base_widget_size_allocate; -#else - widget_klass->get_preferred_width = gtk_gst_base_widget_get_preferred_width; - widget_klass->get_preferred_height = gtk_gst_base_widget_get_preferred_height; -#endif GST_DEBUG_CATEGORY_INIT (gst_debug_gtk_base_widget, "gtkbasewidget", 0, "GTK Video Base Widget"); @@ -513,36 +471,22 @@ gtk_gst_base_widget_init (GtkGstBaseWidget * widget) g_weak_ref_init (&widget->element, NULL); g_mutex_init (&widget->lock); - widget->key_controller = gtk_event_controller_key_new ( -#if !defined(BUILD_FOR_GTK4) - GTK_WIDGET (widget) -#endif - ); + widget->key_controller = gtk_event_controller_key_new (); g_signal_connect (widget->key_controller, "key-pressed", G_CALLBACK (gtk_gst_base_widget_key_event), NULL); g_signal_connect (widget->key_controller, "key-released", G_CALLBACK (gtk_gst_base_widget_key_event), NULL); - widget->motion_controller = gtk_event_controller_motion_new ( -#if !defined(BUILD_FOR_GTK4) - GTK_WIDGET (widget) -#endif - ); + widget->motion_controller = gtk_event_controller_motion_new (); g_signal_connect (widget->motion_controller, "motion", G_CALLBACK (gtk_gst_base_widget_motion_event), NULL); - widget->click_gesture = -#if defined(BUILD_FOR_GTK4) - gtk_gesture_click_new (); -#else - gtk_gesture_multi_press_new (GTK_WIDGET (widget)); -#endif + widget->click_gesture = gtk_gesture_click_new (); g_signal_connect (widget->click_gesture, "pressed", G_CALLBACK (gtk_gst_base_widget_button_event), NULL); g_signal_connect (widget->click_gesture, "released", G_CALLBACK (gtk_gst_base_widget_button_event), NULL); -#if defined(BUILD_FOR_GTK4) /* Otherwise widget in grid will appear as a 1x1px * video which might be misleading for users */ gtk_widget_set_hexpand (GTK_WIDGET (widget), TRUE); @@ -556,7 +500,6 @@ gtk_gst_base_widget_init (GtkGstBaseWidget * widget) gtk_widget_add_controller (GTK_WIDGET (widget), widget->motion_controller); gtk_widget_add_controller (GTK_WIDGET (widget), GTK_EVENT_CONTROLLER (widget->click_gesture)); -#endif gtk_widget_set_can_focus (GTK_WIDGET (widget), TRUE); } @@ -566,14 +509,6 @@ gtk_gst_base_widget_finalize (GObject * object) { GtkGstBaseWidget *widget = GTK_GST_BASE_WIDGET (object); - /* GTK4 takes ownership of EventControllers - * while GTK3 still needs manual unref */ -#if !defined(BUILD_FOR_GTK4) - g_object_unref (widget->key_controller); - g_object_unref (widget->motion_controller); - g_object_unref (widget->click_gesture); -#endif - gst_buffer_replace (&widget->pending_buffer, NULL); gst_buffer_replace (&widget->buffer, NULL); g_mutex_clear (&widget->lock); diff --git a/lib/gst/clapper/gtk4/gtkgstbasewidget.h b/lib/gst/clapper/gtk4/gtkgstbasewidget.h index a8e899b2..4532b821 100644 --- a/lib/gst/clapper/gtk4/gtkgstbasewidget.h +++ b/lib/gst/clapper/gtk4/gtkgstbasewidget.h @@ -26,10 +26,6 @@ #include #include -#if !defined(BUILD_FOR_GTK4) -#include -#endif - #define GTK_GST_BASE_WIDGET(w) ((GtkGstBaseWidget *)(w)) #define GTK_GST_BASE_WIDGET_CLASS(k) ((GtkGstBaseWidgetClass *)(k)) #define GTK_GST_BASE_WIDGET_LOCK(w) g_mutex_lock(&((GtkGstBaseWidget*)(w))->lock) diff --git a/lib/gst/clapper/gtk4/gtkgstglwidget.c b/lib/gst/clapper/gtk4/gtkgstglwidget.c index 2903fb0b..6b3ee8df 100644 --- a/lib/gst/clapper/gtk4/gtkgstglwidget.c +++ b/lib/gst/clapper/gtk4/gtkgstglwidget.c @@ -31,20 +31,12 @@ #include #if GST_GL_HAVE_WINDOW_X11 && defined (GDK_WINDOWING_X11) -#if defined(BUILD_FOR_GTK4) #include -#else -#include -#endif #include #endif #if GST_GL_HAVE_WINDOW_WAYLAND && defined (GDK_WINDOWING_WAYLAND) -#if defined(BUILD_FOR_GTK4) #include -#else -#include -#endif #include #endif @@ -419,12 +411,6 @@ gtk_gst_gl_widget_init (GtkGstGLWidget * gst_widget) GST_INFO ("Created %" GST_PTR_FORMAT, priv->display); - /* GTK4 always has alpha */ -#if !defined(BUILD_FOR_GTK4) - gtk_gl_area_set_has_alpha (GTK_GL_AREA (gst_widget), - !base_widget->ignore_alpha); -#endif - gtk_gl_area_set_auto_render (GTK_GL_AREA (gst_widget), FALSE); } diff --git a/lib/gst/clapper/meson.build b/lib/gst/clapper/meson.build index 961d2f14..456706d8 100644 --- a/lib/gst/clapper/meson.build +++ b/lib/gst/clapper/meson.build @@ -32,7 +32,6 @@ gstclapper_defines = [ '-DBUILDING_GST_CLAPPER', '-DGST_USE_UNSTABLE_API', '-DHAVE_GTK_GL', - '-DBUILD_FOR_GTK4', ] gtk_deps = [gstgl_dep, gstglproto_dep] have_gtk_gl_windowing = false