← Back to team overview

kicad-developers team mailing list archive

[PATCH] Prevent cursor jumping in pcbnew

 

Hi all,


I noticed an irritating behaviour in pcbnew with the OpenGL GAL.

If a dialog is opened while routing a trace (e.g. by hotkey P or Q)
and the mouse is moved either to operate the dialog or otherwise then
the mouse (pointer) position will be different after closing the dialog.

At the next slight movement of the mouse the cursor (the white cross)
will suddenly jump to the mouse position.

The patch below saves the cursor position before either the
"Differential Pair Dimensions" or "Track width and via size" dialogs are
shown and moves the pointer to it after the dialog is closed.

There may be more places needing to do this, or it may be better done
"higher up" in the event handling?


Have fun,

MGri


diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp
index c76f0051c..b08cebd4b 100644
--- a/pcbnew/router/router_tool.cpp
+++ b/pcbnew/router/router_tool.cpp
@@ -778,6 +778,8 @@ int ROUTER_TOOL::DpDimensionsDialog( const TOOL_EVENT& aEvent )
 {
     Activate();
 
+    VECTOR2D cursorPos = getViewControls()->GetCursorPosition();
+
     PNS::SIZES_SETTINGS sizes = m_router->Sizes();
     DIALOG_PNS_DIFF_PAIR_DIMENSIONS settingsDlg( frame(), sizes );
 
@@ -787,6 +789,8 @@ int ROUTER_TOOL::DpDimensionsDialog( const TOOL_EVENT& aEvent )
         m_savedSizes = sizes;
     }
 
+    getViewControls()->SetCursorPosition( cursorPos, false );
+
     return 0;
 }
 
@@ -1066,6 +1070,8 @@ int ROUTER_TOOL::InlineDrag( const TOOL_EVENT& aEvent )
 
 int ROUTER_TOOL::CustomTrackWidthDialog( const TOOL_EVENT& aEvent )
 {
+    VECTOR2D cursorPos = getViewControls()->GetCursorPosition();
+
     BOARD_DESIGN_SETTINGS& bds = board()->GetDesignSettings();
     DIALOG_TRACK_VIA_SIZE sizeDlg( frame(), bds );
 
@@ -1075,6 +1081,8 @@ int ROUTER_TOOL::CustomTrackWidthDialog( const TOOL_EVENT& aEvent )
         m_toolMgr->RunAction( PCB_ACTIONS::trackViaSizeChanged );
     }
 
+    getViewControls()->SetCursorPosition( cursorPos, false );
+
     return 0;
 }