mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-14 13:21:28 +00:00
d3d11: implement mouse wheel events
Adittion of d3d11 support for WM_MOUSEWHEEL and WM_MOUSEHWHEEL events, which are triggered when the mouse is scrolled vertically or horizontally respectively. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7705>
This commit is contained in:
parent
ba94af0285
commit
6bbddc683d
4 changed files with 79 additions and 3 deletions
|
@ -1212,6 +1212,27 @@ gst_d3d11_video_sink_mouse_event (GstD3D11Window * window, const gchar * event,
|
|||
gst_navigation_send_event_simple (GST_NAVIGATION (self), mouse_event);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_d3d11_video_sink_mouse_scroll_event (GstD3D11Window * window,
|
||||
const gchar * event, gdouble x, gdouble y, gint delta_x, gint delta_y,
|
||||
guint modifier, GstD3D11VideoSink * self)
|
||||
{
|
||||
GstEvent *mouse_event;
|
||||
|
||||
if (!self->enable_navigation_events || !event)
|
||||
return;
|
||||
|
||||
GST_LOG_OBJECT (self, "send mouse scroll event %s,", event);
|
||||
if (g_strcmp0 ("mouse-scroll", event) == 0) {
|
||||
mouse_event = gst_navigation_event_new_mouse_scroll (x, y, delta_x,
|
||||
delta_y, (GstNavigationModifierType) modifier);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
gst_navigation_send_event_simple (GST_NAVIGATION (self), mouse_event);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_d3d11_video_sink_present (GstD3D11Window * window, GstD3D11Device * device,
|
||||
ID3D11RenderTargetView * rtv, GstD3D11VideoSink * self)
|
||||
|
@ -1329,6 +1350,8 @@ done:
|
|||
G_CALLBACK (gst_d3d11_video_sink_key_event), self);
|
||||
g_signal_connect (self->window, "mouse-event",
|
||||
G_CALLBACK (gst_d3d11_video_sink_mouse_event), self);
|
||||
g_signal_connect (self->window, "mouse-scroll-event",
|
||||
G_CALLBACK (gst_d3d11_video_sink_mouse_scroll_event), self);
|
||||
g_signal_connect (self->window, "present",
|
||||
G_CALLBACK (gst_d3d11_video_sink_present), self);
|
||||
|
||||
|
|
|
@ -67,6 +67,7 @@ enum
|
|||
{
|
||||
SIGNAL_KEY_EVENT,
|
||||
SIGNAL_MOUSE_EVENT,
|
||||
SIGNAL_MOUSE_SCROLL_EVENT,
|
||||
SIGNAL_PRESENT,
|
||||
SIGNAL_LAST
|
||||
};
|
||||
|
@ -181,6 +182,12 @@ gst_d3d11_window_class_init (GstD3D11WindowClass * klass)
|
|||
G_TYPE_NONE, 5, G_TYPE_STRING, G_TYPE_INT, G_TYPE_DOUBLE, G_TYPE_DOUBLE,
|
||||
G_TYPE_UINT);
|
||||
|
||||
d3d11_window_signals[SIGNAL_MOUSE_SCROLL_EVENT] =
|
||||
g_signal_new ("mouse-scroll-event", G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 6, G_TYPE_STRING, G_TYPE_DOUBLE, G_TYPE_DOUBLE,
|
||||
G_TYPE_INT, G_TYPE_INT, G_TYPE_UINT);
|
||||
|
||||
d3d11_window_signals[SIGNAL_PRESENT] =
|
||||
g_signal_new ("present", G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_LAST, 0, nullptr, nullptr, nullptr,
|
||||
|
@ -571,6 +578,20 @@ gst_d3d11_window_on_mouse_event (GstD3D11Window * window, const gchar * event,
|
|||
event, button, x, y, modifier);
|
||||
}
|
||||
|
||||
void
|
||||
gst_d3d11_window_on_mouse_scroll_event (GstD3D11Window * window,
|
||||
const gchar * event, gdouble x, gdouble y, gint delta_x, gint delta_y,
|
||||
guint modifier)
|
||||
{
|
||||
g_return_if_fail (GST_IS_D3D11_WINDOW (window));
|
||||
|
||||
if (!window->enable_navigation_events)
|
||||
return;
|
||||
|
||||
g_signal_emit (window, d3d11_window_signals[SIGNAL_MOUSE_SCROLL_EVENT], 0,
|
||||
event, x, y, delta_x, delta_y, modifier);
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DXGI_FORMAT dxgi_format;
|
||||
|
|
|
@ -235,6 +235,14 @@ void gst_d3d11_window_on_mouse_event (GstD3D11Window * window,
|
|||
gdouble y,
|
||||
guint modifier);
|
||||
|
||||
void gst_d3d11_window_on_mouse_scroll_event (GstD3D11Window * window,
|
||||
const gchar * event,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gint delta_x,
|
||||
gint delta_y,
|
||||
guint modifier);
|
||||
|
||||
/* utils */
|
||||
GstD3D11WindowNativeType gst_d3d11_window_get_native_type_from_handle (guintptr handle);
|
||||
|
||||
|
|
|
@ -733,6 +733,8 @@ gst_d3d11_window_win32_on_mouse_event (GstD3D11WindowWin32 * self,
|
|||
gint button;
|
||||
const gchar *event = nullptr;
|
||||
guint modifier = 0;
|
||||
gint delta_x = 0, delta_y = 0;
|
||||
POINT screen_point = { 0, 0 };
|
||||
|
||||
if (!window->enable_navigation_events)
|
||||
return;
|
||||
|
@ -778,6 +780,16 @@ gst_d3d11_window_win32_on_mouse_event (GstD3D11WindowWin32 * self,
|
|||
button = 3;
|
||||
event = "mouse-double-click";
|
||||
break;
|
||||
case WM_MOUSEHWHEEL:
|
||||
button = 0;
|
||||
event = "mouse-scroll";
|
||||
delta_x = GET_WHEEL_DELTA_WPARAM (wParam);
|
||||
break;
|
||||
case WM_MOUSEWHEEL:
|
||||
button = 0;
|
||||
event = "mouse-scroll";
|
||||
delta_y = GET_WHEEL_DELTA_WPARAM (wParam);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
@ -793,9 +805,19 @@ gst_d3d11_window_win32_on_mouse_event (GstD3D11WindowWin32 * self,
|
|||
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);
|
||||
if (uMsg == WM_MOUSEHWHEEL || uMsg == WM_MOUSEWHEEL) {
|
||||
screen_point.x = GET_X_LPARAM (lParam);
|
||||
screen_point.y = GET_Y_LPARAM (lParam);
|
||||
ScreenToClient (hWnd, &screen_point);
|
||||
|
||||
gst_d3d11_window_on_mouse_scroll_event (window, event,
|
||||
(gdouble) screen_point.x, (gdouble) screen_point.y,
|
||||
delta_x, delta_y, modifier);
|
||||
} else {
|
||||
gst_d3d11_window_on_mouse_event (window,
|
||||
event, button, (gdouble) GET_X_LPARAM (lParam),
|
||||
(gdouble) GET_Y_LPARAM (lParam), modifier);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -831,6 +853,8 @@ gst_d3d11_window_win32_handle_window_proc (GstD3D11WindowWin32 * self,
|
|||
case WM_LBUTTONDBLCLK:
|
||||
case WM_RBUTTONDBLCLK:
|
||||
case WM_MBUTTONDBLCLK:
|
||||
case WM_MOUSEWHEEL:
|
||||
case WM_MOUSEHWHEEL:
|
||||
gst_d3d11_window_win32_on_mouse_event (self, hWnd, uMsg, wParam, lParam);
|
||||
break;
|
||||
case WM_SYSKEYDOWN:
|
||||
|
|
Loading…
Reference in a new issue