From 40c5c46c38779c2bc027ac53df83167de6cc2429 Mon Sep 17 00:00:00 2001 From: Thomas Jentzsch Date: Sun, 3 Apr 2022 19:55:42 +0200 Subject: [PATCH] fixed #885 (detected settings display overwritten by auto pause) --- src/emucore/EventHandler.cxx | 3 ++- src/emucore/OSystem.cxx | 11 +++++++++++ src/emucore/OSystem.hxx | 10 ++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index 15feedb2e..e51163466 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -380,7 +380,8 @@ void EventHandler::handleSystemEvent(SystemEvent e, int, int) break; case SystemEvent::WINDOW_FOCUS_LOST: - if(myOSystem.settings().getBool("autopause") && myState == EventHandlerState::EMULATION) + if(myOSystem.settings().getBool("autopause") && myState == EventHandlerState::EMULATION + && myOSystem.launcherLostFocus()) setState(EventHandlerState::PAUSE); break; diff --git a/src/emucore/OSystem.cxx b/src/emucore/OSystem.cxx index 3930502b5..0a8713739 100644 --- a/src/emucore/OSystem.cxx +++ b/src/emucore/OSystem.cxx @@ -587,9 +587,20 @@ bool OSystem::createLauncher(const string& startdir) #endif myLauncherUsed = myLauncherUsed || status; + myLauncherLostFocus = !status; return status; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool OSystem::launcherLostFocus() +{ + if(myLauncherLostFocus) + return true; + + myLauncherLostFocus = true; + return false; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - string OSystem::getROMInfo(const FilesystemNode& romfile) { diff --git a/src/emucore/OSystem.hxx b/src/emucore/OSystem.hxx index dac7585c0..8c2698f8f 100644 --- a/src/emucore/OSystem.hxx +++ b/src/emucore/OSystem.hxx @@ -379,6 +379,13 @@ class OSystem */ bool launcherUsed() const { return myLauncherUsed; } + /** + Answers whether the ROM launcher has lost focus after starting emulation. + + @return True if launcher has lost focus, otherwise false + */ + bool launcherLostFocus(); + /** Gets all possible info about the ROM by creating a temporary Console object and querying it. @@ -564,6 +571,9 @@ class OSystem // Indicates whether ROM launcher was ever opened during this run bool myLauncherUsed{false}; + // Indicates whether ROM launcher has focus after starting emulation + bool myLauncherLostFocus{true}; + // Indicates whether to stop the main loop bool myQuitLoop{false};