From a77b8bfcba94c85c0438be30eeeaa8adfd7e6a15 Mon Sep 17 00:00:00 2001 From: Mathieu Schroeter Date: Fri, 3 Mar 2017 21:51:52 +0100 Subject: [PATCH] Handle properly the fullscreen mode The textures must be reloaded like with the new window size. --- src/event.cxx | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/event.cxx b/src/event.cxx index b05e732..4f7abc3 100644 --- a/src/event.cxx +++ b/src/event.cxx @@ -1612,8 +1612,30 @@ POINT CEvent::GetMousePos() void CEvent::SetFullScreen (bool bFullScreen) { + int x, y; + SDL_GetMouseState (&x, &y); + x /= m_WindowScale; + y /= m_WindowScale; + + m_WindowScale = 1; + SDL_SetWindowSize (g_window, LXIMAGE, LYIMAGE); + m_bFullScreen = bFullScreen; SDL_SetWindowFullscreen (g_window, bFullScreen ? SDL_WINDOW_FULLSCREEN : 0); + SDL_SetWindowPosition (g_window, + SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED); + + m_pPixmap->ReloadTargetTextures (); + + /* Force this update before otherwise the coordinates retrieved with + * the Warp SDL function are corresponding to the previous size. + */ + CEvent::PushUserEvent (WM_UPDATE); + + auto coord = new SDL_Point; // Released by the event handler. + coord->x = x; + coord->y = y; + CEvent::PushUserEvent (WM_WARPMOUSE, coord); } /**