Commit 71b960ed authored by Steve Lhomme's avatar Steve Lhomme Committed by Jean-Baptiste Kempf

vout:win32: hide the mouse if it has been inactive for too long

Use a timer tied to the HWND.

Fix #17819
Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent 360a05d7
......@@ -72,6 +72,8 @@ struct event_thread_t
HCURSOR cursor_arrow;
HCURSOR cursor_empty;
unsigned button_pressed;
mtime_t hide_timeout;
mtime_t last_moved;
/* Gestures */
win32_gesture_sys_t *p_gesture;
......@@ -119,6 +121,20 @@ static HCURSOR EmptyCursor( HINSTANCE instance );
static void MouseReleased( event_thread_t *p_event, unsigned button );
static void MousePressed( event_thread_t *p_event, HWND hwnd, unsigned button );
static void CALLBACK HideMouse(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
{
VLC_UNUSED(hwnd); VLC_UNUSED(uMsg); VLC_UNUSED(dwTime);
event_thread_t *p_event = (event_thread_t *)idEvent;
UpdateCursor( p_event, false );
}
static void UpdateCursorMoved( event_thread_t *p_event )
{
UpdateCursor( p_event, true );
p_event->last_moved = mdate();
SetTimer( p_event->hwnd, (UINT_PTR)p_event, p_event->hide_timeout, HideMouse );
}
/* Local helpers */
static inline bool isMouseEvent( WPARAM type )
{
......@@ -211,12 +227,12 @@ static void *EventThread( void *p_this )
(abs(mouse_pos.y - old_mouse_pos.y)) > 2 ) )
{
old_mouse_pos = mouse_pos;
UpdateCursor( p_event, true );
UpdateCursorMoved( p_event );
}
}
else if( isMouseEvent( msg.message ) )
{
UpdateCursor( p_event, true );
UpdateCursorMoved( p_event );
}
else if( msg.message == WM_VLC_HIDE_MOUSE )
{
......@@ -709,6 +725,8 @@ static int Win32VoutCreateWindow( event_thread_t *p_event )
{
p_event->vlc_icon = ExtractIcon( hInstance, vlc_path, 0 );
}
p_event->hide_timeout = var_InheritInteger( p_event->vd, "mouse-hide-timeout" );
UpdateCursorMoved( p_event );
/* Fill in the window class structure */
wc.style = CS_OWNDC|CS_DBLCLKS; /* style: dbl click */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment