Merge pull request #3755 from Jupeyy/pr_remove_windowed_fullscreen

Only remove windowed fullscreen and restore mouse focus loss behavior
This commit is contained in:
Dennis Felsing 2021-04-03 09:45:22 +02:00 committed by GitHub
commit 567e555b5a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 16 additions and 24 deletions

View file

@ -4529,10 +4529,8 @@ int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int *Screen, int *pWidt
else
SdlFlags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
}
else if(Flags & (IGraphicsBackend::INITFLAG_DESKTOP_FULLSCREEN | IGraphicsBackend::INITFLAG_WINDOWED_FULLSCREEN))
else if(Flags & (IGraphicsBackend::INITFLAG_DESKTOP_FULLSCREEN))
{
if(Flags & IGraphicsBackend::INITFLAG_WINDOWED_FULLSCREEN)
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
SdlFlags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
}
@ -4783,24 +4781,15 @@ void CGraphicsBackend_SDL_OpenGL::SetWindowParams(int FullscreenMode, bool IsBor
SDL_SetWindowFullscreen(m_pWindow, SDL_WINDOW_FULLSCREEN_DESKTOP);
#else
SDL_SetWindowFullscreen(m_pWindow, SDL_WINDOW_FULLSCREEN);
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "1");
#endif
}
else if(FullscreenMode == 2)
{
SDL_SetWindowFullscreen(m_pWindow, SDL_WINDOW_FULLSCREEN_DESKTOP);
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "1");
}
else if(FullscreenMode == 3)
{
SDL_SetWindowFullscreen(m_pWindow, SDL_WINDOW_FULLSCREEN_DESKTOP);
SDL_SetWindowBordered(m_pWindow, SDL_bool(false));
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
}
}
else
{
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
SDL_SetWindowFullscreen(m_pWindow, 0);
SDL_SetWindowBordered(m_pWindow, SDL_bool(!IsBorderless));
}

View file

@ -4022,7 +4022,7 @@ void CClient::ConchainWindowScreen(IConsole::IResult *pResult, void *pUserData,
void CClient::SetWindowParams(int FullscreenMode, bool IsBorderless)
{
g_Config.m_GfxFullscreen = clamp(FullscreenMode, 0, 3);
g_Config.m_GfxFullscreen = clamp(FullscreenMode, 0, 2);
g_Config.m_GfxBorderless = (int)IsBorderless;
Graphics()->SetWindowParams(FullscreenMode, IsBorderless);
}

View file

@ -2214,8 +2214,6 @@ int CGraphics_Threaded::IssueInit()
Flags |= IGraphicsBackend::INITFLAG_FULLSCREEN;
else if(g_Config.m_GfxFullscreen == 2)
Flags |= IGraphicsBackend::INITFLAG_DESKTOP_FULLSCREEN;
else if(g_Config.m_GfxFullscreen == 3)
Flags |= IGraphicsBackend::INITFLAG_WINDOWED_FULLSCREEN;
if(g_Config.m_GfxVsync)
Flags |= IGraphicsBackend::INITFLAG_VSYNC;
if(g_Config.m_GfxHighdpi)

View file

@ -641,7 +641,6 @@ public:
INITFLAG_BORDERLESS = 1 << 3,
INITFLAG_HIGHDPI = 1 << 4,
INITFLAG_DESKTOP_FULLSCREEN = 1 << 5,
INITFLAG_WINDOWED_FULLSCREEN = 1 << 6,
};
virtual ~IGraphicsBackend() {}

View file

@ -330,6 +330,8 @@ int CInput::Update()
Graphics()->Resize(Event.window.data1, Event.window.data2);
break;
case SDL_WINDOWEVENT_FOCUS_GAINED:
if(m_InputGrabbed)
MouseModeRelative();
m_MouseFocus = true;
IgnoreKeys = true;
// We should do this call to reset relative mouse position after alt+tab
@ -338,6 +340,12 @@ int CInput::Update()
case SDL_WINDOWEVENT_FOCUS_LOST:
m_MouseFocus = false;
IgnoreKeys = true;
if(m_InputGrabbed)
{
MouseModeAbsolute();
// Remember that we had relative mouse
m_InputGrabbed = true;
}
break;
#if defined(CONF_PLATFORM_MACOS) // Todo: remove this when fixed in SDL
case SDL_WINDOWEVENT_MAXIMIZED:

View file

@ -100,10 +100,10 @@ MACRO_CONFIG_INT(GfxScreenWidth, gfx_screen_width, 0, 0, 0, CFGFLAG_SAVE | CFGFL
MACRO_CONFIG_INT(GfxScreenHeight, gfx_screen_height, 0, 0, 0, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Screen resolution height")
#if !defined(CONF_PLATFORM_MACOS)
MACRO_CONFIG_INT(GfxBorderless, gfx_borderless, 0, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Borderless window (not to be used with fullscreen)")
MACRO_CONFIG_INT(GfxFullscreen, gfx_fullscreen, 1, 0, 3, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Set fullscreen mode: 0=no fullscreen, 1=pure fullscreen, 2=desktop fullscreen, 3=windowed fullscreen")
MACRO_CONFIG_INT(GfxFullscreen, gfx_fullscreen, 1, 0, 2, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Set fullscreen mode: 0=no fullscreen, 1=pure fullscreen, 2=desktop fullscreen")
#else
MACRO_CONFIG_INT(GfxBorderless, gfx_borderless, 1, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Borderless window (not to be used with fullscreen)")
MACRO_CONFIG_INT(GfxFullscreen, gfx_fullscreen, 0, 0, 3, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Set fullscreen mode: 0=no fullscreen, 1=pure fullscreen, 2=desktop fullscreen, 3=windowed fullscreen")
MACRO_CONFIG_INT(GfxFullscreen, gfx_fullscreen, 0, 0, 2, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Set fullscreen mode: 0=no fullscreen, 1=pure fullscreen, 2=desktop fullscreen")
#endif
MACRO_CONFIG_INT(GfxHighdpi, gfx_highdpi, 1, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Enable high-dpi")
MACRO_CONFIG_INT(GfxAlphabits, gfx_alphabits, 0, 0, 0, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Alpha bits for framebuffer (fullscreen only)")

View file

@ -1135,15 +1135,15 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
// switches
static float s_ScrollValueDrop = 0;
static const int s_NumWindowMode = 5;
static const int s_NumWindowMode = 4;
static int s_aWindowModeIDs[s_NumWindowMode];
const void *aWindowModeIDs[s_NumWindowMode];
for(int i = 0; i < s_NumWindowMode; ++i)
aWindowModeIDs[i] = &s_aWindowModeIDs[i];
static int s_WindowModeDropDownState = 0;
const char *pWindowModes[] = {Localize("Windowed"), Localize("Windowed borderless"), Localize("Windowed fullscreen"), Localize("Desktop fullscreen"), Localize("Fullscreen")};
const char *pWindowModes[] = {Localize("Windowed"), Localize("Windowed borderless"), Localize("Desktop fullscreen"), Localize("Fullscreen")};
OldSelected = (g_Config.m_GfxFullscreen ? (g_Config.m_GfxFullscreen == 1 ? 4 : (g_Config.m_GfxFullscreen == 2 ? 3 : 2)) : (g_Config.m_GfxBorderless ? 1 : 0));
OldSelected = (g_Config.m_GfxFullscreen ? (g_Config.m_GfxFullscreen == 1 ? 3 : 2) : (g_Config.m_GfxBorderless ? 1 : 0));
const int NewWindowMode = RenderDropDown(s_WindowModeDropDownState, &MainView, OldSelected, aWindowModeIDs, pWindowModes, s_NumWindowMode, &s_NumWindowMode, s_ScrollValueDrop);
if(OldSelected != NewWindowMode)
@ -1153,10 +1153,8 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
else if(NewWindowMode == 1)
Client()->SetWindowParams(0, true);
else if(NewWindowMode == 2)
Client()->SetWindowParams(3, true);
else if(NewWindowMode == 3)
Client()->SetWindowParams(2, false);
else if(NewWindowMode == 4)
else if(NewWindowMode == 3)
Client()->SetWindowParams(1, false);
}