diff --git a/src/duckstation-nogui/nogui_host_interface.cpp b/src/duckstation-nogui/nogui_host_interface.cpp index 45cdac42b..4ff243018 100644 --- a/src/duckstation-nogui/nogui_host_interface.cpp +++ b/src/duckstation-nogui/nogui_host_interface.cpp @@ -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 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"); } diff --git a/src/duckstation-nogui/nogui_host_interface.h b/src/duckstation-nogui/nogui_host_interface.h index 42964e843..bcfb5a3ad 100644 --- a/src/duckstation-nogui/nogui_host_interface.h +++ b/src/duckstation-nogui/nogui_host_interface.h @@ -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 GetPlatformWindowInfo() = 0; - bool CreateDisplay(); + bool CreateDisplay(bool fullscreen); void DestroyDisplay(); void RunCallbacks(); diff --git a/src/duckstation-nogui/sdl_host_interface.cpp b/src/duckstation-nogui/sdl_host_interface.cpp index 565ae98d5..cadbc2fde 100644 --- a/src/duckstation-nogui/sdl_host_interface.cpp +++ b/src/duckstation-nogui/sdl_host_interface.cpp @@ -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 SDLHostInterface::GetPlatformWindowInfo() diff --git a/src/duckstation-nogui/sdl_host_interface.h b/src/duckstation-nogui/sdl_host_interface.h index 2a0a9437e..6eece50bb 100644 --- a/src/duckstation-nogui/sdl_host_interface.h +++ b/src/duckstation-nogui/sdl_host_interface.h @@ -25,7 +25,7 @@ protected: std::optional GetHostKeyCode(const std::string_view key_code) const override; - bool CreatePlatformWindow(bool fullscreen) override; + bool CreatePlatformWindow() override; void DestroyPlatformWindow() override; std::optional GetPlatformWindowInfo() override; diff --git a/src/duckstation-nogui/vty_host_interface.cpp b/src/duckstation-nogui/vty_host_interface.cpp index bd2ec1259..aa753e7d1 100644 --- a/src/duckstation-nogui/vty_host_interface.cpp +++ b/src/duckstation-nogui/vty_host_interface.cpp @@ -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; diff --git a/src/duckstation-nogui/vty_host_interface.h b/src/duckstation-nogui/vty_host_interface.h index 826e767e3..e18841e1a 100644 --- a/src/duckstation-nogui/vty_host_interface.h +++ b/src/duckstation-nogui/vty_host_interface.h @@ -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 GetPlatformWindowInfo() override; diff --git a/src/duckstation-nogui/win32_host_interface.cpp b/src/duckstation-nogui/win32_host_interface.cpp index f741b221d..30fd41f75 100644 --- a/src/duckstation-nogui/win32_host_interface.cpp +++ b/src/duckstation-nogui/win32_host_interface.cpp @@ -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, diff --git a/src/duckstation-nogui/win32_host_interface.h b/src/duckstation-nogui/win32_host_interface.h index ee86f27f7..c25a067ec 100644 --- a/src/duckstation-nogui/win32_host_interface.h +++ b/src/duckstation-nogui/win32_host_interface.h @@ -16,7 +16,7 @@ public: static std::unique_ptr Create(); protected: - bool CreatePlatformWindow(bool fullscreen) override; + bool CreatePlatformWindow() override; void DestroyPlatformWindow() override; std::optional GetPlatformWindowInfo() override;