d3d11videosink: Handle double click and modifier

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6491>
This commit is contained in:
Seungha Yang 2024-03-30 23:57:27 +09:00 committed by GStreamer Marge Bot
parent e1910d2be1
commit e0def6b355
4 changed files with 56 additions and 15 deletions

View file

@ -1183,8 +1183,8 @@ gst_d3d11_video_sink_key_event (GstD3D11Window * window, const gchar * event,
} }
static void static void
gst_d3d11_video_mouse_key_event (GstD3D11Window * window, const gchar * event, gst_d3d11_video_sink_mouse_event (GstD3D11Window * window, const gchar * event,
gint button, gdouble x, gdouble y, GstD3D11VideoSink * self) gint button, gdouble x, gdouble y, guint modifier, GstD3D11VideoSink * self)
{ {
GstEvent *mouse_event; GstEvent *mouse_event;
@ -1195,13 +1195,16 @@ gst_d3d11_video_mouse_key_event (GstD3D11Window * window, const gchar * event,
"send mouse event %s, button %d (%.1f, %.1f)", event, button, x, y); "send mouse event %s, button %d (%.1f, %.1f)", event, button, x, y);
if (g_strcmp0 ("mouse-button-press", event) == 0) { if (g_strcmp0 ("mouse-button-press", event) == 0) {
mouse_event = gst_navigation_event_new_mouse_button_press (button, x, y, mouse_event = gst_navigation_event_new_mouse_button_press (button, x, y,
GST_NAVIGATION_MODIFIER_NONE); (GstNavigationModifierType) modifier);
} else if (g_strcmp0 ("mouse-button-release", event) == 0) { } else if (g_strcmp0 ("mouse-button-release", event) == 0) {
mouse_event = gst_navigation_event_new_mouse_button_release (button, x, y, mouse_event = gst_navigation_event_new_mouse_button_release (button, x, y,
GST_NAVIGATION_MODIFIER_NONE); (GstNavigationModifierType) modifier);
} else if (g_strcmp0 ("mouse-move", event) == 0) { } else if (g_strcmp0 ("mouse-move", event) == 0) {
mouse_event = gst_navigation_event_new_mouse_move (x, y, mouse_event = gst_navigation_event_new_mouse_move (x, y,
GST_NAVIGATION_MODIFIER_NONE); (GstNavigationModifierType) modifier);
} else if (g_strcmp0 ("mouse-double-click", event) == 0) {
mouse_event = gst_navigation_event_new_mouse_double_click (button, x, y,
(GstNavigationModifierType) modifier);
} else { } else {
return; return;
} }
@ -1325,7 +1328,7 @@ done:
g_signal_connect (self->window, "key-event", g_signal_connect (self->window, "key-event",
G_CALLBACK (gst_d3d11_video_sink_key_event), self); G_CALLBACK (gst_d3d11_video_sink_key_event), self);
g_signal_connect (self->window, "mouse-event", g_signal_connect (self->window, "mouse-event",
G_CALLBACK (gst_d3d11_video_mouse_key_event), self); G_CALLBACK (gst_d3d11_video_sink_mouse_event), self);
g_signal_connect (self->window, "present", g_signal_connect (self->window, "present",
G_CALLBACK (gst_d3d11_video_sink_present), self); G_CALLBACK (gst_d3d11_video_sink_present), self);

View file

@ -178,7 +178,8 @@ gst_d3d11_window_class_init (GstD3D11WindowClass * klass)
d3d11_window_signals[SIGNAL_MOUSE_EVENT] = d3d11_window_signals[SIGNAL_MOUSE_EVENT] =
g_signal_new ("mouse-event", G_TYPE_FROM_CLASS (klass), g_signal_new ("mouse-event", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL,
G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_INT, G_TYPE_DOUBLE, G_TYPE_DOUBLE); G_TYPE_NONE, 5, G_TYPE_STRING, G_TYPE_INT, G_TYPE_DOUBLE, G_TYPE_DOUBLE,
G_TYPE_UINT);
d3d11_window_signals[SIGNAL_PRESENT] = d3d11_window_signals[SIGNAL_PRESENT] =
g_signal_new ("present", G_TYPE_FROM_CLASS (klass), g_signal_new ("present", G_TYPE_FROM_CLASS (klass),
@ -477,7 +478,7 @@ gst_d3d11_window_on_key_event (GstD3D11Window * window, const gchar * event,
void void
gst_d3d11_window_on_mouse_event (GstD3D11Window * window, const gchar * event, gst_d3d11_window_on_mouse_event (GstD3D11Window * window, const gchar * event,
gint button, gdouble x, gdouble y) gint button, gdouble x, gdouble y, guint modifier)
{ {
RECT render_rect; RECT render_rect;
GstVideoOrientationMethod method; GstVideoOrientationMethod method;
@ -567,7 +568,7 @@ gst_d3d11_window_on_mouse_event (GstD3D11Window * window, const gchar * event,
} }
g_signal_emit (window, d3d11_window_signals[SIGNAL_MOUSE_EVENT], 0, g_signal_emit (window, d3d11_window_signals[SIGNAL_MOUSE_EVENT], 0,
event, button, x, y); event, button, x, y, modifier);
} }
typedef struct typedef struct

View file

@ -232,7 +232,8 @@ void gst_d3d11_window_on_mouse_event (GstD3D11Window * window,
const gchar * event, const gchar * event,
gint button, gint button,
gdouble x, gdouble x,
gdouble y); gdouble y,
guint modifier);
/* utils */ /* utils */
GstD3D11WindowNativeType gst_d3d11_window_get_native_type_from_handle (guintptr handle); GstD3D11WindowNativeType gst_d3d11_window_get_native_type_from_handle (guintptr handle);

View file

@ -52,6 +52,15 @@ static LRESULT CALLBACK window_proc (HWND hWnd, UINT uMsg, WPARAM wParam,
static LRESULT FAR PASCAL sub_class_proc (HWND hWnd, UINT uMsg, WPARAM wParam, static LRESULT FAR PASCAL sub_class_proc (HWND hWnd, UINT uMsg, WPARAM wParam,
LPARAM lParam); LPARAM lParam);
/* windowsx.h */
#ifndef GET_X_LPARAM
#define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
#endif
#ifndef GET_Y_LPARAM
#define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
#endif
typedef enum typedef enum
{ {
GST_D3D11_WINDOW_WIN32_OVERLAY_STATE_NONE = 0, GST_D3D11_WINDOW_WIN32_OVERLAY_STATE_NONE = 0,
@ -722,7 +731,8 @@ gst_d3d11_window_win32_on_mouse_event (GstD3D11WindowWin32 * self,
{ {
GstD3D11Window *window = GST_D3D11_WINDOW (self); GstD3D11Window *window = GST_D3D11_WINDOW (self);
gint button; gint button;
const gchar *event = NULL; const gchar *event = nullptr;
guint modifier = 0;
if (!window->enable_navigation_events) if (!window->enable_navigation_events)
return; return;
@ -740,6 +750,10 @@ gst_d3d11_window_win32_on_mouse_event (GstD3D11WindowWin32 * self,
button = 1; button = 1;
event = "mouse-button-release"; event = "mouse-button-release";
break; break;
case WM_LBUTTONDBLCLK:
button = 1;
event = "mouse-double-click";
break;
case WM_RBUTTONDOWN: case WM_RBUTTONDOWN:
button = 2; button = 2;
event = "mouse-button-press"; event = "mouse-button-press";
@ -748,6 +762,10 @@ gst_d3d11_window_win32_on_mouse_event (GstD3D11WindowWin32 * self,
button = 2; button = 2;
event = "mouse-button-release"; event = "mouse-button-release";
break; break;
case WM_RBUTTONDBLCLK:
button = 2;
event = "mouse-double-click";
break;
case WM_MBUTTONDOWN: case WM_MBUTTONDOWN:
button = 3; button = 3;
event = "mouse-button-press"; event = "mouse-button-press";
@ -756,13 +774,28 @@ gst_d3d11_window_win32_on_mouse_event (GstD3D11WindowWin32 * self,
button = 3; button = 3;
event = "mouse-button-release"; event = "mouse-button-release";
break; break;
default: case WM_MBUTTONDBLCLK:
button = 3;
event = "mouse-double-click";
break; break;
default:
return;
} }
if (event) if ((wParam & MK_CONTROL) != 0)
modifier |= GST_NAVIGATION_MODIFIER_CONTROL_MASK;
if ((wParam & MK_LBUTTON) != 0)
modifier |= GST_NAVIGATION_MODIFIER_BUTTON1_MASK;
if ((wParam & MK_RBUTTON) != 0)
modifier |= GST_NAVIGATION_MODIFIER_BUTTON2_MASK;
if ((wParam & MK_MBUTTON) != 0)
modifier |= GST_NAVIGATION_MODIFIER_BUTTON3_MASK;
if ((wParam & MK_SHIFT) != 0)
modifier |= GST_NAVIGATION_MODIFIER_SHIFT_MASK;
gst_d3d11_window_on_mouse_event (window, gst_d3d11_window_on_mouse_event (window,
event, button, (gdouble) LOWORD (lParam), (gdouble) HIWORD (lParam)); event, button, (gdouble) GET_X_LPARAM (lParam),
(gdouble) GET_Y_LPARAM (lParam), modifier);
} }
static void static void
@ -795,6 +828,9 @@ gst_d3d11_window_win32_handle_window_proc (GstD3D11WindowWin32 * self,
case WM_MBUTTONDOWN: case WM_MBUTTONDOWN:
case WM_MBUTTONUP: case WM_MBUTTONUP:
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
case WM_LBUTTONDBLCLK:
case WM_RBUTTONDBLCLK:
case WM_MBUTTONDBLCLK:
gst_d3d11_window_win32_on_mouse_event (self, hWnd, uMsg, wParam, lParam); gst_d3d11_window_win32_on_mouse_event (self, hWnd, uMsg, wParam, lParam);
break; break;
case WM_SYSKEYDOWN: case WM_SYSKEYDOWN: