diff --git a/lib/graphics_engine/include/ge_vulkan_driver.hpp b/lib/graphics_engine/include/ge_vulkan_driver.hpp index bf95c6ddc..1154de060 100644 --- a/lib/graphics_engine/include/ge_vulkan_driver.hpp +++ b/lib/graphics_engine/include/ge_vulkan_driver.hpp @@ -358,7 +358,7 @@ namespace GE { return m_separate_rtt_texture; } void handleDeletedTextures(); void addRTTPolyCount(unsigned count) { m_rtt_polycount += count; } - SDL_Window* getWindow() const { return m_window; } + SDL_Window* getSDLWindow() const { return m_window; } private: struct SwapChainSupportDetails { diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.cpp b/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.cpp index 21de5835d..1dfef29db 100644 --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.cpp +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.cpp @@ -342,7 +342,7 @@ extern "C" void update_fullscreen_desktop(int val) GE::GEVulkanDriver* gevk = GE::getVKDriver(); if (!gevk || !GE::getGEConfig()->m_vulkan_fullscreen_desktop) return; - SDL_Window* window = gevk->getWindow(); + SDL_Window* window = gevk->getSDLWindow(); int prev_width = 0; int prev_height = 0; @@ -952,17 +952,7 @@ bool CIrrDeviceSDL::run() { if (SDL_event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) { - updateNativeScale(); - u32 new_width = SDL_event.window.data1 * NativeScaleX; - u32 new_height = SDL_event.window.data2 * NativeScaleY; - if (new_width != Width || new_height != Height) - { - Width = new_width; - Height = new_height; - if (VideoDriver) - VideoDriver->OnResize(core::dimension2d(Width, Height)); - reset_network_body(); - } + handleNewSize(SDL_event.window.data1, SDL_event.window.data2); } else if (SDL_event.window.event == SDL_WINDOWEVENT_MINIMIZED) { @@ -1028,6 +1018,23 @@ bool CIrrDeviceSDL::run() return !Close; } + +void CIrrDeviceSDL::handleNewSize(u32 width, u32 height) +{ + updateNativeScale(); + u32 new_width = width * NativeScaleX; + u32 new_height = height * NativeScaleY; + if (new_width != Width || new_height != Height) + { + Width = new_width; + Height = new_height; + if (VideoDriver) + VideoDriver->OnResize(core::dimension2d(Width, Height)); + reset_network_body(); + } +} + + //! Activate any joysticks, and generate events for them. bool CIrrDeviceSDL::activateJoysticks(core::array & joystickInfo) { diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.h b/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.h index 6bac91264..af1940961 100644 --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.h +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.h @@ -143,6 +143,7 @@ class MoltenVK; virtual bool isGyroscopeAvailable(); virtual void resetPaused() { clearAllTouchIds(); } + void handleNewSize(u32 width, u32 height); //! Implementation of the linux cursor control class CCursorControl : public gui::ICursorControl diff --git a/src/states_screens/options/options_screen_video.cpp b/src/states_screens/options/options_screen_video.cpp index ef445256f..d201a1da3 100644 --- a/src/states_screens/options/options_screen_video.cpp +++ b/src/states_screens/options/options_screen_video.cpp @@ -45,8 +45,11 @@ #include #include #include +#include +#include "../../lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.h" #endif +#include #include #include @@ -736,6 +739,7 @@ void OptionsScreenVideo::updateBlurTooltip() // -------------------------------------------------------------------------------------------- extern "C" void update_swap_interval(int swap_interval); extern "C" void update_fullscreen_desktop(int val); +extern "C" void reset_network_body(); void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name, const int playerID) @@ -885,11 +889,26 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name, rememberWinpos->setActive(!fullscreen->getState()); #ifndef SERVER_ONLY - if (GE::getDriver()->getDriverType() == video::EDT_VULKAN && - GE::getGEConfig()->m_vulkan_fullscreen_desktop) + GE::GEVulkanDriver* gevk = GE::getVKDriver(); + if (gevk && GE::getGEConfig()->m_vulkan_fullscreen_desktop) { UserConfigParams::m_fullscreen = fullscreen->getState(); update_fullscreen_desktop(UserConfigParams::m_fullscreen); + if (StateManager::get()->getGameState() == GUIEngine::INGAME_MENU) + { + StateManager::get()->popMenu(); + std::function screen_function = + getNewScreenPointer(); + int new_width = 0; + int new_height = 0; + SDL_GetWindowSize(gevk->getSDLWindow(), &new_width, + &new_height); + static_cast(gevk->getIrrlichtDevice()) + ->handleNewSize(new_width, new_height); + irr_driver->handleWindowResize(); + Screen* new_screen = screen_function(); + new_screen->push(); + } } else updateResolutionsList();