Hopefully correct setting of host mouse cursor in window and fullscreen modes.

This commit is contained in:
waltje
2017-12-15 00:42:10 -05:00
parent cf67c2a1a9
commit 3bd6b0eccc
3 changed files with 28 additions and 8 deletions

View File

@@ -8,7 +8,7 @@
*
* user Interface module for WinAPI on Windows.
*
* Version: @(#)win_ui.c 1.0.8 2017/12/15
* Version: @(#)win_ui.c 1.0.9 2017/12/15
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -64,6 +64,25 @@ static int hook_enabled = 0;
static int save_window_pos = 0;
/* Set host cursor visible or not. */
void
show_cursor(int val)
{
static int old = -1, vis = -1;
if (vis == val) return;
if (val < 0)
val = old;
old = vis;
while (1) {
if (ShowCursor((val == 0) ? FALSE : TRUE) < 0) break;
}
vis = val;
}
HICON
LoadIconEx(PCTSTR pszIconName)
{
@@ -938,15 +957,12 @@ plat_mouse_capture(int on)
GetClipCursor(&oldclip);
GetWindowRect(hwndRender, &rect);
ClipCursor(&rect);
while (1) {
if (ShowCursor(FALSE) < 0) break;
}
show_cursor(0);
mouse_capture = 1;
} else if (!on && mouse_capture) {
/* Disable the in-app mouse. */
ClipCursor(&oldclip);
ShowCursor(TRUE);
show_cursor(1);
mouse_capture = 0;
}