Check if the window is foreground before causing a focus war

Fix #6250
This commit is contained in:
Marek Roszko 2020-11-04 07:21:05 -05:00
parent 2ffa88d076
commit 8eaf9915c1
1 changed files with 8 additions and 0 deletions

View File

@ -432,8 +432,16 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
{ {
wxWindow* window = dynamic_cast<wxWindow*>( m_toolMgr->GetToolHolder() ); wxWindow* window = dynamic_cast<wxWindow*>( m_toolMgr->GetToolHolder() );
#if defined( _WIN32 )
// Mouse events may trigger regardless of window status (windows feature)
// However we need to avoid focus fighting (especially modals)
if( window && window->GetHWND() == GetForegroundWindow() )
#else
if( window ) if( window )
#endif
{
window->SetFocus(); window->SetFocus();
}
} }
// Mouse handling // Mouse handling