diff --git a/bsnes/target-bsnes/bsnes.cpp b/bsnes/target-bsnes/bsnes.cpp index b7236ab1..c7bb3dd3 100644 --- a/bsnes/target-bsnes/bsnes.cpp +++ b/bsnes/target-bsnes/bsnes.cpp @@ -40,7 +40,6 @@ auto nall::main(Arguments arguments) -> void { settings.load(); Application::setName("bsnes"); - Application::setScreenSaver(settings.general.screenSaver); Application::setToolTips(settings.general.toolTips); Instances::presentation.construct(); diff --git a/bsnes/target-bsnes/program/program.cpp b/bsnes/target-bsnes/program/program.cpp index 66575e0f..8b236dd3 100644 --- a/bsnes/target-bsnes/program/program.cpp +++ b/bsnes/target-bsnes/program/program.cpp @@ -85,7 +85,16 @@ auto Program::main() -> void { inputManager.poll(); inputManager.pollHotkeys(); - if(inactive()) { + static bool previouslyInactive = true; + bool currentlyInactive = inactive(); + + // check if emulator has transitioned from active to inactive or vice versa + if(previouslyInactive != currentlyInactive) { + previouslyInactive = currentlyInactive; + Application::setScreenSaver(currentlyInactive || settings.general.screenSaver); + } + + if(currentlyInactive) { audio.clear(); usleep(20 * 1000); if(settings.emulator.runAhead.frames == 0) viewportRefresh(); diff --git a/bsnes/target-bsnes/settings/emulator.cpp b/bsnes/target-bsnes/settings/emulator.cpp index 5561ac6f..00f94e76 100644 --- a/bsnes/target-bsnes/settings/emulator.cpp +++ b/bsnes/target-bsnes/settings/emulator.cpp @@ -25,6 +25,8 @@ auto EmulatorSettings::create() -> void { }); screenSaver.setText("Allow screensaver during emulation").setChecked(settings.general.screenSaver).onToggle([&] { settings.general.screenSaver = screenSaver.checked(); + // setting can be toggled while emulation is active + if(!program.inactive()) Application::setScreenSaver(settings.general.screenSaver); }); optionsSpacer.setColor({192, 192, 192});