diff options
author | Diogo Franco (Kovensky) <diogomfranco@gmail.com> | 2013-07-25 14:19:12 -0300 |
---|---|---|
committer | Diogo Franco (Kovensky) <diogomfranco@gmail.com> | 2013-07-25 14:19:12 -0300 |
commit | f0b1834d59e7c0e7d696faf9c52837d009e915b3 (patch) | |
tree | 2121e4d2f86186e4bbf3898ca9248ba0762a05ed /video/out/w32_common.c | |
parent | 0cfc382355b71a9dd57b872e30f50463cabd5e2e (diff) | |
download | mpv-f0b1834d59e7c0e7d696faf9c52837d009e915b3.tar.bz2 mpv-f0b1834d59e7c0e7d696faf9c52837d009e915b3.tar.xz |
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.
Diffstat (limited to 'video/out/w32_common.c')
-rw-r--r-- | video/out/w32_common.c | 15 |
1 files changed, 15 insertions, 0 deletions
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; |