From 49655ae742e15167c22d8a34022dcdd58b9743b8 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 6 May 2023 11:27:29 +0100 Subject: [PATCH] Defense in depth for "mouse stuck in canvas". Fixes https://gitlab.com/kicad/code/kicad/issues/12653 --- eeschema/tools/ee_selection_tool.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index fc7f9729b4..b53f687d65 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -354,10 +354,21 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) if( evt->IsMouseDown( BUT_LEFT ) ) { - // Avoid triggering when running under other tools - // Distinguish point editor from selection modification by checking modifiers - if( m_frame->ToolStackIsEmpty() && m_toolMgr->GetTool() - && ( !m_toolMgr->GetTool()->HasPoint() || hasModifier() ) ) + if( !m_frame->ToolStackIsEmpty() ) + { + // Avoid triggering when running under other tools + } + else if( m_toolMgr->GetTool() + && m_toolMgr->GetTool()->HasPoint() ) + { + // Distinguish point editor from selection modification by checking modifiers + if( hasModifier() ) + { + m_originalCursor = m_toolMgr->GetMousePosition(); + m_disambiguateTimer.StartOnce( 500 ); + } + } + else { m_originalCursor = m_toolMgr->GetMousePosition(); m_disambiguateTimer.StartOnce( 500 ); @@ -571,6 +582,11 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) { m_disambiguateTimer.Stop(); + // We didn't set these, but we have reports that they leak out of some other tools, + // so we clear them here. + getViewControls()->SetAutoPan( false ); + getViewControls()->CaptureCursor( false ); + if( SCH_EDIT_FRAME* schframe = dynamic_cast( m_frame ) ) schframe->FocusOnItem( nullptr );