]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Do not temporarily unhide cursor and then hide it again when capturing mouse.
authorToni Wilen <twilen@winuae.net>
Tue, 19 Mar 2024 16:58:15 +0000 (18:58 +0200)
committerToni Wilen <twilen@winuae.net>
Tue, 19 Mar 2024 16:58:15 +0000 (18:58 +0200)
inputdevice.cpp
od-win32/win32.cpp

index 26913eefe98a9398fa4dd44bac3be75dacae75ca..6eb09a6827c63ba8b1ea5920ad0a559867e27ff6 100644 (file)
@@ -5776,8 +5776,7 @@ void inputdevice_vsync (void)
                mousehack_alive_cnt++;
                if (mousehack_alive_cnt == 0) {
                        mousehack_alive_cnt = 100;
-                       setmouseactive(0, 0);
-                       setmouseactive(0, 1);
+                       setmouseactive(0, -1);
                }
        }
        inputdevice_checkconfig ();
index de3cbe4b223372af1c4e5558da7e0a06d7a17b37..d20c4fe8d17007217e3ca44842c164589a312699 100644 (file)
@@ -812,6 +812,27 @@ static void setcursorshape(int monid)
        }
 }
 
+void set_showcursor(BOOL v)
+{
+       if (v) {
+               int vv = ShowCursor(TRUE);
+               if (vv > 1) {
+                       ShowCursor(FALSE);
+               }
+       } else {
+               int max = 10;
+               while (max-- > 0) {
+                       int vv = ShowCursor(FALSE);
+                       if (vv < 0) {
+                               while (vv < -1) {
+                                       vv = ShowCursor(TRUE);
+                               }
+                               break;
+                       }
+               }
+       }
+}
+
 void releasecapture(struct AmigaMonitor *mon)
 {
        //write_log(_T("releasecapture %d\n"), mon_cursorclipped);
@@ -821,14 +842,11 @@ void releasecapture(struct AmigaMonitor *mon)
        GetCursorInfo(&pci);
        write_log(_T("PCI %08x %p %d %d\n"), pci.flags, pci.hCursor, pci.ptScreenPos.x, pci.ptScreenPos.y);
 #endif
-       if (!mon_cursorclipped)
-               return;
        if (!ClipCursor(NULL))
                write_log(_T("ClipCursor %08x\n"), GetLastError());
        if (!ReleaseCapture())
                write_log(_T("ReleaseCapture %08x\n"), GetLastError());
-       int c = ShowCursor(TRUE);
-       write_log(_T("ShowCursor %d\n"), c);
+       set_showcursor(TRUE);
        mon_cursorclipped = 0;
 }
 
@@ -1052,13 +1070,13 @@ static void setmouseactive2(struct AmigaMonitor *mon, int active, bool allowpaus
        mouseactive = active ? mon->monitor_id + 1 : 0;
 
        mon->mouseposx = mon->mouseposy = 0;
-       //write_log (_T("setmouseactive(%d)\n"), active);
-       releasecapture (mon);
-       recapture = 0;
 
        if (isfullscreen () <= 0 && (currprefs.input_mouse_untrap & MOUSEUNTRAP_MAGIC) && currprefs.input_tablet > 0) {
-               if (mousehack_alive ())
+               if (mousehack_alive()) {
+                       releasecapture(mon);
+                       recapture = 0;
                        return;
+               }
                SetCursor (normalcursor);
        }
 
@@ -1081,6 +1099,8 @@ static void setmouseactive2(struct AmigaMonitor *mon, int active, bool allowpaus
                focus = 0;
                mouseactive = 0;
                active = 0;
+               releasecapture(mon);
+               recapture = 0;
        }
 
        if (mouseactive > 0)
@@ -1090,18 +1110,17 @@ static void setmouseactive2(struct AmigaMonitor *mon, int active, bool allowpaus
 
        if (mouseactive) {
                if (focus) {
-                       if (GetActiveWindow() != mon->hMainWnd && GetActiveWindow() != mon->hAmigaWnd)
+                       if (GetActiveWindow() != mon->hMainWnd && GetActiveWindow() != mon->hAmigaWnd) {
                                SetActiveWindow(mon->hMainWnd);
-                       if (!mon_cursorclipped) {
-                               //write_log(_T("setcapture\n"));
+                       }
+                       //write_log(_T("setcapture\n"));
 #if MOUSECLIP_HIDE
-                               ShowCursor (FALSE);
+                       set_showcursor(FALSE);
 #endif
-                               SetCapture (mon->hAmigaWnd);
-                               updatewinrect(mon, false);
-                               mon_cursorclipped = mon->monitor_id + 1;
-                               updatemouseclip(mon);
-                       }
+                       SetCapture (mon->hAmigaWnd);
+                       updatewinrect(mon, false);
+                       mon_cursorclipped = mon->monitor_id + 1;
+                       updatemouseclip(mon);
                        setcursor(mon, -30000, -30000);
                }
                if (lastmouseactive != mouseactive) {
@@ -7693,7 +7712,7 @@ static void create_dump (struct _EXCEPTION_POINTERS *pExceptionPointers)
                                        CloseHandle (f);
                                        ClipCursor(NULL);
                                        ReleaseCapture();
-                                       ShowCursor(TRUE);
+                                       set_showcursor(TRUE);
                                        if (debugfile)
                                                log_close(debugfile);
                                        if (isfullscreen() <= 0) {