mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-22 09:41:07 +00:00
d3d11videosink: Handle double click and modifier
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6491>
This commit is contained in:
parent
e1910d2be1
commit
e0def6b355
4 changed files with 56 additions and 15 deletions
|
@ -1183,8 +1183,8 @@ gst_d3d11_video_sink_key_event (GstD3D11Window * window, const gchar * event,
|
|||
}
|
||||
|
||||
static void
|
||||
gst_d3d11_video_mouse_key_event (GstD3D11Window * window, const gchar * event,
|
||||
gint button, gdouble x, gdouble y, GstD3D11VideoSink * self)
|
||||
gst_d3d11_video_sink_mouse_event (GstD3D11Window * window, const gchar * event,
|
||||
gint button, gdouble x, gdouble y, guint modifier, GstD3D11VideoSink * self)
|
||||
{
|
||||
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);
|
||||
if (g_strcmp0 ("mouse-button-press", event) == 0) {
|
||||
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) {
|
||||
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) {
|
||||
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 {
|
||||
return;
|
||||
}
|
||||
|
@ -1325,7 +1328,7 @@ done:
|
|||
g_signal_connect (self->window, "key-event",
|
||||
G_CALLBACK (gst_d3d11_video_sink_key_event), self);
|
||||
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_CALLBACK (gst_d3d11_video_sink_present), self);
|
||||
|
||||
|
|
|
@ -178,7 +178,8 @@ gst_d3d11_window_class_init (GstD3D11WindowClass * klass)
|
|||
d3d11_window_signals[SIGNAL_MOUSE_EVENT] =
|
||||
g_signal_new ("mouse-event", G_TYPE_FROM_CLASS (klass),
|
||||
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] =
|
||||
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
|
||||
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;
|
||||
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,
|
||||
event, button, x, y);
|
||||
event, button, x, y, modifier);
|
||||
}
|
||||
|
||||
typedef struct
|
||||
|
|
|
@ -232,7 +232,8 @@ void gst_d3d11_window_on_mouse_event (GstD3D11Window * window,
|
|||
const gchar * event,
|
||||
gint button,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
gdouble y,
|
||||
guint modifier);
|
||||
|
||||
/* utils */
|
||||
GstD3D11WindowNativeType gst_d3d11_window_get_native_type_from_handle (guintptr handle);
|
||||
|
|
|
@ -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,
|
||||
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
|
||||
{
|
||||
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);
|
||||
gint button;
|
||||
const gchar *event = NULL;
|
||||
const gchar *event = nullptr;
|
||||
guint modifier = 0;
|
||||
|
||||
if (!window->enable_navigation_events)
|
||||
return;
|
||||
|
@ -740,6 +750,10 @@ gst_d3d11_window_win32_on_mouse_event (GstD3D11WindowWin32 * self,
|
|||
button = 1;
|
||||
event = "mouse-button-release";
|
||||
break;
|
||||
case WM_LBUTTONDBLCLK:
|
||||
button = 1;
|
||||
event = "mouse-double-click";
|
||||
break;
|
||||
case WM_RBUTTONDOWN:
|
||||
button = 2;
|
||||
event = "mouse-button-press";
|
||||
|
@ -748,6 +762,10 @@ gst_d3d11_window_win32_on_mouse_event (GstD3D11WindowWin32 * self,
|
|||
button = 2;
|
||||
event = "mouse-button-release";
|
||||
break;
|
||||
case WM_RBUTTONDBLCLK:
|
||||
button = 2;
|
||||
event = "mouse-double-click";
|
||||
break;
|
||||
case WM_MBUTTONDOWN:
|
||||
button = 3;
|
||||
event = "mouse-button-press";
|
||||
|
@ -756,13 +774,28 @@ gst_d3d11_window_win32_on_mouse_event (GstD3D11WindowWin32 * self,
|
|||
button = 3;
|
||||
event = "mouse-button-release";
|
||||
break;
|
||||
default:
|
||||
case WM_MBUTTONDBLCLK:
|
||||
button = 3;
|
||||
event = "mouse-double-click";
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
if (event)
|
||||
gst_d3d11_window_on_mouse_event (window,
|
||||
event, button, (gdouble) LOWORD (lParam), (gdouble) HIWORD (lParam));
|
||||
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,
|
||||
event, button, (gdouble) GET_X_LPARAM (lParam),
|
||||
(gdouble) GET_Y_LPARAM (lParam), modifier);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -795,6 +828,9 @@ gst_d3d11_window_win32_handle_window_proc (GstD3D11WindowWin32 * self,
|
|||
case WM_MBUTTONDOWN:
|
||||
case WM_MBUTTONUP:
|
||||
case WM_MOUSEMOVE:
|
||||
case WM_LBUTTONDBLCLK:
|
||||
case WM_RBUTTONDBLCLK:
|
||||
case WM_MBUTTONDBLCLK:
|
||||
gst_d3d11_window_win32_on_mouse_event (self, hWnd, uMsg, wParam, lParam);
|
||||
break;
|
||||
case WM_SYSKEYDOWN:
|
||||
|
|
Loading…
Reference in a new issue