NoGUI: Fix crash on startup with exclusive fullscreen
This commit is contained in:
parent
79549a2a51
commit
6aa78b11fe
|
@ -47,13 +47,13 @@ bool NoGUIHostInterface::Initialize()
|
|||
return false;
|
||||
|
||||
const bool start_fullscreen = m_flags.start_fullscreen || g_settings.start_fullscreen;
|
||||
if (!CreatePlatformWindow(start_fullscreen))
|
||||
if (!CreatePlatformWindow())
|
||||
{
|
||||
Log_ErrorPrintf("Failed to create platform window");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!CreateDisplay())
|
||||
if (!CreateDisplay(start_fullscreen))
|
||||
{
|
||||
Log_ErrorPrintf("Failed to create host display");
|
||||
DestroyPlatformWindow();
|
||||
|
@ -80,7 +80,7 @@ void NoGUIHostInterface::Shutdown()
|
|||
CommonHostInterface::Shutdown();
|
||||
}
|
||||
|
||||
bool NoGUIHostInterface::CreateDisplay()
|
||||
bool NoGUIHostInterface::CreateDisplay(bool fullscreen)
|
||||
{
|
||||
std::optional<WindowInfo> wi = GetPlatformWindowInfo();
|
||||
if (!wi)
|
||||
|
@ -123,6 +123,9 @@ bool NoGUIHostInterface::CreateDisplay()
|
|||
return false;
|
||||
}
|
||||
|
||||
if (fullscreen)
|
||||
SetFullscreen(true);
|
||||
|
||||
if (!CreateHostDisplayResources())
|
||||
Log_WarningPrint("Failed to create host display resources");
|
||||
|
||||
|
@ -176,10 +179,10 @@ bool NoGUIHostInterface::AcquireHostDisplay()
|
|||
|
||||
// We need to recreate the window, otherwise bad things happen...
|
||||
DestroyPlatformWindow();
|
||||
if (!CreatePlatformWindow(was_fullscreen))
|
||||
if (!CreatePlatformWindow())
|
||||
Panic("Failed to recreate platform window on GPU renderer switch");
|
||||
|
||||
if (!CreateDisplay())
|
||||
if (!CreateDisplay(was_fullscreen))
|
||||
Panic("Failed to recreate display on GPU renderer switch");
|
||||
}
|
||||
|
||||
|
|
|
@ -43,11 +43,11 @@ protected:
|
|||
|
||||
void RequestExit() override;
|
||||
|
||||
virtual bool CreatePlatformWindow(bool fullscreen) = 0;
|
||||
virtual bool CreatePlatformWindow() = 0;
|
||||
virtual void DestroyPlatformWindow() = 0;
|
||||
virtual std::optional<WindowInfo> GetPlatformWindowInfo() = 0;
|
||||
|
||||
bool CreateDisplay();
|
||||
bool CreateDisplay(bool fullscreen);
|
||||
void DestroyDisplay();
|
||||
void RunCallbacks();
|
||||
|
||||
|
|
|
@ -154,7 +154,7 @@ ALWAYS_INLINE static TinyString GetWindowTitle()
|
|||
return TinyString::FromFormat("DuckStation %s (%s)", g_scm_tag_str, g_scm_branch_str);
|
||||
}
|
||||
|
||||
bool SDLHostInterface::CreatePlatformWindow(bool fullscreen)
|
||||
bool SDLHostInterface::CreatePlatformWindow()
|
||||
{
|
||||
// Create window.
|
||||
const u32 window_flags = SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI;
|
||||
|
@ -176,9 +176,6 @@ bool SDLHostInterface::CreatePlatformWindow(bool fullscreen)
|
|||
SDL_FreeSurface(icon_surface);
|
||||
}
|
||||
|
||||
if (fullscreen || m_fullscreen)
|
||||
SetFullscreen(true);
|
||||
|
||||
ImGui_ImplSDL2_Init(m_window);
|
||||
|
||||
// Process events so that we have everything sorted out before creating a child window for the GL context (X11).
|
||||
|
@ -192,6 +189,7 @@ void SDLHostInterface::DestroyPlatformWindow()
|
|||
ImGui_ImplSDL2_Shutdown();
|
||||
SDL_DestroyWindow(m_window);
|
||||
m_window = nullptr;
|
||||
m_fullscreen = false;
|
||||
}
|
||||
|
||||
std::optional<WindowInfo> SDLHostInterface::GetPlatformWindowInfo()
|
||||
|
|
|
@ -25,7 +25,7 @@ protected:
|
|||
|
||||
std::optional<HostKeyCode> GetHostKeyCode(const std::string_view key_code) const override;
|
||||
|
||||
bool CreatePlatformWindow(bool fullscreen) override;
|
||||
bool CreatePlatformWindow() override;
|
||||
void DestroyPlatformWindow() override;
|
||||
std::optional<WindowInfo> GetPlatformWindowInfo() override;
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ void VTYHostInterface::FixIncompatibleSettings(bool display_osd_messages)
|
|||
g_settings.confim_power_off = false;
|
||||
}
|
||||
|
||||
bool VTYHostInterface::CreatePlatformWindow(bool fullscreen)
|
||||
bool VTYHostInterface::CreatePlatformWindow()
|
||||
{
|
||||
SetImGuiKeyMap();
|
||||
return true;
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
protected:
|
||||
virtual void FixIncompatibleSettings(bool display_osd_messages) override;
|
||||
|
||||
bool CreatePlatformWindow(bool fullscreen) override;
|
||||
bool CreatePlatformWindow() override;
|
||||
void DestroyPlatformWindow() override;
|
||||
std::optional<WindowInfo> GetPlatformWindowInfo() override;
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ bool Win32HostInterface::RegisterWindowClass()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Win32HostInterface::CreatePlatformWindow(bool fullscreen)
|
||||
bool Win32HostInterface::CreatePlatformWindow()
|
||||
{
|
||||
m_hwnd = CreateWindowExW(WS_EX_CLIENTEDGE, WINDOW_CLASS_NAME, _T("DuckStation"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,
|
||||
CW_USEDEFAULT, DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT, nullptr, nullptr,
|
||||
|
|
|
@ -16,7 +16,7 @@ public:
|
|||
static std::unique_ptr<NoGUIHostInterface> Create();
|
||||
|
||||
protected:
|
||||
bool CreatePlatformWindow(bool fullscreen) override;
|
||||
bool CreatePlatformWindow() override;
|
||||
void DestroyPlatformWindow() override;
|
||||
std::optional<WindowInfo> GetPlatformWindowInfo() override;
|
||||
|
||||
|
|
Loading…
Reference in New Issue