Don't copy modifiers to prime events.

The modifiers go with the hotkey, not with the action.

Fixes https://gitlab.com/kicad/code/kicad/issues/11618
This commit is contained in:
Jeff Young 2022-05-16 10:22:55 +01:00
parent 1f088984ce
commit f2fc78f380
9 changed files with 37 additions and 42 deletions

View File

@ -350,9 +350,15 @@ void TOOL_MANAGER::CancelTool()
void TOOL_MANAGER::PrimeTool( const VECTOR2D& aPosition )
{
int modifiers = 0;
modifiers |= wxGetKeyState( WXK_SHIFT ) ? MD_SHIFT : 0;
modifiers |= wxGetKeyState( WXK_CONTROL ) ? MD_CTRL : 0;
modifiers |= wxGetKeyState( WXK_ALT ) ? MD_ALT : 0;
/*
* Don't include any modifiers. They're part of the hotkey, not part of the resulting
* click.
*
* modifiers |= wxGetKeyState( WXK_SHIFT ) ? MD_SHIFT : 0;
* modifiers |= wxGetKeyState( WXK_CONTROL ) ? MD_CTRL : 0;
* modifiers |= wxGetKeyState( WXK_ALT ) ? MD_ALT : 0;
*/
TOOL_EVENT evt( TC_MOUSE, TA_PRIME, BUT_LEFT | modifiers );
evt.SetMousePosition( aPosition );

View File

@ -187,7 +187,7 @@ int SCH_DRAWING_TOOLS::PlaceSymbol( const TOOL_EVENT& aEvent )
}
else if( !aEvent.IsReactivate() )
{
m_toolMgr->RunAction( EE_ACTIONS::cursorClick );
m_toolMgr->PrimeTool( aEvent.Position() );
}
// Main loop: keep receiving events
@ -430,7 +430,7 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
if( image )
m_toolMgr->RunAction( ACTIONS::refreshPreview );
else if( !aEvent.IsReactivate() )
m_toolMgr->RunAction( ACTIONS::cursorClick );
m_toolMgr->PrimeTool( aEvent.Position() );
// Main loop: keep receiving events
while( TOOL_EVENT* evt = Wait() )
@ -701,7 +701,7 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent )
// Prime the pump
if( aEvent.HasPosition() && type != SCH_SHEET_PIN_T )
m_toolMgr->RunAction( ACTIONS::cursorClick );
m_toolMgr->PrimeTool( aEvent.Position() );
else
m_toolMgr->RunAction( ACTIONS::refreshPreview );
@ -1106,16 +1106,12 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
// Set initial cursor
setCursor();
// Prime the pump if the tool isn't being re-activated
if( aEvent.HasPosition() )
{
m_toolMgr->PrimeTool( aEvent.Position() );
}
else if( common_settings->m_Input.immediate_actions && !aEvent.IsReactivate() && ( isText
|| isGlobalLabel
|| isHierLabel
|| isClassLabel
|| isNetLabel ) )
else if( common_settings->m_Input.immediate_actions && !aEvent.IsReactivate()
&& ( isText || isGlobalLabel || isHierLabel || isClassLabel || isNetLabel ) )
{
m_toolMgr->PrimeTool( { 0, 0 } );
ignorePrimePosition = true;
@ -1416,9 +1412,8 @@ int SCH_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
// Set initial cursor
setCursor();
// Prime the pump
if( aEvent.HasPosition() )
m_toolMgr->RunAction( ACTIONS::cursorClick );
m_toolMgr->PrimeTool( aEvent.Position() );
// Main loop: keep receiving events
while( TOOL_EVENT* evt = Wait() )
@ -1583,9 +1578,8 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
// Set initial cursor
setCursor();
// Prime the pump
if( aEvent.HasPosition() )
m_toolMgr->RunAction( ACTIONS::cursorClick );
m_toolMgr->PrimeTool( aEvent.Position() );
// Main loop: keep receiving events
while( TOOL_EVENT* evt = Wait() )

View File

@ -111,7 +111,6 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
// Set initial cursor
setCursor();
// Prime the pump
if( aEvent.HasPosition() )
{
m_toolMgr->PrimeTool( aEvent.Position() );
@ -336,9 +335,8 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
// Set initial cursor
setCursor();
// Prime the pump
if( aEvent.HasPosition() )
m_toolMgr->RunAction( ACTIONS::cursorClick );
m_toolMgr->PrimeTool( aEvent.Position() );
// Main loop: keep receiving events
while( TOOL_EVENT* evt = Wait() )

View File

@ -101,9 +101,8 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent )
// Set initial cursor
setCursor();
// Prime the pump
if( aEvent.HasPosition() || ( !aEvent.IsReactivate() && isText ) )
m_toolMgr->RunAction( ACTIONS::cursorClick );
m_toolMgr->PrimeTool( aEvent.Position() );
// Main loop: keep receiving events
while( TOOL_EVENT* evt = Wait() )
@ -248,9 +247,8 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
// Set initial cursor
setCursor();
// Prime the pump
if( aEvent.HasPosition() )
m_toolMgr->RunAction( ACTIONS::cursorClick );
m_toolMgr->PrimeTool( aEvent.Position() );
// Main loop: keep receiving events
while( TOOL_EVENT* evt = Wait() )

View File

@ -1382,9 +1382,8 @@ int ROUTER_TOOL::MainLoop( const TOOL_EVENT& aEvent )
m_router->SetMode( mode );
m_cancelled = false;
// Prime the pump
if( aEvent.HasPosition() )
m_toolMgr->PrimeTool( controls->GetCursorPosition( false ) );
m_toolMgr->PrimeTool( aEvent.Position() );
// Main loop: keep receiving events
while( TOOL_EVENT* evt = Wait() )

View File

@ -1032,7 +1032,7 @@ int BOARD_EDITOR_CONTROL::PlaceFootprint( const TOOL_EVENT& aEvent )
}
else if( !aEvent.IsReactivate() )
{
m_toolMgr->RunAction( PCB_ACTIONS::cursorClick );
m_toolMgr->PrimeTool( aEvent.Position() );
}
// Main loop: keep receiving events

