From 5f9dfeea8690f44f84ebab9656d188040fe366dc Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 24 Apr 2021 23:53:16 -0700 Subject: [PATCH] Windows: Reduce focus juggling on game start. Previously, we would activate the debugger (if enabled), and then reactivate the main window. This meant if you switched to something, PPSSPP would demand focus once the game loaded. --- Windows/Debugger/Debugger_Disasm.cpp | 4 ++-- Windows/Debugger/Debugger_Disasm.h | 2 +- Windows/MainWindow.cpp | 4 +--- Windows/W32Util/DialogManager.cpp | 11 ++++++++--- Windows/W32Util/DialogManager.h | 2 +- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Windows/Debugger/Debugger_Disasm.cpp b/Windows/Debugger/Debugger_Disasm.cpp index 3f0bf77907..54af241898 100644 --- a/Windows/Debugger/Debugger_Disasm.cpp +++ b/Windows/Debugger/Debugger_Disasm.cpp @@ -848,14 +848,14 @@ void CDisasm::SetDebugMode(bool _bDebug, bool switchPC) } } -void CDisasm::Show(bool bShow) { +void CDisasm::Show(bool bShow, bool includeToTop) { if (deferredSymbolFill_ && bShow) { if (g_symbolMap) { g_symbolMap->FillSymbolListBox(GetDlgItem(m_hDlg, IDC_FUNCTIONLIST), ST_FUNCTION); deferredSymbolFill_ = false; } } - Dialog::Show(bShow); + Dialog::Show(bShow, includeToTop); } void CDisasm::NotifyMapLoaded() { diff --git a/Windows/Debugger/Debugger_Disasm.h b/Windows/Debugger/Debugger_Disasm.h index c95ba39bd7..e77a9bb2ca 100644 --- a/Windows/Debugger/Debugger_Disasm.h +++ b/Windows/Debugger/Debugger_Disasm.h @@ -49,7 +49,7 @@ public: CDisasm(HINSTANCE _hInstance, HWND _hParent, DebugInterface *cpu); ~CDisasm(); - void Show(bool bShow) override; + void Show(bool bShow, bool includeToTop = true) override; void Update() override { UpdateDialog(true); diff --git a/Windows/MainWindow.cpp b/Windows/MainWindow.cpp index d01074b92b..26c64a1c33 100644 --- a/Windows/MainWindow.cpp +++ b/Windows/MainWindow.cpp @@ -540,7 +540,7 @@ namespace MainWindow void CreateDebugWindows() { disasmWindow = new CDisasm(MainWindow::GetHInstance(), MainWindow::GetHWND(), currentDebugMIPS); DialogManager::AddDlg(disasmWindow); - disasmWindow->Show(g_Config.bShowDebuggerOnLoad); + disasmWindow->Show(g_Config.bShowDebuggerOnLoad, false); #if PPSSPP_API(ANY_GL) geDebuggerWindow = new CGEDebugger(MainWindow::GetHInstance(), MainWindow::GetHWND()); @@ -935,8 +935,6 @@ namespace MainWindow if (disasmWindow) disasmWindow->UpdateDialog(); - - SetForegroundWindow(hwndMain); break; case WM_USER_SAVESTATE_FINISH: diff --git a/Windows/W32Util/DialogManager.cpp b/Windows/W32Util/DialogManager.cpp index fdb89ac600..df131d9db4 100644 --- a/Windows/W32Util/DialogManager.cpp +++ b/Windows/W32Util/DialogManager.cpp @@ -30,11 +30,16 @@ void Dialog::Destroy() DestroyWindow(m_hDlg); } -void Dialog::Show(bool _bShow) +void Dialog::Show(bool _bShow, bool includeToTop) { - m_bShowState = _bShow ? SW_NORMAL : SW_HIDE; + if (_bShow && includeToTop) + m_bShowState = SW_SHOWNORMAL; + else if (_bShow) + m_bShowState = SW_SHOWNOACTIVATE; + else + m_bShowState = SW_HIDE; ShowWindow(m_hDlg, m_bShowState); - if (_bShow) + if (_bShow && includeToTop) BringWindowToTop(m_hDlg); } diff --git a/Windows/W32Util/DialogManager.h b/Windows/W32Util/DialogManager.h index f1093deb14..fc943b3ddd 100644 --- a/Windows/W32Util/DialogManager.h +++ b/Windows/W32Util/DialogManager.h @@ -8,7 +8,7 @@ public: Dialog(LPCSTR res, HINSTANCE _hInstance, HWND _hParent); virtual ~Dialog(); - virtual void Show(bool _bShow); + virtual void Show(bool _bShow, bool includeToTop = true); virtual void Update() {} HWND GetDlgHandle() {