Be more careful with forced cursor positions.

Fixes https://gitlab.com/kicad/code/kicad/issues/9977
This commit is contained in:
Jeff Young 2022-04-10 23:14:30 +01:00
parent 32a2490677
commit 29eb5931c2
6 changed files with 25 additions and 1 deletions

View File

@ -548,6 +548,7 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
Activate(); Activate();
// Must be done after Activate() so that it gets set into the correct context // Must be done after Activate() so that it gets set into the correct context
m_controls->ShowCursor( true ); m_controls->ShowCursor( true );
m_controls->ForceCursorPosition( false );
// do not capture or auto-pan until we start placing some text // do not capture or auto-pan until we start placing some text
// Set initial cursor // Set initial cursor
setCursor(); setCursor();
@ -742,6 +743,7 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
m_controls->SetAutoPan( false ); m_controls->SetAutoPan( false );
m_controls->CaptureCursor( false ); m_controls->CaptureCursor( false );
m_controls->ForceCursorPosition( false );
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW ); m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
if( selection().Empty() ) if( selection().Empty() )
@ -795,6 +797,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
{ {
m_controls->SetAutoPan( false ); m_controls->SetAutoPan( false );
m_controls->CaptureCursor( false ); m_controls->CaptureCursor( false );
m_controls->ForceCursorPosition( false );
preview.Clear(); preview.Clear();
m_view->Update( &preview ); m_view->Update( &preview );
@ -818,6 +821,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
Activate(); Activate();
// Must be done after Activate() so that it gets set into the correct context // Must be done after Activate() so that it gets set into the correct context
m_controls->ShowCursor( true ); m_controls->ShowCursor( true );
m_controls->ForceCursorPosition( false );
// Set initial cursor // Set initial cursor
setCursor(); setCursor();
@ -1362,6 +1366,7 @@ int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent )
m_view->Remove( &preview ); m_view->Remove( &preview );
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW ); m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
m_controls->ForceCursorPosition( false );
m_frame->PopTool( tool ); m_frame->PopTool( tool );
@ -1400,6 +1405,7 @@ int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent )
m_controls->ShowCursor( true ); m_controls->ShowCursor( true );
m_controls->SetAutoPan( true ); m_controls->SetAutoPan( true );
m_controls->CaptureCursor( false ); m_controls->CaptureCursor( false );
m_controls->ForceCursorPosition( false );
// Set initial cursor // Set initial cursor
setCursor(); setCursor();
@ -1446,6 +1452,7 @@ int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent )
} }
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW ); m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
m_controls->ForceCursorPosition( false );
return 0; return 0;
} }
@ -1541,6 +1548,7 @@ bool DRAWING_TOOL::drawSegment( const std::string& aTool, PCB_SHAPE** aGraphic,
}; };
m_controls->ShowCursor( true ); m_controls->ShowCursor( true );
m_controls->ForceCursorPosition( false );
// Set initial cursor // Set initial cursor
setCursor(); setCursor();
@ -1861,6 +1869,7 @@ bool DRAWING_TOOL::drawArc( const std::string& aTool, PCB_SHAPE** aGraphic, bool
}; };
m_controls->ShowCursor( true ); m_controls->ShowCursor( true );
m_controls->ForceCursorPosition( false );
// Set initial cursor // Set initial cursor
setCursor(); setCursor();
@ -2189,6 +2198,7 @@ int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent )
Activate(); Activate();
// Must be done after Activate() so that it gets set into the correct context // Must be done after Activate() so that it gets set into the correct context
m_controls->ShowCursor( true ); m_controls->ShowCursor( true );
m_controls->ForceCursorPosition( false );
// Set initial cursor // Set initial cursor
setCursor(); setCursor();

View File

@ -752,6 +752,7 @@ int EDIT_TOOL::doMoveSelection( TOOL_EVENT aEvent, bool aPickReference )
// Must be done after Activate() so that it gets set into the correct context // Must be done after Activate() so that it gets set into the correct context
controls->ShowCursor( true ); controls->ShowCursor( true );
controls->SetAutoPan( true ); controls->SetAutoPan( true );
controls->ForceCursorPosition( false );
if( aPickReference && !pickReferencePoint( _( "Select reference point for move..." ), "", "", if( aPickReference && !pickReferencePoint( _( "Select reference point for move..." ), "", "",
pickedReferencePoint ) ) pickedReferencePoint ) )

View File

