switch between fullscreen and windowed mode without restarting the client (by oy)

This commit is contained in:
def 2016-04-29 21:07:10 +02:00
parent 6c4e6c5c44
commit 354696afb7
6 changed files with 20 additions and 6 deletions

View file

@ -696,6 +696,11 @@ void CGraphicsBackend_SDL_OpenGL::Maximize()
// TODO: SDL
}
bool CGraphicsBackend_SDL_OpenGL::Fullscreen(bool State)
{
return SDL_SetWindowFullscreen(m_pWindow, State ? SDL_WINDOW_FULLSCREEN : 0) == 0;
}
int CGraphicsBackend_SDL_OpenGL::WindowActive()
{
return SDL_GetWindowFlags(m_pWindow)&SDL_WINDOW_INPUT_FOCUS;

View file

@ -188,6 +188,7 @@ public:
virtual void Minimize();
virtual void Maximize();
virtual bool Fullscreen(bool State);
virtual int WindowActive();
virtual int WindowOpen();
virtual void SetWindowGrab(bool Grab);

View file

@ -895,6 +895,11 @@ void CGraphics_Threaded::Maximize()
m_pBackend->Maximize();
}
bool CGraphics_Threaded::Fullscreen(bool State)
{
return m_pBackend->Fullscreen(State);
}
int CGraphics_Threaded::WindowActive()
{
return m_pBackend->WindowActive();

View file

@ -311,6 +311,7 @@ public:
virtual void Minimize() = 0;
virtual void Maximize() = 0;
virtual bool Fullscreen(bool State) = 0;
virtual int WindowActive() = 0;
virtual int WindowOpen() = 0;
virtual void SetWindowGrab(bool Grab) = 0;
@ -427,6 +428,7 @@ public:
virtual void Minimize();
virtual void Maximize();
virtual bool Fullscreen(bool State);
virtual int WindowActive();
virtual int WindowOpen();

View file

@ -66,6 +66,8 @@ public:
int ScreenHeight() const { return m_ScreenHeight; }
float ScreenAspect() const { return (float)ScreenWidth()/(float)ScreenHeight(); }
virtual bool Fullscreen(bool State) = 0;
virtual void Clear(float r, float g, float b) = 0;
virtual void ClipEnable(int x, int y, int w, int h) = 0;

View file

@ -802,7 +802,6 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
static int s_GfxScreenHeight = g_Config.m_GfxScreenHeight;
static int s_GfxColorDepth = g_Config.m_GfxColorDepth;
static int s_GfxBorderless = g_Config.m_GfxBorderless;
static int s_GfxFullscreen = g_Config.m_GfxFullscreen;
static int s_GfxVsync = g_Config.m_GfxVsync;
static int s_GfxFsaaSamples = g_Config.m_GfxFsaaSamples;
static int s_GfxTextureQuality = g_Config.m_GfxTextureQuality;
@ -868,10 +867,11 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
MainView.HSplitTop(20.0f, &Button, &MainView);
if(DoButton_CheckBox(&g_Config.m_GfxFullscreen, Localize("Fullscreen"), g_Config.m_GfxFullscreen, &Button))
{
g_Config.m_GfxFullscreen ^= 1;
if(Graphics()->Fullscreen(g_Config.m_GfxFullscreen^1))
{ g_Config.m_GfxFullscreen ^= 1;
if(g_Config.m_GfxFullscreen && g_Config.m_GfxBorderless)
g_Config.m_GfxBorderless = 0;
CheckSettings = true;
}
}
MainView.HSplitTop(20.0f, &Button, &MainView);
@ -919,7 +919,6 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
s_GfxScreenHeight == g_Config.m_GfxScreenHeight &&
s_GfxColorDepth == g_Config.m_GfxColorDepth &&
s_GfxBorderless == g_Config.m_GfxBorderless &&
s_GfxFullscreen == g_Config.m_GfxFullscreen &&
s_GfxVsync == g_Config.m_GfxVsync &&
s_GfxFsaaSamples == g_Config.m_GfxFsaaSamples &&
s_GfxTextureQuality == g_Config.m_GfxTextureQuality &&