Reduce the likelyhood that the mouse will hover over the taskbar or toast notification while in relative mode, which causes a mouse leave event.

This will still happen occasionally as the mouse is whipped around, if there is a window overlapping the game window, but it should happen less often now. This could even happen with the original code that warped the mouse every frame, so this should be a good compromise where we don't warp the mouse continously and we still keep the mouse in the safe area of the game window.

Note that notifications can be any size, so the safe area may need to be adjusted or even dynamically defined via a hint.
This commit is contained in:
Sam Lantinga
2021-09-24 10:49:44 -07:00
parent ce66051b0a
commit db68af8032
3 changed files with 135 additions and 30 deletions

View File

@@ -248,6 +248,24 @@ WIN_IsEqualIID(REFIID a, REFIID b)
return (SDL_memcmp(a, b, sizeof (*a)) == 0);
}
void
WIN_RECTToRect(const RECT *winrect, SDL_Rect *sdlrect)
{
sdlrect->x = winrect->left;
sdlrect->w = (winrect->right - winrect->left) + 1;
sdlrect->y = winrect->top;
sdlrect->h = (winrect->bottom - winrect->top) + 1;
}
void
WIN_RectToRECT(const SDL_Rect *sdlrect, RECT *winrect)
{
winrect->left = sdlrect->x;
winrect->right = sdlrect->x + sdlrect->w - 1;
winrect->top = sdlrect->y;
winrect->bottom = sdlrect->y + sdlrect->h - 1;
}
#endif /* __WIN32__ || __WINRT__ */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -37,6 +37,8 @@
#include <windows.h>
#include <basetyps.h> /* for REFIID with broken mingw.org headers */
#include "SDL_rect.h"
/* Routines to convert from UTF8 to native Windows text */
#define WIN_StringToUTF8W(S) SDL_iconv_string("UTF-8", "UTF-16LE", (char *)(S), (SDL_wcslen(S)+1)*sizeof(WCHAR))
#define WIN_UTF8ToStringW(S) (WCHAR *)SDL_iconv_string("UTF-16LE", "UTF-8", (char *)(S), SDL_strlen(S)+1)
@@ -81,6 +83,10 @@ extern char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid);
extern BOOL WIN_IsEqualGUID(const GUID * a, const GUID * b);
extern BOOL WIN_IsEqualIID(REFIID a, REFIID b);
/* Convert between SDL_rect and RECT */
extern void WIN_RECTToRect(const RECT *winrect, SDL_Rect *sdlrect);
extern void WIN_RectToRECT(const SDL_Rect *sdlrect, RECT *winrect);
#endif /* _INCLUDED_WINDOWS_H */
/* vi: set ts=4 sw=4 expandtab: */