Skip to content

Commit

Permalink
[Fix] Don't send keyboard shortcut messages intended for MDI views to…
Browse files Browse the repository at this point in the history
… the view if another dialog currently has focus.

git-svn-id: https://source.openmpt.org/svn/openmpt/trunk/OpenMPT@22315 56274372-70c3-4bfc-bfc3-4c3a0b034d27
  • Loading branch information
sagamusix committed Nov 26, 2024
1 parent f57280e commit c94cac0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions mptrack/MainFrm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2720,6 +2720,7 @@ LRESULT CMainFrame::OnCustomKeyMsg(WPARAM wParam, LPARAM lParam)

default:
// If handled neither by MainFrame nor by ModDoc, send it to the active view
// Note: MDIGetActive() will return a valid view even if we are currently in a modal dialog!
CMDIChildWnd *pMDIActive = MDIGetActive();
CWnd *wnd = nullptr;
if(pMDIActive)
Expand All @@ -2733,12 +2734,12 @@ LRESULT CMainFrame::OnCustomKeyMsg(WPARAM wParam, LPARAM lParam)
}

// Backup solution for order navigation if the currently active view is not a pattern view, but a module is playing
// Note: This should also work if the currently active window is not a CMDIChildWnd, hence it happens before the GetActiveWindow() check.
if(mpt::is_in_range(cmd, kcPrevNextOrderStart, kcPrevNextOrderEnd)
&& m_pSndFile && m_pSndFile->GetpModDoc()
&& wnd != nullptr
&& strcmp(wnd->GetRuntimeClass()->m_lpszClassName, "CViewPattern"))
{
ResetNotificationBuffer();
CriticalSection cs;

ORDERINDEX order = m_pSndFile->m_PlayState.m_nCurrentOrder;
Expand All @@ -2747,6 +2748,10 @@ LRESULT CMainFrame::OnCustomKeyMsg(WPARAM wParam, LPARAM lParam)
else
order = m_pSndFile->Order().GetNextOrderIgnoringSkips(order);

if(order == m_pSndFile->m_PlayState.m_nCurrentOrder)
return wParam;

ResetNotificationBuffer();
switch(wParam)
{
case kcPrevOrder:
Expand All @@ -2769,9 +2774,10 @@ LRESULT CMainFrame::OnCustomKeyMsg(WPARAM wParam, LPARAM lParam)
m_pSndFile->m_PlayState.m_nSeqOverride = order;
break;
}
return wParam;
}

if(wnd)
if(wnd && GetActiveWindow() == this)
return wnd->SendMessage(WM_MOD_KEYCOMMAND, wParam, lParam);
return kcNull;
}
Expand Down

0 comments on commit c94cac0

Please sign in to comment.