diff options
Diffstat (limited to 'src/frontend/qt_sdl/main.cpp')
-rw-r--r-- | src/frontend/qt_sdl/main.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/frontend/qt_sdl/main.cpp b/src/frontend/qt_sdl/main.cpp index c5ce692..7c7fe7d 100644 --- a/src/frontend/qt_sdl/main.cpp +++ b/src/frontend/qt_sdl/main.cpp @@ -1534,6 +1534,19 @@ void MainWindow::dropEvent(QDropEvent* event) } } +void MainWindow::onAppStateChanged(Qt::ApplicationState state) +{ + if (state == Qt::ApplicationInactive) + { + if (Config::PauseLostFocus && emuThread->emuIsRunning()) + emuThread->emuPause(); + } + else if (state == Qt::ApplicationActive) + { + if (Config::PauseLostFocus && !pausedManually) + emuThread->emuUnpause(); + } +} QString MainWindow::loadErrorStr(int error) { @@ -2002,11 +2015,13 @@ void MainWindow::onPause(bool checked) { emuThread->emuPause(); OSD::AddMessage(0, "Paused"); + pausedManually = true; } else { emuThread->emuUnpause(); OSD::AddMessage(0, "Resumed"); + pausedManually = false; } } @@ -2152,6 +2167,7 @@ void MainWindow::onOpenInterfaceSettings() InterfaceSettingsDialog* dlg = InterfaceSettingsDialog::openDlg(this); connect(dlg, &InterfaceSettingsDialog::finished, this, &MainWindow::onInterfaceSettingsFinished); connect(dlg, &InterfaceSettingsDialog::updateMouseTimer, this, &MainWindow::onUpdateMouseTimer); + connect(dlg, &InterfaceSettingsDialog::focusUnpauseEmu, emuThread, &EmuThread::emuUnpause); } void MainWindow::onUpdateMouseTimer() @@ -2505,6 +2521,8 @@ int main(int argc, char** argv) emuThread->start(); emuThread->emuPause(); + QObject::connect(&melon, &QApplication::applicationStateChanged, mainWindow, &MainWindow::onAppStateChanged); + if (argc > 1) { char* file = argv[1]; |