From 68e7d98b8503cbbe903c1b82215ce49ee03ef3b6 Mon Sep 17 00:00:00 2001 From: Rafael Kitover Date: Wed, 1 Oct 2025 17:05:39 +0000 Subject: [PATCH] Fix pause when inactive for new wxWidgets Handle the Iconize event to pause when "pause when inactive" is enabled, to work around a change in recent versions of wxWidgets that ignore this unfocus event. Fix #1494. Signed-off-by: Rafael Kitover --- src/wx/wxvbam.cpp | 12 ++++++++++++ src/wx/wxvbam.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/src/wx/wxvbam.cpp b/src/wx/wxvbam.cpp index db67b788..8a720240 100644 --- a/src/wx/wxvbam.cpp +++ b/src/wx/wxvbam.cpp @@ -985,6 +985,7 @@ EVT_MOVE(MainFrame::OnMove) EVT_MOVE_START(MainFrame::OnMoveStart) EVT_MOVE_END(MainFrame::OnMoveEnd) EVT_SIZE(MainFrame::OnSize) +EVT_ICONIZE(MainFrame::OnIconize) #if defined(__WXMSW__) @@ -1088,6 +1089,17 @@ void MainFrame::OnSize(wxSizeEvent& event) OPTION(kGeomFullScreen) = IsFullScreen(); } +void MainFrame::OnIconize(wxIconizeEvent& event) +{ + if (!init_complete_) { + return; + } + + if (OPTION(kPrefPauseWhenInactive)) { + panel->Pause(); + } +} + wxString MainFrame::GetGamePath(wxString path) { wxString game_path = path; diff --git a/src/wx/wxvbam.h b/src/wx/wxvbam.h index 5cba7cbb..159cdde0 100644 --- a/src/wx/wxvbam.h +++ b/src/wx/wxvbam.h @@ -360,6 +360,8 @@ private: void OnMoveStart(wxMoveEvent& event); void OnMoveEnd(wxMoveEvent& event); void OnSize(wxSizeEvent& event); + void OnIconize(wxIconizeEvent& event); + // Load a named wxDialog from the XRC file wxDialog* LoadXRCDialog(const char* name);