diff --git a/src/citra_qt/configuration/config.cpp b/src/citra_qt/configuration/config.cpp
index 5c0abbc2a9..74d779b0a9 100644
--- a/src/citra_qt/configuration/config.cpp
+++ b/src/citra_qt/configuration/config.cpp
@@ -768,6 +768,7 @@ void Config::ReadUIValues() {
ReadBasicSetting(UISettings::values.callout_flags);
ReadBasicSetting(UISettings::values.show_console);
ReadBasicSetting(UISettings::values.pause_when_in_background);
+ ReadBasicSetting(UISettings::values.mute_when_in_background);
ReadBasicSetting(UISettings::values.hide_mouse);
}
@@ -1239,6 +1240,7 @@ void Config::SaveUIValues() {
WriteBasicSetting(UISettings::values.callout_flags);
WriteBasicSetting(UISettings::values.show_console);
WriteBasicSetting(UISettings::values.pause_when_in_background);
+ WriteBasicSetting(UISettings::values.mute_when_in_background);
WriteBasicSetting(UISettings::values.hide_mouse);
}
diff --git a/src/citra_qt/configuration/configure_general.cpp b/src/citra_qt/configuration/configure_general.cpp
index bdcb640c9d..a402523bf0 100644
--- a/src/citra_qt/configuration/configure_general.cpp
+++ b/src/citra_qt/configuration/configure_general.cpp
@@ -74,6 +74,8 @@ void ConfigureGeneral::SetConfiguration() {
ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing.GetValue());
ui->toggle_background_pause->setChecked(
UISettings::values.pause_when_in_background.GetValue());
+ ui->toggle_background_mute->setChecked(
+ UISettings::values.mute_when_in_background.GetValue());
ui->toggle_hide_mouse->setChecked(UISettings::values.hide_mouse.GetValue());
ui->toggle_update_check->setChecked(
@@ -174,6 +176,7 @@ void ConfigureGeneral::ApplyConfiguration() {
if (Settings::IsConfiguringGlobal()) {
UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked();
UISettings::values.pause_when_in_background = ui->toggle_background_pause->isChecked();
+ UISettings::values.mute_when_in_background = ui->toggle_background_mute->isChecked();
UISettings::values.hide_mouse = ui->toggle_hide_mouse->isChecked();
UISettings::values.check_for_update_on_start = ui->toggle_update_check->isChecked();
diff --git a/src/citra_qt/configuration/configure_general.ui b/src/citra_qt/configuration/configure_general.ui
index 316edadb12..deb6c42828 100644
--- a/src/citra_qt/configuration/configure_general.ui
+++ b/src/citra_qt/configuration/configure_general.ui
@@ -36,6 +36,13 @@
+ -
+
+
+ Mute audio when in background
+
+
+
-
diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp
index 302ebc1f7d..b129a0e5f0 100644
--- a/src/citra_qt/main.cpp
+++ b/src/citra_qt/main.cpp
@@ -778,21 +778,33 @@ void GMainWindow::RestoreUIState() {
}
void GMainWindow::OnAppFocusStateChanged(Qt::ApplicationState state) {
- if (!UISettings::values.pause_when_in_background) {
- return;
- }
if (state != Qt::ApplicationHidden && state != Qt::ApplicationInactive &&
state != Qt::ApplicationActive) {
LOG_DEBUG(Frontend, "ApplicationState unusual flag: {} ", state);
}
- if (ui->action_Pause->isEnabled() &&
- (state & (Qt::ApplicationHidden | Qt::ApplicationInactive))) {
- auto_paused = true;
- OnPauseGame();
- } else if (emulation_running && !emu_thread->IsRunning() && auto_paused &&
- state == Qt::ApplicationActive) {
- auto_paused = false;
- OnStartGame();
+ if (!emulation_running) {
+ return;
+ }
+ if (UISettings::values.pause_when_in_background) {
+ if (emu_thread->IsRunning() &&
+ (state & (Qt::ApplicationHidden | Qt::ApplicationInactive))) {
+ auto_paused = true;
+ OnPauseGame();
+ } else if (!emu_thread->IsRunning() && auto_paused && state == Qt::ApplicationActive) {
+ auto_paused = false;
+ OnStartGame();
+ }
+ }
+ if (UISettings::values.mute_when_in_background) {
+ if (!Settings::values.audio_muted &&
+ (state & (Qt::ApplicationHidden | Qt::ApplicationInactive))) {
+ Settings::values.audio_muted = true;
+ auto_muted = true;
+ } else if (auto_muted && state == Qt::ApplicationActive) {
+ Settings::values.audio_muted = false;
+ auto_muted = false;
+ }
+ UpdateVolumeUI();
}
}
diff --git a/src/citra_qt/main.h b/src/citra_qt/main.h
index a89561ad2d..934b56d34a 100644
--- a/src/citra_qt/main.h
+++ b/src/citra_qt/main.h
@@ -325,6 +325,7 @@ private:
QString game_path;
bool auto_paused = false;
+ bool auto_muted = false;
QTimer mouse_hide_timer;
// Movie
diff --git a/src/citra_qt/uisettings.h b/src/citra_qt/uisettings.h
index a0e7559c04..8e671f49f2 100644
--- a/src/citra_qt/uisettings.h
+++ b/src/citra_qt/uisettings.h
@@ -80,6 +80,7 @@ struct Values {
Settings::Setting save_state_warning{true, "saveStateWarning"};
Settings::Setting first_start{true, "firstStart"};
Settings::Setting pause_when_in_background{false, "pauseWhenInBackground"};
+ Settings::Setting mute_when_in_background{false, "muteWhenInBackground"};
Settings::Setting hide_mouse{false, "hideInactiveMouse"};
bool updater_found;