Port window event handling to SDL3.

This commit is contained in:
Yamagi 2024-03-29 15:44:01 +01:00
parent a81b065893
commit d315f02a7b

View file

@ -658,69 +658,68 @@ IN_Update(void)
break; break;
} }
case SDL_WINDOWEVENT: case SDL_EVENT_WINDOW_FOCUS_LOST:
if (event.window.event == SDL_EVENT_WINDOW_FOCUS_LOST || {
event.window.event == SDL_EVENT_WINDOW_FOCUS_GAINED) Key_MarkAllUp();
S_Activate(false);
if (windowed_pauseonfocuslost->value != 1)
{ {
Key_MarkAllUp(); Cvar_SetValue("paused", 1);
if (event.window.event == SDL_EVENT_WINDOW_FOCUS_LOST)
{
S_Activate(false);
if (windowed_pauseonfocuslost->value != 1)
{
Cvar_SetValue("paused", 1);
}
/* pause music */
if (Cvar_VariableValue("ogg_pausewithgame") == 1 &&
OGG_Status() == PLAY && cl.attractloop == false)
{
Cbuf_AddText("ogg toggle\n");
}
}
if (event.window.event == SDL_EVENT_WINDOW_FOCUS_GAINED)
{
S_Activate(true);
if (windowed_pauseonfocuslost->value == 2)
{
Cvar_SetValue("paused", 0);
}
/* play music */
if (Cvar_VariableValue("ogg_pausewithgame") == 1 &&
OGG_Status() == PAUSE && cl.attractloop == false &&
cl_paused->value == 0)
{
Cbuf_AddText("ogg toggle\n");
}
}
} }
else if (event.window.event == SDL_EVENT_WINDOW_MOVED)
{
// make sure GLimp_GetRefreshRate() will query from SDL again - the window might
// be on another display now!
glimp_refreshRate = -1.0;
}
else if (event.window.event == SDL_EVENT_WINDOW_SHOWN)
{
if (cl_unpaused_scvis->value > 0)
{
Cvar_SetValue("paused", 0);
}
/* play music */ /* pause music */
if (Cvar_VariableValue("ogg_pausewithgame") == 1 && if (Cvar_VariableValue("ogg_pausewithgame") == 1 &&
OGG_Status() == PAUSE && cl.attractloop == false && OGG_Status() == PLAY && cl.attractloop == false)
cl_paused->value == 0) {
{ Cbuf_AddText("ogg toggle\n");
Cbuf_AddText("ogg toggle\n");
}
} }
break; break;
}
case SDL_EVENT_WINDOW_FOCUS_GAINED:
{
S_Activate(true);
if (windowed_pauseonfocuslost->value == 2)
{
Cvar_SetValue("paused", 0);
}
/* play music */
if (Cvar_VariableValue("ogg_pausewithgame") == 1 &&
OGG_Status() == PAUSE && cl.attractloop == false &&
cl_paused->value == 0)
{
Cbuf_AddText("ogg toggle\n");
}
break;
}
case SDL_EVENT_WINDOW_MOVED:
{
// make sure GLimp_GetRefreshRate() will query from SDL again - the window might
// be on another display now!
glimp_refreshRate = -1.0;
break;
}
case SDL_EVENT_WINDOW_SHOWN:
{
if (cl_unpaused_scvis->value > 0)
{
Cvar_SetValue("paused", 0);
}
/* play music */
if (Cvar_VariableValue("ogg_pausewithgame") == 1 &&
OGG_Status() == PAUSE && cl.attractloop == false &&
cl_paused->value == 0)
{
Cbuf_AddText("ogg toggle\n");
}
break;
}
case SDL_EVENT_GAMEPAD_BUTTON_UP : case SDL_EVENT_GAMEPAD_BUTTON_UP :
case SDL_EVENT_GAMEPAD_BUTTON_DOWN : case SDL_EVENT_GAMEPAD_BUTTON_DOWN :