mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Merge branch 'fix-window-refocus' into 'master'
SDL: only react to window focus changes if state actually changes See merge request KartKrew/Kart!859
This commit is contained in:
commit
99e6301365
1 changed files with 9 additions and 1 deletions
|
|
@ -572,10 +572,13 @@ static INT32 SDLJoyAxis(const Sint16 axis, UINT8 pid)
|
||||||
|
|
||||||
static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
|
static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
|
||||||
{
|
{
|
||||||
|
#define FOCUSUNION (mousefocus | (kbfocus << 1))
|
||||||
static SDL_bool firsttimeonmouse = SDL_TRUE;
|
static SDL_bool firsttimeonmouse = SDL_TRUE;
|
||||||
static SDL_bool mousefocus = SDL_TRUE;
|
static SDL_bool mousefocus = SDL_TRUE;
|
||||||
static SDL_bool kbfocus = SDL_TRUE;
|
static SDL_bool kbfocus = SDL_TRUE;
|
||||||
|
|
||||||
|
const unsigned int oldfocus = FOCUSUNION;
|
||||||
|
|
||||||
switch (evt.event)
|
switch (evt.event)
|
||||||
{
|
{
|
||||||
case SDL_WINDOWEVENT_ENTER:
|
case SDL_WINDOWEVENT_ENTER:
|
||||||
|
|
@ -599,6 +602,11 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
|
||||||
window_y = evt.data2;
|
window_y = evt.data2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (FOCUSUNION == oldfocus) // No state change
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (mousefocus && kbfocus)
|
if (mousefocus && kbfocus)
|
||||||
{
|
{
|
||||||
// Tell game we got focus back, resume music if necessary
|
// Tell game we got focus back, resume music if necessary
|
||||||
|
|
@ -639,7 +647,7 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
|
||||||
SDLdoUngrabMouse();
|
SDLdoUngrabMouse();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#undef FOCUSUNION
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type)
|
static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue