Revert 7868

git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@7869 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: ebe28e2225c3142cf334a25817a3eaf24fe93a2f
Former-commit-id: cf29c585edefd994f38475ee0ed61764fa293756
This commit is contained in:
beaglejoe 2022-01-03 16:35:33 +00:00
parent a8711df56b
commit 18880c3e26

View file

@ -319,6 +319,17 @@ SDL_Surface* gfScrCreateWindow(int nWinWidth, int nWinHeight, int nTotalDepth,in
#endif
0x00000000);
if (bfVideoMode & SDL_WINDOW_FULLSCREEN)
{
SDL_Rect bounds;
/* Work around SDL2 bug */
if (SDL_GetDisplayBounds(GfScrStartDisplayId, &bounds) == 0) {
if (bounds.w == nWinWidth && bounds.h == nWinHeight)
SDL_SetWindowFullscreen(GfuiWindow, SDL_WINDOW_FULLSCREEN_DESKTOP);
else SDL_SetWindowFullscreen(GfuiWindow, SDL_WINDOW_FULLSCREEN);
} else SDL_SetWindowFullscreen(GfuiWindow, SDL_WINDOW_FULLSCREEN);
}
return PScreenSurface;
}
@ -430,7 +441,7 @@ bool GfScrInitSDL2(int nWinWidth, int nWinHeight, int nFullScreen)
bFullScreen = nFullScreen ? true : false;
if(bFullScreen)
bfVideoMode |= SDL_WINDOW_FULLSCREEN_DESKTOP;
bfVideoMode |= SDL_WINDOW_FULLSCREEN;
/* TODO : move and re-implement these?
bool bAlphaChannel =
@ -475,7 +486,7 @@ bool GfScrInitSDL2(int nWinWidth, int nWinHeight, int nFullScreen)
// Failed : Try and remove the full-screen requirement if present ...
if (!PScreenSurface && bFullScreen)
{
bfVideoMode &= ~SDL_WINDOW_FULLSCREEN_DESKTOP;
bfVideoMode &= ~SDL_WINDOW_FULLSCREEN;
PScreenSurface = gfScrCreateWindow(nWinWidth, nWinHeight, nTotalDepth,bfVideoMode);
if (!PScreenSurface)
GfLogTrace("Can't get a non-full-screen %dx%dx%d compatible video mode\n",
@ -542,7 +553,7 @@ bool GfScrInitSDL2(int nWinWidth, int nWinHeight, int nFullScreen)
// Report about selected SDL video mode.
GfLogInfo("Selected SDL video mode :\n");
GfLogInfo(" Full screen : %s\n", (bfVideoMode & SDL_WINDOW_FULLSCREEN_DESKTOP) ? "Yes" : "No");
GfLogInfo(" Full screen : %s\n", (bfVideoMode & SDL_WINDOW_FULLSCREEN) ? "Yes" : "No");
GfLogInfo(" Size : %dx%d\n", nWinWidth, nWinHeight);
GfLogInfo(" Color depth : %d bits\n", nTotalDepth);
@ -556,6 +567,27 @@ bool GfScrInitSDL2(int nWinWidth, int nWinHeight, int nFullScreen)
SDL_RestoreWindow(GfuiWindow);
}
/*
#ifdef WIN32
// Under Windows, give an initial position to the window if not full-screen mode
// (under Linux/Mac OS X, no need, the window manager smartly takes care of this).
if (!(bfVideoMode & SDL_WINDOW_FULLSCREEN))
{
// Try to center the game Window on the desktop, but keep the title bar visible if any.
const HWND hDesktop = GetDesktopWindow();
RECT rectDesktop;
GetWindowRect(hDesktop, &rectDesktop);
const int nWMWinXPos =
nWinWidth >= rectDesktop.right ? 0 : (rectDesktop.right - nWinWidth) / 2;
const int nWMWinYPos =
nWinHeight >= rectDesktop.bottom ? 0 : (rectDesktop.bottom - nWinHeight) / 2;
GfuiInitWindowPositionAndSize(nWMWinXPos, nWMWinYPos, nWinWidth, nWinHeight);
}
#endif
*/
// Initialize the Open GL viewport.
gfScrReshapeViewport(nWinWidth, nWinHeight);
@ -666,11 +698,19 @@ bool GfScrToggleFullScreen()
{
Uint32 flags = SDL_GetWindowFlags(GfuiWindow);
if (flags & SDL_WINDOW_FULLSCREEN_DESKTOP) {
if ((flags & SDL_WINDOW_FULLSCREEN) || (flags & SDL_WINDOW_FULLSCREEN_DESKTOP)) {
SDL_SetWindowFullscreen(GfuiWindow, 0);
return false;
} else {
SDL_Rect bounds;
/* Work around SDL2 bug */
if (SDL_GetDisplayBounds(GfScrStartDisplayId, &bounds) == 0) {
if (SDL_FALSE) //(bounds.w == nWinWidth && bounds.h == nWinHeight)
SDL_SetWindowFullscreen(GfuiWindow, SDL_WINDOW_FULLSCREEN_DESKTOP);
else SDL_SetWindowFullscreen(GfuiWindow, SDL_WINDOW_FULLSCREEN);
} else SDL_SetWindowFullscreen(GfuiWindow, SDL_WINDOW_FULLSCREEN);
return true;
}
}