From 62ab514f132ecb1fa7cccba601390776798a6a70 Mon Sep 17 00:00:00 2001 From: Stepanov Igor Date: Fri, 17 Oct 2025 22:36:56 +0300 Subject: [PATCH] fix after merge --- src/window/Window.hpp | 6 +----- src/window/detail/SDLWindow.cpp | 17 +++++++++-------- src/window/detail/SDLWindow.hpp | 4 ++-- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/window/Window.hpp b/src/window/Window.hpp index 3cce5c863..f56b97f52 100644 --- a/src/window/Window.hpp +++ b/src/window/Window.hpp @@ -9,11 +9,7 @@ class ImageData; class Input; struct DisplaySettings; -enum class WindowMode { - WINDOWED, - FULLSCREEN, - BORDERLESS -}; +enum class WindowMode { WINDOWED, FULLSCREEN, BORDERLESS }; class Window { public: diff --git a/src/window/detail/SDLWindow.cpp b/src/window/detail/SDLWindow.cpp index 86d66f56e..86cfe6491 100644 --- a/src/window/detail/SDLWindow.cpp +++ b/src/window/detail/SDLWindow.cpp @@ -18,6 +18,7 @@ #include "graphics/core/ImageData.hpp" #include "graphics/core/Texture.hpp" #include "settings.hpp" +#include "window/Window.hpp" #include "window/detail/SDLInput.hpp" static debug::Logger logger("window"); @@ -318,18 +319,18 @@ void SDLWindow::setCursor(CursorShape shape) { SDL_SetCursor(cursor); } } -void SDLWindow::toggleFullscreen() { - fullscreen = !fullscreen; - if (!SDL_SetWindowFullscreen(window, fullscreen)) { +void SDLWindow::setMode(WindowMode mode) { + // WindowMode::WINDOWED by default have the next options as disbled + if (!SDL_SetWindowFullscreen(window, mode == WindowMode::FULLSCREEN)) { logger.error() << "Cant toggle fullscreen window: " << SDL_GetError(); } - if (!SDL_SyncWindow(window)) { - logger.error() << "Cant sync window after toggle fullscreen: " - << SDL_GetError(); + if (!SDL_SetWindowBordered(window, mode == WindowMode::BORDERLESS)) { + logger.error() << "Cant toggle bordered window: " << SDL_GetError(); } } -bool SDLWindow::isFullscreen() const { - return fullscreen; + +WindowMode SDLWindow::getMode() const { + return mode; } void SDLWindow::setIcon(const ImageData *image) { diff --git a/src/window/detail/SDLWindow.hpp b/src/window/detail/SDLWindow.hpp index 581d0fb34..8e9f23e8a 100644 --- a/src/window/detail/SDLWindow.hpp +++ b/src/window/detail/SDLWindow.hpp @@ -24,8 +24,8 @@ public: void setShouldClose(bool flag) override; void setCursor(CursorShape shape) override; - void toggleFullscreen() override; - bool isFullscreen() const override; + void setMode(WindowMode mode) override; + WindowMode getMode() const override; void setIcon(const ImageData *image) override;