From f0b1834d59e7c0e7d696faf9c52837d009e915b3 Mon Sep 17 00:00:00 2001 From: "Diogo Franco (Kovensky)" Date: Thu, 25 Jul 2013 14:19:12 -0300 Subject: 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. --- video/out/w32_common.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'video') diff --git a/video/out/w32_common.c b/video/out/w32_common.c index b51078b5f1..0315056750 100644 --- a/video/out/w32_common.c +++ b/video/out/w32_common.c @@ -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; -- cgit v1.2.3