From 3bf636d46bfe2b0d432c762859e4ea00aa3e6412 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Thu, 8 Jul 2021 20:33:04 +0200 Subject: [PATCH] sink: Do not send navigation events when not playing Before playback starts our video display size is zero, no point in sending navigation events in such case. Latest gstreamer git prints criticals in such case. Also do not send mouse navigaion when element is paused and skip keypresses when below paused state. --- lib/gst/clapper/gtk4/gtkclapperglwidget.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/gst/clapper/gtk4/gtkclapperglwidget.c b/lib/gst/clapper/gtk4/gtkclapperglwidget.c index bca815b5..4128c3d7 100644 --- a/lib/gst/clapper/gtk4/gtkclapperglwidget.c +++ b/lib/gst/clapper/gtk4/gtkclapperglwidget.c @@ -330,7 +330,7 @@ gtk_clapper_gl_widget_key_event (GtkEventControllerKey * key_controller, GstElement *element; if ((element = g_weak_ref_get (&clapper_widget->element))) { - if (GST_IS_NAVIGATION (element)) { + if (GST_IS_NAVIGATION (element) && element->current_state > GST_STATE_READY) { GdkEvent *event = gtk_event_controller_get_current_event (controller); const gchar *str = _gdk_key_to_navigation_string (keyval); @@ -419,8 +419,11 @@ gtk_clapper_gl_widget_button_event (GtkGestureClick * gesture, GtkClapperGLWidget *clapper_widget = GTK_CLAPPER_GL_WIDGET (widget); GstElement *element; + if (clapper_widget->display_width == 0 || clapper_widget->display_height == 0) + return FALSE; + if ((element = g_weak_ref_get (&clapper_widget->element))) { - if (GST_IS_NAVIGATION (element)) { + if (GST_IS_NAVIGATION (element) && element->current_state > GST_STATE_PAUSED) { GdkEvent *event = gtk_event_controller_get_current_event (controller); const gchar *key_type = gdk_event_get_event_type (event) == GDK_BUTTON_PRESS @@ -449,9 +452,12 @@ gtk_clapper_gl_widget_motion_event (GtkEventControllerMotion * motion_controller GtkClapperGLWidget *clapper_widget = GTK_CLAPPER_GL_WIDGET (widget); GstElement *element; - if (x != clapper_widget->last_pos_x && y != clapper_widget->last_pos_y && - (element = g_weak_ref_get (&clapper_widget->element))) { - if (GST_IS_NAVIGATION (element)) { + if ((x == clapper_widget->last_pos_x && y == clapper_widget->last_pos_y) || + clapper_widget->display_width == 0 || clapper_widget->display_height == 0) + return FALSE; + + if ((element = g_weak_ref_get (&clapper_widget->element))) { + if (GST_IS_NAVIGATION (element) && element->current_state > GST_STATE_PAUSED) { gdouble stream_x, stream_y; clapper_widget->last_pos_x = x;