1
0
mirror of https://github.com/blupi-games/planetblupi synced 2024-12-30 10:15:36 +01:00

Fix mostly the fullscreen switching with more than 1 display

It concerns the issue #59.

It's not perfect but it works much better (at leats on Linux). The idea
is to move the window to the top left corner of the current display.
This commit is contained in:
Mathieu Schroeter 2018-05-29 18:06:04 +02:00
parent 96cbf54167
commit 43ba6df7af

View File

@ -1666,10 +1666,36 @@ CEvent::SetFullScreen (bool bFullScreen)
SDL_SetWindowSize (g_window, LXIMAGE, LYIMAGE);
g_bFullScreen = bFullScreen;
int displayIndex = SDL_GetWindowDisplayIndex (g_window);
if (g_bFullScreen)
{
int displays = SDL_GetNumVideoDisplays ();
std::vector<SDL_Rect> displayBounds;
for (int i = 0; i < displays; i++)
{
displayBounds.push_back (SDL_Rect ());
SDL_GetDisplayBounds (i, &displayBounds.back ());
}
/* It seems that the fullscreen switching works better when the window
* is at the top left corner of the current display.
*/
SDL_SetWindowPosition (
g_window, displayBounds[displayIndex].x, displayBounds[displayIndex].y);
}
SDL_SetWindowFullscreen (g_window, bFullScreen ? SDL_WINDOW_FULLSCREEN : 0);
SDL_SetWindowBordered (g_window, bFullScreen ? SDL_FALSE : SDL_TRUE);
SDL_SetWindowGrab (g_window, bFullScreen ? SDL_TRUE : SDL_FALSE);
if (!g_bFullScreen)
SDL_SetWindowPosition (
g_window, SDL_WINDOWPOS_CENTERED_DISPLAY (displayIndex),
SDL_WINDOWPOS_CENTERED_DISPLAY (displayIndex));
m_pPixmap->LoadCursors (g_zoom);
m_pPixmap->ReloadTargetTextures ();