From 4e97923cee2a1581b83c6334afb99587286c6c1f Mon Sep 17 00:00:00 2001 From: Igor Stepanov Date: Fri, 10 Oct 2025 17:27:40 +0300 Subject: [PATCH] fix cursors --- src/window/detail/window_sdl.cpp | 13 +++++++++++-- src/window/detail/window_sdl.hpp | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/window/detail/window_sdl.cpp b/src/window/detail/window_sdl.cpp index b8a4054d0..c60870eb1 100644 --- a/src/window/detail/window_sdl.cpp +++ b/src/window/detail/window_sdl.cpp @@ -257,7 +257,13 @@ void window_sdl::setShouldClose(bool flag) { } void window_sdl::setCursor(CursorShape shape) { - SDL_Cursor *cursor = nullptr; + // so it method called each frame, we always recreate cursor. + // Refactor it + if (cursor) { + SDL_DestroyCursor(cursor); + cursor = nullptr; + } + switch (shape) { case CursorShape::ARROW: cursor = SDL_CreateSystemCursor( @@ -313,7 +319,6 @@ void window_sdl::setCursor(CursorShape shape) { } if (cursor) { SDL_SetCursor(cursor); - SDL_DestroyCursor(cursor); } } void window_sdl::toggleFullscreen() { @@ -321,6 +326,10 @@ void window_sdl::toggleFullscreen() { if (!SDL_SetWindowFullscreen(window, fullscreen)) { logger.error() << "Cant toggle fullscreen window: " << SDL_GetError(); } + if (!SDL_SyncWindow(window)) { + logger.error() << "Cant sync window after toggle fullscreen: " + << SDL_GetError(); + } } bool window_sdl::isFullscreen() const { return fullscreen; diff --git a/src/window/detail/window_sdl.hpp b/src/window/detail/window_sdl.hpp index e26fc6768..d6f507258 100644 --- a/src/window/detail/window_sdl.hpp +++ b/src/window/detail/window_sdl.hpp @@ -49,6 +49,7 @@ private: SDL_Window *window = nullptr; SDL_Renderer *renderer = nullptr; + SDL_Cursor *cursor = nullptr; SDL_GLContext context = nullptr; std::stack scissorStack;