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.
This commit is contained in:
Rafał Dzięgiel
2021-07-08 20:33:04 +02:00
parent 8f79a76a51
commit 3bf636d46b

View File

@@ -330,7 +330,7 @@ gtk_clapper_gl_widget_key_event (GtkEventControllerKey * key_controller,
GstElement *element; GstElement *element;
if ((element = g_weak_ref_get (&clapper_widget->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); GdkEvent *event = gtk_event_controller_get_current_event (controller);
const gchar *str = _gdk_key_to_navigation_string (keyval); 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); GtkClapperGLWidget *clapper_widget = GTK_CLAPPER_GL_WIDGET (widget);
GstElement *element; 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 ((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); GdkEvent *event = gtk_event_controller_get_current_event (controller);
const gchar *key_type = const gchar *key_type =
gdk_event_get_event_type (event) == GDK_BUTTON_PRESS 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); GtkClapperGLWidget *clapper_widget = GTK_CLAPPER_GL_WIDGET (widget);
GstElement *element; GstElement *element;
if (x != clapper_widget->last_pos_x && y != clapper_widget->last_pos_y && if ((x == clapper_widget->last_pos_x && y == clapper_widget->last_pos_y) ||
(element = g_weak_ref_get (&clapper_widget->element))) { clapper_widget->display_width == 0 || clapper_widget->display_height == 0)
if (GST_IS_NAVIGATION (element)) { 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; gdouble stream_x, stream_y;
clapper_widget->last_pos_x = x; clapper_widget->last_pos_x = x;