From 775e3ae91a704d42728b228253b733d382acfc3b Mon Sep 17 00:00:00 2001 From: retr0s4ge Date: Sun, 12 Aug 2018 19:58:02 +0200 Subject: [PATCH] (Windows Frontend) Fix the bug where cursor is auto-hidden even when over the menu Also, changed the time before auto-hiding to 10 seconds. --- desmume/src/frontend/windows/main.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/desmume/src/frontend/windows/main.cpp b/desmume/src/frontend/windows/main.cpp index 0b1f7706e..b413c45ed 100755 --- a/desmume/src/frontend/windows/main.cpp +++ b/desmume/src/frontend/windows/main.cpp @@ -4654,6 +4654,12 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM { static int tmp_execute; static UINT_PTR autoHideCursorTimer = 0; + static bool mouseLeftClientArea = true; + + TRACKMOUSEEVENT tme; + tme.cbSize = sizeof(tme); + tme.dwFlags = TME_LEAVE; + tme.hwndTrack = hwnd; switch (message) // handle the messages { @@ -4997,8 +5003,9 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM { if (autoHideCursorTimer == wParam) { - if (((IsZoomed(hwnd) && (GetStyle()&DWS_FULLSCREEN)) || fsWindow) && autoHideCursor) - while (ShowCursor(FALSE) >= 0); + if(autoHideCursor && !mouseLeftClientArea) + if ((IsZoomed(hwnd) && (GetStyle()&DWS_FULLSCREEN)) || fsWindow) + while (ShowCursor(FALSE) >= 0); } return 0; } @@ -5423,8 +5430,13 @@ DOKEYDOWN: case WM_MOUSEMOVE: case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK: + if (mouseLeftClientArea) + { + TrackMouseEvent(&tme); + mouseLeftClientArea = false; + } while (ShowCursor(TRUE) <= 0); - autoHideCursorTimer = SetTimer(hwnd, 1, 5000, NULL); + autoHideCursorTimer = SetTimer(hwnd, 1, 10000, NULL); if (((message==WM_POINTERDOWN || message== WM_POINTERUPDATE) && ((wParam & (POINTER_MESSAGE_FLAG_INCONTACT | POINTER_MESSAGE_FLAG_FIRSTBUTTON)))) @@ -5519,6 +5531,9 @@ DOKEYDOWN: userTouchesScreen = false; return 0; + case WM_MOUSELEAVE: + mouseLeftClientArea = true; + return 0; #if 0 case WM_INITMENU: { HMENU menu = (HMENU)wParam;