diff --git a/client/SDL/SDL3/sdl_window.cpp b/client/SDL/SDL3/sdl_window.cpp index b5e2dd90c..0a1aa0fcf 100644 --- a/client/SDL/SDL3/sdl_window.cpp +++ b/client/SDL/SDL3/sdl_window.cpp @@ -23,15 +23,14 @@ #include "sdl_window.hpp" #include "sdl_utils.hpp" -SdlWindow::SdlWindow(const std::string& title, Sint32 startupX, Sint32 startupY, Sint32 width, - Sint32 height, [[maybe_unused]] Uint32 flags) +SdlWindow::SdlWindow(const std::string& title, const SDL_Rect& rect, [[maybe_unused]] Uint32 flags) { auto props = SDL_CreateProperties(); SDL_SetStringProperty(props, SDL_PROP_WINDOW_CREATE_TITLE_STRING, title.c_str()); - SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_X_NUMBER, startupX); - SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_Y_NUMBER, startupY); - SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_WIDTH_NUMBER, width); - SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_HEIGHT_NUMBER, height); + SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_X_NUMBER, rect.x); + SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_Y_NUMBER, rect.y); + SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_WIDTH_NUMBER, rect.w); + SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_HEIGHT_NUMBER, rect.h); if (flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) SDL_SetBooleanProperty(props, SDL_PROP_WINDOW_CREATE_HIGH_PIXEL_DENSITY_BOOLEAN, true); @@ -47,8 +46,8 @@ SdlWindow::SdlWindow(const std::string& title, Sint32 startupX, Sint32 startupY, auto sc = scale(); const int iscale = static_cast(sc * 100.0f); - auto w = 100 * width / iscale; - auto h = 100 * height / iscale; + auto w = 100 * rect.w / iscale; + auto h = 100 * rect.h / iscale; std::ignore = resize({ w, h }); SDL_SetHint(SDL_HINT_APP_NAME, ""); std::ignore = SDL_SyncWindow(_window); @@ -315,26 +314,20 @@ SdlWindow SdlWindow::create(SDL_DisplayID id, const std::string& title, Uint32 f Uint32 height) { flags |= SDL_WINDOW_HIGH_PIXEL_DENSITY; - auto startupX = static_cast(SDL_WINDOWPOS_CENTERED_DISPLAY(id)); - auto startupY = static_cast(SDL_WINDOWPOS_CENTERED_DISPLAY(id)); + + SDL_Rect rect = { static_cast(SDL_WINDOWPOS_CENTERED_DISPLAY(id)), + static_cast(SDL_WINDOWPOS_CENTERED_DISPLAY(id)), static_cast(width), + static_cast(height) }; if ((flags & SDL_WINDOW_FULLSCREEN) != 0) { - SDL_Rect rect = {}; - SDL_GetDisplayBounds(id, &rect); - startupX = rect.x; - startupY = rect.y; - width = static_cast(rect.w); - height = static_cast(rect.h); + std::ignore = SDL_GetDisplayBounds(id, &rect); } - SdlWindow window{ title, startupX, startupY, static_cast(width), static_cast(height), - flags }; + SdlWindow window{ title, rect, flags }; if ((flags & (SDL_WINDOW_FULLSCREEN)) != 0) { - SDL_Rect rect = {}; - SDL_GetDisplayBounds(id, &rect); window.setOffsetX(rect.x); window.setOffsetY(rect.y); } diff --git a/client/SDL/SDL3/sdl_window.hpp b/client/SDL/SDL3/sdl_window.hpp index c2a8e5973..ae6a72486 100644 --- a/client/SDL/SDL3/sdl_window.hpp +++ b/client/SDL/SDL3/sdl_window.hpp @@ -80,8 +80,7 @@ class SdlWindow void updateSurface(); protected: - SdlWindow(const std::string& title, Sint32 startupX, Sint32 startupY, Sint32 width, - Sint32 height, Uint32 flags); + SdlWindow(const std::string& title, const SDL_Rect& rect, Uint32 flags); private: SDL_Window* _window = nullptr;