View File

@ -577,9 +577,8 @@ int DRAWING_TOOL::InteractivePlaceWithPreview( const TOOL_EVENT& aEvent,
// Must be done after Activate() so that it gets set into the correct context
m_controls->ShowCursor( true );
// Prime the pump
if( aEvent.HasPosition() )
m_toolMgr->RunAction( ACTIONS::cursorClick );
m_toolMgr->PrimeTool( aEvent.Position() );
// Main loop: keep receiving events
wxPoint wxCursorPosition = wxPoint();

View File

@ -450,6 +450,7 @@ int DRAWING_TOOL::DrawCircle( const TOOL_EVENT& aEvent )
circle->SetShape( SHAPE_T::CIRCLE );
circle->SetFilled( false );
circle->SetFlags( IS_NEW );
startingPoint = NULLOPT;
}
@ -471,7 +472,7 @@ int DRAWING_TOOL::DrawArc( const TOOL_EVENT& aEvent )
PCB_SHAPE* arc = m_isFootprintEditor ? new FP_SHAPE( parentFootprint ) : new PCB_SHAPE;
BOARD_COMMIT commit( m_frame );
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ARC );
bool immediateMode = aEvent.HasPosition();
OPT<VECTOR2D> startingPoint = boost::make_optional<VECTOR2D>( false, { 0, 0 } );
arc->SetShape( SHAPE_T::ARC );
arc->SetFlags( IS_NEW );
@ -480,7 +481,10 @@ int DRAWING_TOOL::DrawArc( const TOOL_EVENT& aEvent )
m_frame->PushTool( tool );
Activate();
while( drawArc( tool, &arc, immediateMode ) )
if( aEvent.HasPosition() )
startingPoint = aEvent.Position();
while( drawArc( tool, &arc, startingPoint ) )
{
if( arc )
{
@ -496,7 +500,8 @@ int DRAWING_TOOL::DrawArc( const TOOL_EVENT& aEvent )
arc = m_isFootprintEditor ? new FP_SHAPE( parentFootprint ) : new PCB_SHAPE;
arc->SetShape( SHAPE_T::ARC );
arc->SetFlags( IS_NEW );
immediateMode = false;
startingPoint = NULLOPT;
}
return 0;
@ -554,9 +559,8 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
// Set initial cursor
setCursor();
// Prime the pump
if( !aEvent.IsReactivate() )
m_toolMgr->RunAction( ACTIONS::cursorClick );
m_toolMgr->PrimeTool( aEvent.Position() );
// Main loop: keep receiving events
while( TOOL_EVENT* evt = Wait() )
@ -826,7 +830,6 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
// Set initial cursor
setCursor();
// Prime the pump
m_toolMgr->RunAction( ACTIONS::refreshPreview );
if( aEvent.HasPosition() )
@ -1553,11 +1556,10 @@ bool DRAWING_TOOL::drawSegment( const std::string& aTool, PCB_SHAPE** aGraphic,
// Set initial cursor
setCursor();
// Prime the pump
m_toolMgr->RunAction( ACTIONS::refreshPreview );
if( aStartingPoint )
m_toolMgr->RunAction( ACTIONS::cursorClick );
m_toolMgr->PrimeTool( aStartingPoint.get() );
// Main loop: keep receiving events
while( TOOL_EVENT* evt = Wait() )
@ -1831,7 +1833,8 @@ static void updateArcFromConstructionMgr( const KIGFX::PREVIEW::ARC_GEOM_MANAGER
}
bool DRAWING_TOOL::drawArc( const std::string& aTool, PCB_SHAPE** aGraphic, bool aImmediateMode )
bool DRAWING_TOOL::drawArc( const std::string& aTool, PCB_SHAPE** aGraphic,
OPT<VECTOR2D> aStartingPoint )
{
PCB_SHAPE*& graphic = *aGraphic;
@ -1877,11 +1880,10 @@ bool DRAWING_TOOL::drawArc( const std::string& aTool, PCB_SHAPE** aGraphic, bool
bool firstPoint = false;
bool cancelled = false;
// Prime the pump
m_toolMgr->RunAction( ACTIONS::refreshPreview );
if( aImmediateMode )
m_toolMgr->RunAction( ACTIONS::cursorClick );
if( aStartingPoint )
m_toolMgr->PrimeTool(aStartingPoint.get() );
// Main loop: keep receiving events
while( TOOL_EVENT* evt = Wait() )
@ -2203,7 +2205,6 @@ int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent )
// Set initial cursor
setCursor();
// Prime the pump
if( aEvent.HasPosition() )
m_toolMgr->PrimeTool( aEvent.Position() );

View File

@ -231,7 +231,7 @@ private:
* @return False if the tool was canceled before the origin was set or origin and end are
* the same point.
*/
bool drawArc( const std::string& aTool, PCB_SHAPE** aGraphic, bool aImmediateMode );
bool drawArc( const std::string& aTool, PCB_SHAPE** aGraphic, OPT<VECTOR2D> aStartingPoint );
/**
* Draw a polygon, that is added as a zone or a keepout area.