diff options
author | James Ross-Gowan <rossymiles@gmail.com> | 2015-03-13 19:46:54 +1100 |
---|---|---|
committer | James Ross-Gowan <rossymiles@gmail.com> | 2015-03-13 21:31:58 +1100 |
commit | acbac01a73e22ba1b0aa48be191f72f988133edd (patch) | |
tree | 1516b2c2d76dcbfcc92538f97538f72ddbfdab27 /video/out/w32_common.c | |
parent | ea680d2677e7ffbfdc3b4386df7690386703fe45 (diff) | |
download | mpv-acbac01a73e22ba1b0aa48be191f72f988133edd.tar.bz2 mpv-acbac01a73e22ba1b0aa48be191f72f988133edd.tar.xz |
w32_common: don't hide cursor when the menu is open
Previously, mpv would hide the cursor when the autohide timer expired,
even if the window menu was open. This made it difficult to use the menu
with the mouse.
When handling VOCTRL_SET_CURSOR_VISIBILITY, instead of determining
whether to call SetCursor by checking if the cursor is in the client
area, call it based on the parameters to the last WM_SETCURSOR message.
When the window enters "menu mode," it gets a WM_SETCURSOR message with
HIWORD(lParam) set to 0 to indicate that the cursor shouldn't be set.
Diffstat (limited to 'video/out/w32_common.c')
-rw-r--r-- | video/out/w32_common.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/video/out/w32_common.c b/video/out/w32_common.c index aa74f1b7b6..a568880a58 100644 --- a/video/out/w32_common.c +++ b/video/out/w32_common.c @@ -98,6 +98,9 @@ struct vo_w32_state { int mouse_x; int mouse_y; + // Should SetCursor be called when handling VOCTRL_SET_CURSOR_VISIBILITY? + bool can_set_cursor; + // UTF-16 decoding state for WM_CHAR and VK_PACKET int high_surrogate; @@ -682,7 +685,10 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, mp_input_put_key(w32->input_ctx, MP_INPUT_RELEASE_ALL); break; case WM_SETCURSOR: - if (LOWORD(lParam) == HTCLIENT && !w32->cursor_visible) { + // The cursor should only be hidden if the mouse is in the client area + // and if the window isn't in menu mode (HIWORD(lParam) is non-zero) + w32->can_set_cursor = LOWORD(lParam) == HTCLIENT && HIWORD(lParam); + if (w32->can_set_cursor && !w32->cursor_visible) { SetCursor(NULL); return TRUE; } @@ -1204,12 +1210,6 @@ fail: return 0; } -static bool vo_w32_is_cursor_in_client(struct vo_w32_state *w32) -{ - DWORD pos = GetMessagePos(); - return SendMessage(w32->window, WM_NCHITTEST, 0, pos) == HTCLIENT; -} - static int gui_thread_control(struct vo_w32_state *w32, int request, void *arg) { switch (request) { @@ -1258,7 +1258,7 @@ static int gui_thread_control(struct vo_w32_state *w32, int request, void *arg) case VOCTRL_SET_CURSOR_VISIBILITY: w32->cursor_visible = *(bool *)arg; - if (vo_w32_is_cursor_in_client(w32)) { + if (w32->can_set_cursor && w32->tracking) { if (w32->cursor_visible) SetCursor(LoadCursor(NULL, IDC_ARROW)); else |