From 4e690b1f60d9f9d9154bbf342e79f5a5769ac60d Mon Sep 17 00:00:00 2001 From: Marisa Kirisame Date: Wed, 15 Aug 2018 19:41:52 +0200 Subject: [PATCH] Fix SDL window "sticking" to the center of the screen after using vid_setsize. --- src/posix/sdl/gl_sysfb.h | 2 ++ src/posix/sdl/sdlglvideo.cpp | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/posix/sdl/gl_sysfb.h b/src/posix/sdl/gl_sysfb.h index c9c1e8192..ee2713bc5 100644 --- a/src/posix/sdl/gl_sysfb.h +++ b/src/posix/sdl/gl_sysfb.h @@ -31,6 +31,8 @@ public: SDL_Window *GetSDLWindow() { return Screen; } void GetWindowBordersSize(int &top, int &left); + bool m_fsswitch; + protected: void SetGammaTable(uint16_t *tbl); void ResetGammaTable(); diff --git a/src/posix/sdl/sdlglvideo.cpp b/src/posix/sdl/sdlglvideo.cpp index 651842083..15c0e4944 100644 --- a/src/posix/sdl/sdlglvideo.cpp +++ b/src/posix/sdl/sdlglvideo.cpp @@ -175,6 +175,8 @@ IVideo *gl_CreateVideo() SystemGLFrameBuffer::SystemGLFrameBuffer (void *, bool fullscreen) : DFrameBuffer (vid_defwidth, vid_defheight) { + m_fsswitch = false; + // SDL_GetWindowBorderSize() is only available since 2.0.5, but because // GZDoom supports platforms with older SDL2 versions, this function // has to be dynamically loaded @@ -334,8 +336,16 @@ void SystemGLFrameBuffer::ToggleFullscreen(bool yes) SDL_SetWindowFullscreen(Screen, yes ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0); if ( !yes ) { - fullscreen = false; - SetWindowSize(win_w, win_h); + if ( !m_fsswitch ) + { + m_fsswitch = true; + fullscreen = false; + } + else + { + m_fsswitch = false; + SetWindowSize(win_w, win_h); + } } } @@ -414,7 +424,7 @@ void ProcessSDLWindowEvent(const SDL_WindowEvent &event) break; case SDL_WINDOWEVENT_RESIZED: - if (!fullscreen) + if (!fullscreen && !(static_cast(screen)->m_fsswitch)) { win_w = event.data1; win_h = event.data2;