@ -328,6 +328,7 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
Activate(); Activate();
// Must be done after Activate() so that it gets set into the correct context // Must be done after Activate() so that it gets set into the correct context
getViewControls()->ShowCursor( true ); getViewControls()->ShowCursor( true );
getViewControls()->ForceCursorPosition( false );
// Set initial cursor // Set initial cursor
setCursor(); setCursor();
@ -478,6 +479,7 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
statusPopup.Hide(); statusPopup.Hide();
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW ); frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
getViewControls()->ForceCursorPosition( false );
return 0; return 0;
} }

View File

@ -123,7 +123,9 @@ int PCB_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
break; break;
} }
else else
{
setControls(); setControls();
}
} }
else if( evt->IsMotion() ) else if( evt->IsMotion() )
@ -152,7 +154,9 @@ int PCB_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
} }
else else
{
evt->SetPassEvent(); evt->SetPassEvent();
}
} }
if( m_finalizeHandler ) if( m_finalizeHandler )

View File

@ -52,6 +52,7 @@ void PCB_TOOL_BASE::doInteractiveItemPlacement( const std::string& aTool,
Activate(); Activate();
// Must be done after Activate() so that it gets set into the correct context // Must be done after Activate() so that it gets set into the correct context
controls()->ShowCursor( true ); controls()->ShowCursor( true );
controls()->ForceCursorPosition( false );
// do not capture or auto-pan until we start placing an item // do not capture or auto-pan until we start placing an item
PCB_GRID_HELPER grid( m_toolMgr, frame()->GetMagneticItemsSettings() ); PCB_GRID_HELPER grid( m_toolMgr, frame()->GetMagneticItemsSettings() );
@ -120,6 +121,7 @@ void PCB_TOOL_BASE::doInteractiveItemPlacement( const std::string& aTool,
controls()->SetAutoPan( false ); controls()->SetAutoPan( false );
controls()->CaptureCursor( false ); controls()->CaptureCursor( false );
controls()->ShowCursor( true ); controls()->ShowCursor( true );
controls()->ForceCursorPosition( false );
}; };
if( evt->IsCancelInteractive() ) if( evt->IsCancelInteractive() )
@ -266,6 +268,7 @@ void PCB_TOOL_BASE::doInteractiveItemPlacement( const std::string& aTool,
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW ); frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
controls()->SetAutoPan( false ); controls()->SetAutoPan( false );
controls()->CaptureCursor( false ); controls()->CaptureCursor( false );
controls()->ForceCursorPosition( false );
} }

View File

@ -219,6 +219,7 @@ int PCB_VIEWER_TOOLS::MeasureTool( const TOOL_EVENT& aEvent )
view.SetVisible( &ruler, false ); view.SetVisible( &ruler, false );
controls.SetAutoPan( false ); controls.SetAutoPan( false );
controls.CaptureCursor( false ); controls.CaptureCursor( false );
controls.ForceCursorPosition( false );
originSet = false; originSet = false;
}; };
@ -227,6 +228,8 @@ int PCB_VIEWER_TOOLS::MeasureTool( const TOOL_EVENT& aEvent )
controls.ShowCursor( true ); controls.ShowCursor( true );
controls.SetAutoPan( false ); controls.SetAutoPan( false );
controls.CaptureCursor( false ); controls.CaptureCursor( false );
controls.ForceCursorPosition( false );
// Set initial cursor // Set initial cursor
setCursor(); setCursor();
@ -236,7 +239,7 @@ int PCB_VIEWER_TOOLS::MeasureTool( const TOOL_EVENT& aEvent )
grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
grid.SetUseGrid( view.GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() ); grid.SetUseGrid( view.GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
const VECTOR2I cursorPos = grid.BestSnapAnchor( controls.GetMousePosition(), nullptr ); const VECTOR2I cursorPos = grid.BestSnapAnchor( controls.GetMousePosition(), nullptr );
controls.ForceCursorPosition(true, cursorPos ); controls.ForceCursorPosition( true, cursorPos );
if( evt->IsCancelInteractive() ) if( evt->IsCancelInteractive() )
{ {
@ -339,6 +342,7 @@ int PCB_VIEWER_TOOLS::MeasureTool( const TOOL_EVENT& aEvent )
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW ); frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
controls.SetAutoPan( false ); controls.SetAutoPan( false );
controls.CaptureCursor( false ); controls.CaptureCursor( false );
controls.ForceCursorPosition( false );
return 0; return 0;
} }