Skip to content

Commit

Permalink
Fix SDL window "sticking" to the center of the screen after using vid…
Browse files Browse the repository at this point in the history
…_setsize.
  • Loading branch information
Marisa Kirisame authored and coelckers committed Aug 15, 2018
1 parent e18b172 commit 4e690b1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/posix/sdl/gl_sysfb.h
Expand Up @@ -31,6 +31,8 @@ class SystemGLFrameBuffer : public DFrameBuffer
SDL_Window *GetSDLWindow() { return Screen; }
void GetWindowBordersSize(int &top, int &left);

bool m_fsswitch;

protected:
void SetGammaTable(uint16_t *tbl);
void ResetGammaTable();
Expand Down
16 changes: 13 additions & 3 deletions src/posix/sdl/sdlglvideo.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}
}

Expand Down Expand Up @@ -414,7 +424,7 @@ void ProcessSDLWindowEvent(const SDL_WindowEvent &event)
break;

case SDL_WINDOWEVENT_RESIZED:
if (!fullscreen)
if (!fullscreen && !(static_cast<SystemGLFrameBuffer *>(screen)->m_fsswitch))
{
win_w = event.data1;
win_h = event.data2;
Expand Down

0 comments on commit 4e690b1

Please sign in to comment.