Fixed auto-resolution and window after fullscreen

Gamers do not need to enter the resolution settings in the config.
This commit is contained in:
pk-2000 2020-12-25 05:46:10 +02:00 committed by GitHub
parent 9b7a91075b
commit 1ad14d35da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 7 deletions

View File

@ -126,6 +126,10 @@ void EventThread::process(RGSSThreadData &rtData)
int defScreenW, defScreenH; int defScreenW, defScreenH;
defScreenW = rtData.config.defScreenW; defScreenW = rtData.config.defScreenW;
defScreenH = rtData.config.defScreenH; defScreenH = rtData.config.defScreenH;
SDL_SetWindowSize(win, 544, 416);
int defScreenW_new, defScreenH_new;
int firstrun;
firstrun = 0;
int toggleFSMod = rtData.config.anyAltToggleFS ? KMOD_ALT : KMOD_LALT; int toggleFSMod = rtData.config.anyAltToggleFS ? KMOD_ALT : KMOD_LALT;
fps.lastFrame = SDL_GetPerformanceCounter(); fps.lastFrame = SDL_GetPerformanceCounter();
@ -212,7 +216,17 @@ void EventThread::process(RGSSThreadData &rtData)
{ {
case SDL_WINDOWEVENT_SIZE_CHANGED : case SDL_WINDOWEVENT_SIZE_CHANGED :
winW = event.window.data1; winW = event.window.data1;
winH = event.window.data2; winH = event.window.data2;
if (firstrun == 1)
{
firstrun = 2;
SDL_SetWindowPosition(win, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
}
if (firstrun == 0)
{
firstrun = 1;
SDL_SetWindowPosition(win, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
}
windowSizeMsg.post(Vec2i(winW, winH)); windowSizeMsg.post(Vec2i(winW, winH));
resetInputStates(); resetInputStates();
@ -268,13 +282,11 @@ void EventThread::process(RGSSThreadData &rtData)
SDL_SetWindowTitle(win, pendingTitle); SDL_SetWindowTitle(win, pendingTitle);
pendingTitle[0] = '\0'; pendingTitle[0] = '\0';
havePendingTitle = false; havePendingTitle = false;
SDL_SetWindowSize(win, defScreenW, defScreenH); SDL_SetWindowSize(win, defScreenW_new, defScreenH_new);
SDL_SetWindowPosition(win, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
} }
else else
{ {
SDL_SetWindowSize(win, defScreenW, defScreenH); SDL_SetWindowSize(win, defScreenW_new, defScreenH_new);
SDL_SetWindowPosition(win, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
} }
break; break;
@ -555,8 +567,6 @@ void EventThread::resetInputStates()
void EventThread::setFullscreen(SDL_Window *win, bool mode) void EventThread::setFullscreen(SDL_Window *win, bool mode)
{ {
SDL_GetDesktopDisplayMode(0, &dm); SDL_GetDesktopDisplayMode(0, &dm);
SDL_SetWindowSize(win, dm.w, dm.h);
SDL_WINDOWEVENT_SIZE_CHANGED;
SDL_SetWindowFullscreen SDL_SetWindowFullscreen
(win, mode ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0); (win, mode ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
fullscreen = mode; fullscreen = mode;