mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-23 14:25:37 +00:00
NoGUI/SDL: Implement pause on focus loss
This commit is contained in:
parent
ab0364eb8f
commit
8e9fbf63a3
|
@ -1,4 +1,5 @@
|
|||
#include "sdl_host_interface.h"
|
||||
#include "core/system.h"
|
||||
#include "frontend-common/controller_interface.h"
|
||||
#include "frontend-common/fullscreen_ui.h"
|
||||
#include "frontend-common/icon.h"
|
||||
|
@ -276,12 +277,40 @@ void SDLHostInterface::HandleSDLEvent(const SDL_Event* event)
|
|||
{
|
||||
case SDL_WINDOWEVENT:
|
||||
{
|
||||
if (event->window.event == SDL_WINDOWEVENT_SIZE_CHANGED)
|
||||
switch (event->window.event)
|
||||
{
|
||||
s32 window_width, window_height;
|
||||
SDL_GetWindowSize(m_window, &window_width, &window_height);
|
||||
m_display->ResizeRenderWindow(window_width, window_height);
|
||||
OnHostDisplayResized();
|
||||
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
||||
{
|
||||
s32 window_width, window_height;
|
||||
SDL_GetWindowSize(m_window, &window_width, &window_height);
|
||||
m_display->ResizeRenderWindow(window_width, window_height);
|
||||
OnHostDisplayResized();
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_WINDOWEVENT_FOCUS_LOST:
|
||||
{
|
||||
if (!m_was_paused_by_focus_loss && !System::IsPaused())
|
||||
{
|
||||
PauseSystem(true);
|
||||
m_was_paused_by_focus_loss = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
||||
{
|
||||
if (m_was_paused_by_focus_loss)
|
||||
{
|
||||
if (System::IsPaused())
|
||||
PauseSystem(false);
|
||||
m_was_paused_by_focus_loss = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -34,4 +34,5 @@ private:
|
|||
|
||||
SDL_Window* m_window = nullptr;
|
||||
bool m_fullscreen = false;
|
||||
bool m_was_paused_by_focus_loss = false;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue