From: <sv...@op...> - 2024-06-28 22:28:03
|
Author: sagamusix Date: Sat Jun 29 00:27:51 2024 New Revision: 21098 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=21098 Log: Merged revision(s) 21097 from trunk/OpenMPT: [Fix] Properly restore keyboard focus in the upper half of the MDI views after OpenMPT regains focus (https://bugs.openmpt.org/view.php?id=1795). ........ Modified: branches/OpenMPT-1.31/ (props changed) branches/OpenMPT-1.31/mptrack/Globals.cpp branches/OpenMPT-1.31/mptrack/Globals.h Modified: branches/OpenMPT-1.31/mptrack/Globals.cpp ============================================================================== --- branches/OpenMPT-1.31/mptrack/Globals.cpp Sat Jun 29 00:27:03 2024 (r21097) +++ branches/OpenMPT-1.31/mptrack/Globals.cpp Sat Jun 29 00:27:51 2024 (r21098) @@ -1,8 +1,9 @@ /* - * globals.cpp + * Globals.cpp * ----------- - * Purpose: Implementation of various views of the tracker interface. - * Notes : (currently none) + * Purpose: Implementation of the base classes for the upper and lower half of the MDI child windows. + * Notes : CModControlDlg = Upper half (Ctrl_*.cpp/h), which is contained inside a CModControlView together with the tab switcher (CModTabCtrl). + * CModScrollView = Lower half (View_*.cpp/h). * Authors: OpenMPT Devs * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. */ @@ -192,10 +193,12 @@ //{{AFX_MSG_MAP(CModControlView) ON_WM_SIZE() ON_WM_DESTROY() + ON_WM_SETFOCUS() ON_NOTIFY(TCN_SELCHANGE, IDC_TABCTRL1, &CModControlView::OnTabSelchange) ON_MESSAGE(WM_MOD_ACTIVATEVIEW, &CModControlView::OnActivateModView) ON_MESSAGE(WM_MOD_CTRLMSG, &CModControlView::OnModCtrlMsg) ON_MESSAGE(WM_MOD_GETTOOLTIPTEXT, &CModControlView::OnGetToolTipText) + ON_MESSAGE(WM_MOD_MDIDEACTIVATE, &CModControlView::OnSaveFocusItem) ON_COMMAND(ID_EDIT_CUT, &CModControlView::OnEditCut) ON_COMMAND(ID_EDIT_COPY, &CModControlView::OnEditCopy) ON_COMMAND(ID_EDIT_PASTE, &CModControlView::OnEditPaste) @@ -227,6 +230,22 @@ } +LRESULT CModControlView::OnSaveFocusItem(WPARAM, LPARAM) +{ + // Ugly workaround for focus issue in upper view (https://bugs.openmpt.org/view.php?id=1795) + m_oldWnd = ::GetFocus(); + return 0; +} + + +void CModControlView::OnSetFocus(CWnd* pOldWnd) +{ + if(m_oldWnd && ::IsChild(m_hWnd, m_oldWnd)) + ::SetFocus(m_oldWnd); + CView::OnSetFocus(pOldWnd); +} + + void CModControlView::OnSize(UINT nType, int cx, int cy) { CView::OnSize(nType, cx, cy); Modified: branches/OpenMPT-1.31/mptrack/Globals.h ============================================================================== --- branches/OpenMPT-1.31/mptrack/Globals.h Sat Jun 29 00:27:03 2024 (r21097) +++ branches/OpenMPT-1.31/mptrack/Globals.h Sat Jun 29 00:27:51 2024 (r21098) @@ -1,7 +1,7 @@ /* * Globals.h * --------- - * Purpose: Implementation of various views of the tracker interface. + * Purpose: Implementation of the base classes for the upper and lower half of the MDI child windows. * Notes : (currently none) * Authors: OpenMPT Devs * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. @@ -119,6 +119,7 @@ Page m_nActiveDlg = Page::Unknown; int m_nInstrumentChanged = -1; HWND m_hWndView = nullptr, m_hWndMDI = nullptr; + HWND m_oldWnd = nullptr; protected: // create from serialization only CModControlView() = default; @@ -153,6 +154,8 @@ protected: //{{AFX_MSG(CModControlView) + afx_msg LRESULT OnSaveFocusItem(WPARAM, LPARAM); + afx_msg void OnSetFocus(CWnd *pOldWnd); afx_msg void OnSize(UINT nType, int cx, int cy); afx_msg void OnDestroy(); afx_msg void OnTabSelchange(NMHDR* pNMHDR, LRESULT* pResult); |