mirror of
https://github.com/mpv-player/mpv
synced 2025-02-07 23:51:49 +00:00
w32_common: Track when the mouse leaves the window
Windows doesn't send WM_MOUSELEAVE by default unless you ask it to; request tracking for leave events when the mouse enters the window (or is moved). Tracking is automatically de-activated once the mouse leaves the window, so we have to re-request it every time the mouse re-enters the window.
This commit is contained in:
parent
0cfc382355
commit
f0b1834d59
@ -112,6 +112,12 @@ static int mod_state(struct vo *vo)
|
||||
return res;
|
||||
}
|
||||
|
||||
static BOOL tracking;
|
||||
static TRACKMOUSEEVENT trackEvent = {
|
||||
.cbSize = sizeof(TRACKMOUSEEVENT),
|
||||
.dwFlags = TME_LEAVE,
|
||||
};
|
||||
|
||||
static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
|
||||
LPARAM lParam)
|
||||
{
|
||||
@ -227,7 +233,13 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
case WM_MOUSELEAVE:
|
||||
tracking = FALSE;
|
||||
mp_input_put_key(vo->input_ctx, MP_KEY_MOUSE_LEAVE);
|
||||
break;
|
||||
case WM_MOUSEMOVE:
|
||||
if (!tracking)
|
||||
tracking = TrackMouseEvent(&trackEvent);;
|
||||
vo_mouse_movement(vo, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
|
||||
break;
|
||||
case WM_LBUTTONDOWN:
|
||||
@ -632,6 +644,9 @@ int vo_w32_init(struct vo *vo)
|
||||
return 0;
|
||||
}
|
||||
|
||||
tracking = FALSE;
|
||||
trackEvent.hwndTrack = w32->window;
|
||||
|
||||
if (vo->opts->WinID >= 0)
|
||||
EnableWindow(w32->window, 0);
|
||||
w32->cursor_visible = true;
|
||||
|
Loading…
Reference in New Issue
Block a user