Skip to content

Commit 53c043c

Browse files
committed
Option to enable/disable pause on focus lost
1 parent 30b7627 commit 53c043c

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

platforms/shared/desktop/application.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -573,14 +573,17 @@ static void sdl_events_app(const SDL_Event* event)
573573
{
574574
case SDL_WINDOWEVENT_FOCUS_GAINED:
575575
{
576-
if (!paused_when_focus_lost)
576+
if (config_emulator.pause_when_inactive && !paused_when_focus_lost)
577577
emu_resume();
578578
break;
579579
}
580580
case SDL_WINDOWEVENT_FOCUS_LOST:
581581
{
582-
paused_when_focus_lost = emu_is_paused();
583-
emu_pause();
582+
if (config_emulator.pause_when_inactive)
583+
{
584+
paused_when_focus_lost = emu_is_paused();
585+
emu_pause();
586+
}
584587
break;
585588
}
586589
}

platforms/shared/desktop/config.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ void config_read(void)
202202
config_emulator.ffwd_speed = read_int("Emulator", "FFWD", 1);
203203
config_emulator.save_slot = read_int("Emulator", "SaveSlot", 0);
204204
config_emulator.start_paused = read_bool("Emulator", "StartPaused", false);
205+
config_emulator.pause_when_inactive = read_bool("Emulator", "PauseWhenInactive", true);
205206
config_emulator.savefiles_dir_option = read_int("Emulator", "SaveFilesDirOption", 0);
206207
config_emulator.savefiles_path = read_string("Emulator", "SaveFilesPath");
207208
config_emulator.savestates_dir_option = read_int("Emulator", "SaveStatesDirOption", 0);
@@ -422,6 +423,7 @@ void config_write(void)
422423
write_int("Emulator", "FFWD", config_emulator.ffwd_speed);
423424
write_int("Emulator", "SaveSlot", config_emulator.save_slot);
424425
write_bool("Emulator", "StartPaused", config_emulator.start_paused);
426+
write_bool("Emulator", "PauseWhenInactive", config_emulator.pause_when_inactive);
425427
write_int("Emulator", "SaveFilesDirOption", config_emulator.savefiles_dir_option);
426428
write_string("Emulator", "SaveFilesPath", config_emulator.savefiles_path);
427429
write_int("Emulator", "SaveStatesDirOption", config_emulator.savestates_dir_option);

platforms/shared/desktop/config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ struct config_Emulator
4242
bool paused = false;
4343
int save_slot = 0;
4444
bool start_paused = false;
45+
bool pause_when_inactive = true;
4546
bool ffwd = false;
4647
int ffwd_speed = 1;
4748
bool show_info = false;

platforms/shared/desktop/gui_menus.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ static void menu_emulator(void)
498498
ImGui::Separator();
499499

500500
ImGui::MenuItem("Start Paused", "", &config_emulator.start_paused);
501+
ImGui::MenuItem("Pause When Inactive", "", &config_emulator.pause_when_inactive);
501502

502503
ImGui::EndMenu();
503504
}

0 commit comments

Comments
 (0)