From e1910d2be15e3adba78e9dd76d6d4d02c2468bc4 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Sun, 31 Mar 2024 00:30:03 +0900 Subject: [PATCH] navigation: Define mouse double click event Windows and UI toolkits define mouse double click events Part-of: --- girs/GstVideo-1.0.gir | 61 ++++++++++++++++++- .../gst-libs/gst/video/navigation.c | 35 ++++++++++- .../gst-libs/gst/video/navigation.h | 19 ++++++ 3 files changed, 111 insertions(+), 4 deletions(-) diff --git a/girs/GstVideo-1.0.gir b/girs/GstVideo-1.0.gir index 5b23131504..4ff3931316 100644 --- a/girs/GstVideo-1.0.gir +++ b/girs/GstVideo-1.0.gir @@ -991,6 +991,33 @@ Shift and Alt). a bit-mask representing the state of the modifier keys (e.g. Control, +Shift and Alt). + + + + + + Create a new navigation event for the given key mouse double click. + + + a new #GstEvent + + + + + The number of the pressed mouse button. + + + + The x coordinate of the mouse cursor. + + + + The y coordinate of the mouse cursor. + + + + a bit-mask representing the state of the modifier keys (e.g. Control, Shift and Alt). @@ -1876,7 +1903,7 @@ implementing the #GstNavigation interface. The type of mouse event, as a text string. Recognised values are -"mouse-button-press", "mouse-button-release" and "mouse-move". +"mouse-button-press", "mouse-button-release", "mouse-move" and "mouse-double-click". @@ -2062,6 +2089,11 @@ from the event. An event cancelling all currently active touch points. + + A mouse button double click event. +Use gst_navigation_event_parse_mouse_button_event() to extract the details +from the event. + Navigation interface. @@ -16768,6 +16800,33 @@ Shift and Alt). a bit-mask representing the state of the modifier keys (e.g. Control, +Shift and Alt). + + + + + + Create a new navigation event for the given key mouse double click. + + + a new #GstEvent + + + + + The number of the pressed mouse button. + + + + The x coordinate of the mouse cursor. + + + + The y coordinate of the mouse cursor. + + + + a bit-mask representing the state of the modifier keys (e.g. Control, Shift and Alt). diff --git a/subprojects/gst-plugins-base/gst-libs/gst/video/navigation.c b/subprojects/gst-plugins-base/gst-libs/gst/video/navigation.c index 8cf2154b74..079422dc80 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/video/navigation.c +++ b/subprojects/gst-plugins-base/gst-libs/gst/video/navigation.c @@ -132,7 +132,7 @@ gst_navigation_send_key_event (GstNavigation * navigation, const char *event, * gst_navigation_send_mouse_event: * @navigation: The navigation interface instance * @event: The type of mouse event, as a text string. Recognised values are - * "mouse-button-press", "mouse-button-release" and "mouse-move". + * "mouse-button-press", "mouse-button-release", "mouse-move" and "mouse-double-click". * @button: The button number of the button being pressed or released. Pass 0 * for mouse-move events. * @x: The x coordinate of the mouse event. @@ -151,7 +151,8 @@ gst_navigation_send_mouse_event (GstNavigation * navigation, const char *event, g_return_if_fail (GST_IS_NAVIGATION (navigation)); g_return_if_fail (g_strcmp0 (event, "mouse-button-press") == 0 || g_strcmp0 (event, "mouse-button-release") == 0 || - g_strcmp0 (event, "mouse-move") == 0); + g_strcmp0 (event, "mouse-move") == 0 || + g_strcmp0 (event, "mouse-double-click") == 0); gst_navigation_send_event (navigation, gst_structure_new (GST_NAVIGATION_EVENT_NAME, "event", G_TYPE_STRING, @@ -807,6 +808,8 @@ gst_navigation_event_get_type (GstEvent * event) return GST_NAVIGATION_EVENT_TOUCH_MOTION; else if (g_str_equal (e_type, "touch-frame")) return GST_NAVIGATION_EVENT_TOUCH_FRAME; + else if (g_str_equal (e_type, "mouse-double-click")) + return GST_NAVIGATION_EVENT_MOUSE_DOUBLE_CLICK; return GST_NAVIGATION_EVENT_INVALID; } @@ -878,6 +881,31 @@ gst_navigation_event_new_mouse_button_press (gint button, gdouble x, gdouble y, "state", GST_TYPE_NAVIGATION_MODIFIER_TYPE, state, NULL)); } +/** + * gst_navigation_event_new_mouse_double_click: + * @button: The number of the pressed mouse button. + * @x: The x coordinate of the mouse cursor. + * @y: The y coordinate of the mouse cursor. + * @state: a bit-mask representing the state of the modifier keys (e.g. Control, + * Shift and Alt). + * + * Create a new navigation event for the given key mouse double click. + * + * Returns: (transfer full): a new #GstEvent + * + * Since: 1.26 + */ +GstEvent * +gst_navigation_event_new_mouse_double_click (gint button, gdouble x, gdouble y, + GstNavigationModifierType state) +{ + return gst_event_new_navigation (gst_structure_new (GST_NAVIGATION_EVENT_NAME, + "event", G_TYPE_STRING, "mouse-double-click", + "button", G_TYPE_INT, button, "pointer_x", G_TYPE_DOUBLE, x, + "pointer_y", G_TYPE_DOUBLE, y, + "state", GST_TYPE_NAVIGATION_MODIFIER_TYPE, state, NULL)); +} + /** * gst_navigation_event_new_mouse_button_release: * @button: The number of the released mouse button. @@ -1163,7 +1191,8 @@ gst_navigation_event_parse_mouse_button_event (GstEvent * event, gint * button, e_type = gst_navigation_event_get_type (event); g_return_val_if_fail (e_type == GST_NAVIGATION_EVENT_MOUSE_BUTTON_PRESS || - e_type == GST_NAVIGATION_EVENT_MOUSE_BUTTON_RELEASE, FALSE); + e_type == GST_NAVIGATION_EVENT_MOUSE_BUTTON_RELEASE || + e_type == GST_NAVIGATION_EVENT_MOUSE_DOUBLE_CLICK, FALSE); s = gst_event_get_structure (event); if (x) diff --git a/subprojects/gst-plugins-base/gst-libs/gst/video/navigation.h b/subprojects/gst-plugins-base/gst-libs/gst/video/navigation.h index 650f58241a..7d34f2bfd6 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/video/navigation.h +++ b/subprojects/gst-plugins-base/gst-libs/gst/video/navigation.h @@ -371,6 +371,9 @@ gboolean gst_navigation_message_parse_event (GstMessage *message * of simultaneous touch events. (Since: 1.22) * @GST_NAVIGATION_EVENT_TOUCH_CANCEL: An event cancelling all currently active * touch points. (Since: 1.22) + * @GST_NAVIGATION_EVENT_MOUSE_DOUBLE_CLICK: A mouse button double click event. Use + * gst_navigation_event_parse_mouse_button_event() to extract the details from the + * event. (Since: 1.26) * * Enum values for the various events that an element implementing the * GstNavigation interface might send up the pipeline. Touch events have been @@ -447,6 +450,17 @@ typedef enum { * Since: 1.22 */ GST_NAVIGATION_EVENT_TOUCH_CANCEL = 12, + + /** + * GST_NAVIGATION_EVENT_MOUSE_DOUBLE_CLICK: + * + * A mouse button double click event. + * Use gst_navigation_event_parse_mouse_button_event() to extract the details + * from the event. + * + * Since: 1.26 + */ + GST_NAVIGATION_EVENT_MOUSE_DOUBLE_CLICK = 13, } GstNavigationEventType; GST_VIDEO_API @@ -465,6 +479,11 @@ GstEvent* gst_navigation_event_new_mouse_button_press (gint button, gdou gdouble y, GstNavigationModifierType state) G_GNUC_MALLOC; +GST_VIDEO_API +GstEvent* gst_navigation_event_new_mouse_double_click (gint button, gdouble x, + gdouble y, + GstNavigationModifierType state) G_GNUC_MALLOC; + GST_VIDEO_API GstEvent* gst_navigation_event_new_mouse_button_release (gint button, gdouble x, gdouble y,