mirror of https://github.com/bsnes-emu/bsnes.git
target-bsnes: Only suppress screensavers when active
This commit reworks when the screensaver suppression kicks in. Previously, bsnes would only engage screensaver suppression once, on application launch. Now that the option is exposed and can be toggled at any time, we have to be a little more clever. Additionally, screensaver suppression is now only engaged while emulation is active, because it doesn't make much sense otherwise.
This commit is contained in:
parent
dba608a808
commit
d29677b778
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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});
|
||||
|
||||
|
|
Loading…
Reference in New Issue