From 8eaf9915c1b19202f763fd7e004ea20bc9ccb624 Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Wed, 4 Nov 2020 07:21:05 -0500 Subject: [PATCH] Check if the window is foreground before causing a focus war Fix #6250 --- common/tool/tool_dispatcher.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/common/tool/tool_dispatcher.cpp b/common/tool/tool_dispatcher.cpp index 8165b1e593..1aa1240ae5 100644 --- a/common/tool/tool_dispatcher.cpp +++ b/common/tool/tool_dispatcher.cpp @@ -432,8 +432,16 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent ) { wxWindow* window = dynamic_cast( 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 ) +#endif + { window->SetFocus(); + } } // Mouse handling