summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Ross-Gowan <rossymiles@gmail.com>2015-03-13 19:46:54 +1100
committerDiogo Franco (Kovensky) <diogomfranco@gmail.com>2015-03-15 20:09:00 +0900
commite865543be2360a7d1560d65864f2e42be7e14190 (patch)
treeeaa294030eb7858fef8a74279480bc13db0e5e26
parente84a00651a3bda40752602606ebf4a2472eb3dab (diff)
downloadmpv-e865543be2360a7d1560d65864f2e42be7e14190.tar.bz2
mpv-e865543be2360a7d1560d65864f2e42be7e14190.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. (cherry picked from commit acbac01a73e22ba1b0aa48be191f72f988133edd)
-rw-r--r--video/out/w32_common.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/video/out/w32_common.c b/video/out/w32_common.c
index 614d6ec8a7..c7dfd0d45f 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;
@@ -679,7 +682,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;
}
@@ -1199,12 +1205,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) {
@@ -1250,7 +1250,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