mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-16 01:35:07 +00:00
GUI: Remember window x/y position and maximized state. Warning: This may cause issues when windows are re-ordered. Is there a way to fix windows spawning outside of screen boundaries?
This commit is contained in:
parent
e226d09807
commit
e88e0a4e4e
2 changed files with 52 additions and 17 deletions
|
@ -2536,6 +2536,7 @@ bool FurnaceGUI::loop() {
|
||||||
if (settings.powerSave) SDL_WaitEventTimeout(NULL,500);
|
if (settings.powerSave) SDL_WaitEventTimeout(NULL,500);
|
||||||
}
|
}
|
||||||
eventTimeBegin=SDL_GetPerformanceCounter();
|
eventTimeBegin=SDL_GetPerformanceCounter();
|
||||||
|
bool updateWindow = false;
|
||||||
while (SDL_PollEvent(&ev)) {
|
while (SDL_PollEvent(&ev)) {
|
||||||
WAKE_UP;
|
WAKE_UP;
|
||||||
ImGui_ImplSDL2_ProcessEvent(&ev);
|
ImGui_ImplSDL2_ProcessEvent(&ev);
|
||||||
|
@ -2642,6 +2643,20 @@ bool FurnaceGUI::loop() {
|
||||||
scrW=ev.window.data1/dpiScale;
|
scrW=ev.window.data1/dpiScale;
|
||||||
scrH=ev.window.data2/dpiScale;
|
scrH=ev.window.data2/dpiScale;
|
||||||
#endif
|
#endif
|
||||||
|
updateWindow=true;
|
||||||
|
break;
|
||||||
|
case SDL_WINDOWEVENT_MOVED:
|
||||||
|
scrX=ev.window.data1;
|
||||||
|
scrY=ev.window.data2;
|
||||||
|
updateWindow=true;
|
||||||
|
break;
|
||||||
|
case SDL_WINDOWEVENT_MAXIMIZED:
|
||||||
|
scrMax=true;
|
||||||
|
updateWindow=true;
|
||||||
|
break;
|
||||||
|
case SDL_WINDOWEVENT_RESTORED:
|
||||||
|
scrMax=false;
|
||||||
|
updateWindow=true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2697,6 +2712,18 @@ bool FurnaceGUI::loop() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update config x/y/w/h values based on scrMax state
|
||||||
|
if(updateWindow) {
|
||||||
|
if(scrMax) {
|
||||||
|
scrConfY=scrConfX = SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetWindowDisplayIndex(sdlWin));
|
||||||
|
} else {
|
||||||
|
scrConfX=scrX;
|
||||||
|
scrConfY=scrY;
|
||||||
|
scrConfW=scrW;
|
||||||
|
scrConfH=scrH;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
wantCaptureKeyboard=ImGui::GetIO().WantTextInput;
|
wantCaptureKeyboard=ImGui::GetIO().WantTextInput;
|
||||||
|
|
||||||
if (wantCaptureKeyboard!=oldWantCaptureKeyboard) {
|
if (wantCaptureKeyboard!=oldWantCaptureKeyboard) {
|
||||||
|
@ -4436,8 +4463,11 @@ bool FurnaceGUI::init() {
|
||||||
SDL_Surface* icon=SDL_CreateRGBSurfaceFrom(furIcon,256,256,32,256*4,0xff,0xff00,0xff0000,0xff000000);
|
SDL_Surface* icon=SDL_CreateRGBSurfaceFrom(furIcon,256,256,32,256*4,0xff,0xff00,0xff0000,0xff000000);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
scrW=e->getConfInt("lastWindowWidth",1280);
|
scrW=scrConfW=e->getConfInt("lastWindowWidth",1280);
|
||||||
scrH=e->getConfInt("lastWindowHeight",800);
|
scrH=scrConfH=e->getConfInt("lastWindowHeight",800);
|
||||||
|
scrX=scrConfX=e->getConfInt("lastWindowX",SDL_WINDOWPOS_CENTERED);
|
||||||
|
scrY=scrConfY=e->getConfInt("lastWindowY",SDL_WINDOWPOS_CENTERED);
|
||||||
|
scrMax=e->getConfBool("lastWindowMax",false);
|
||||||
|
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
SDL_Rect displaySize;
|
SDL_Rect displaySize;
|
||||||
|
@ -4453,7 +4483,7 @@ bool FurnaceGUI::init() {
|
||||||
|
|
||||||
SDL_Init(SDL_INIT_VIDEO);
|
SDL_Init(SDL_INIT_VIDEO);
|
||||||
|
|
||||||
sdlWin=SDL_CreateWindow("Furnace",SDL_WINDOWPOS_CENTERED,SDL_WINDOWPOS_CENTERED,scrW*dpiScale,scrH*dpiScale,SDL_WINDOW_RESIZABLE|SDL_WINDOW_ALLOW_HIGHDPI|(fullScreen?SDL_WINDOW_FULLSCREEN_DESKTOP:0));
|
sdlWin=SDL_CreateWindow("Furnace",scrX,scrY,scrW*dpiScale,scrH*dpiScale,SDL_WINDOW_RESIZABLE|SDL_WINDOW_ALLOW_HIGHDPI|(scrMax?SDL_WINDOW_MAXIMIZED:0)|(fullScreen?SDL_WINDOW_FULLSCREEN_DESKTOP:0));
|
||||||
if (sdlWin==NULL) {
|
if (sdlWin==NULL) {
|
||||||
logE("could not open window! %s",SDL_GetError());
|
logE("could not open window! %s",SDL_GetError());
|
||||||
return false;
|
return false;
|
||||||
|
@ -4619,8 +4649,11 @@ bool FurnaceGUI::finish() {
|
||||||
e->setConf("spoilerOpen",spoilerOpen);
|
e->setConf("spoilerOpen",spoilerOpen);
|
||||||
|
|
||||||
// commit last window size
|
// commit last window size
|
||||||
e->setConf("lastWindowWidth",scrW);
|
e->setConf("lastWindowWidth",scrConfW);
|
||||||
e->setConf("lastWindowHeight",scrH);
|
e->setConf("lastWindowHeight",scrConfH);
|
||||||
|
e->setConf("lastWindowX",scrConfX);
|
||||||
|
e->setConf("lastWindowY",scrConfY);
|
||||||
|
e->setConf("lastWindowMax",scrMax);
|
||||||
|
|
||||||
e->setConf("tempoView",tempoView);
|
e->setConf("tempoView",tempoView);
|
||||||
e->setConf("waveHex",waveHex);
|
e->setConf("waveHex",waveHex);
|
||||||
|
|
|
@ -996,7 +996,9 @@ class FurnaceGUI {
|
||||||
|
|
||||||
FurnaceGUIFileDialog* fileDialog;
|
FurnaceGUIFileDialog* fileDialog;
|
||||||
|
|
||||||
int scrW, scrH;
|
int scrW, scrH, scrConfW, scrConfH;
|
||||||
|
int scrX, scrY, scrConfX, scrConfY;
|
||||||
|
bool scrMax;
|
||||||
|
|
||||||
double dpiScale;
|
double dpiScale;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue