From: Seungha Yang Date: Mon, 1 Aug 2022 19:16:31 +0000 (+0900) Subject: d3d11videosink: Early terminate mouse/keyboard event handling X-Git-Tag: 1.22.0~1191 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7d4a1a5beb6102a8e84bdffe424964d7edf98571;p=platform%2Fupstream%2Fgstreamer.git d3d11videosink: Early terminate mouse/keyboard event handling ... and add missing null check (plus coding style fix) Part-of: --- diff --git a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11videosink.cpp b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11videosink.cpp index 3b516b0..76389d9 100644 --- a/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11videosink.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d11/gstd3d11videosink.cpp @@ -678,49 +678,50 @@ static void gst_d3d11_video_sink_key_event (GstD3D11Window * window, const gchar * event, const gchar * key, GstD3D11VideoSink * self) { - GstEvent *key_event = NULL; - - if (self->enable_navigation_events) { - GST_LOG_OBJECT (self, "send key event %s, key %s", event, key); - if (0 == g_strcmp0 ("key-press", event)) - key_event = - gst_navigation_event_new_key_press (key, - GST_NAVIGATION_MODIFIER_NONE); - else if (0 == g_strcmp0 ("key-release", event)) - key_event = - gst_navigation_event_new_key_release (key, - GST_NAVIGATION_MODIFIER_NONE); - - if (event) - gst_navigation_send_event_simple (GST_NAVIGATION (self), key_event); + GstEvent *key_event; + + if (!self->enable_navigation_events || !event || !key) + return; + + GST_LOG_OBJECT (self, "send key event %s, key %s", event, key); + if (g_strcmp0 ("key-press", event) == 0) { + key_event = gst_navigation_event_new_key_press (key, + GST_NAVIGATION_MODIFIER_NONE); + } else if (g_strcmp0 ("key-release", event) == 0) { + key_event = gst_navigation_event_new_key_release (key, + GST_NAVIGATION_MODIFIER_NONE); + } else { + return; } + + gst_navigation_send_event_simple (GST_NAVIGATION (self), key_event); } static void gst_d3d11_video_mouse_key_event (GstD3D11Window * window, const gchar * event, gint button, gdouble x, gdouble y, GstD3D11VideoSink * self) { - GstEvent *mouse_event = NULL; - - if (self->enable_navigation_events) { - GST_LOG_OBJECT (self, - "send mouse event %s, button %d (%.1f, %.1f)", event, button, x, y); - if (0 == g_strcmp0 ("mouse-button-press", event)) - mouse_event = - gst_navigation_event_new_mouse_button_press (button, x, y, - GST_NAVIGATION_MODIFIER_NONE); - else if (0 == g_strcmp0 ("mouse-button-release", event)) - mouse_event = - gst_navigation_event_new_mouse_button_release (button, x, y, - GST_NAVIGATION_MODIFIER_NONE); - else if (0 == g_strcmp0 ("mouse-move", event)) - mouse_event = - gst_navigation_event_new_mouse_move (x, y, - GST_NAVIGATION_MODIFIER_NONE); - - if (event) - gst_navigation_send_event_simple (GST_NAVIGATION (self), mouse_event); + GstEvent *mouse_event; + + if (!self->enable_navigation_events || !event) + return; + + GST_LOG_OBJECT (self, + "send mouse event %s, button %d (%.1f, %.1f)", event, button, x, y); + if (g_strcmp0 ("mouse-button-press", event) == 0) { + mouse_event = gst_navigation_event_new_mouse_button_press (button, x, y, + GST_NAVIGATION_MODIFIER_NONE); + } else if (g_strcmp0 ("mouse-button-release", event) == 0) { + mouse_event = gst_navigation_event_new_mouse_button_release (button, x, y, + GST_NAVIGATION_MODIFIER_NONE); + } else if (g_strcmp0 ("mouse-move", event) == 0) { + mouse_event = gst_navigation_event_new_mouse_move (x, y, + GST_NAVIGATION_MODIFIER_NONE); + } else { + return; } + + gst_navigation_send_event_simple (GST_NAVIGATION (self), mouse_event); } static gboolean