From dec5d801807c499beb4a88cd2f26f62c7b5f9a2c Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sat, 13 Apr 2019 11:22:48 -0400 Subject: [PATCH] Veto mouse warping from DRC dialog Fixes: lp:1824630 * https://bugs.launchpad.net/kicad/+bug/1824630 --- common/tool/tool_manager.cpp | 4 +++- include/tool/tool_manager.h | 5 +++++ pcbnew/dialogs/dialog_drc.cpp | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/common/tool/tool_manager.cpp b/common/tool/tool_manager.cpp index ffd43c208e..e27d0b1ea6 100644 --- a/common/tool/tool_manager.cpp +++ b/common/tool/tool_manager.cpp @@ -689,7 +689,6 @@ void TOOL_MANAGER::dispatchContextMenu( const TOOL_EVENT& aEvent ) } m_viewControls->ForceCursorPosition( true, m_menuCursor ); - m_warpMouseAfterContextMenu = true; // Display a copy of menu std::unique_ptr menu( m->Clone() ); @@ -715,6 +714,9 @@ void TOOL_MANAGER::dispatchContextMenu( const TOOL_EVENT& aEvent ) dispatchInternal( evt ); } + // Restore setting in case it was vetoed + m_warpMouseAfterContextMenu = true; + // Notify the tools that menu has been closed TOOL_EVENT evt( TC_COMMAND, TA_CONTEXT_MENU_CLOSED ); evt.SetParameter( m ); diff --git a/include/tool/tool_manager.h b/include/tool/tool_manager.h index a73a0ce214..3c529dbd00 100644 --- a/include/tool/tool_manager.h +++ b/include/tool/tool_manager.h @@ -372,6 +372,11 @@ public: */ const KIGFX::VC_SETTINGS& GetCurrentToolVC() const; + /** + * Disables mouse warping after the current context menu is closed. + * Must be called before invoking each context menu. + * It's a good idea to call this from non-modal dialogs (e.g. DRC window). + */ void VetoContextMenuMouseWarp() { m_warpMouseAfterContextMenu = false; diff --git a/pcbnew/dialogs/dialog_drc.cpp b/pcbnew/dialogs/dialog_drc.cpp index 9f5afd07dc..f25439ab33 100644 --- a/pcbnew/dialogs/dialog_drc.cpp +++ b/pcbnew/dialogs/dialog_drc.cpp @@ -436,6 +436,7 @@ void DIALOG_DRC_CONTROL::doSelectionMenu( const DRC_ITEM* aItem ) } WINDOW_THAWER thawer( m_brdEditor ); + m_brdEditor->GetToolManager()->VetoContextMenuMouseWarp(); m_brdEditor->GetToolManager()->RunAction( PCB_ACTIONS::selectionMenu, true, &items ); // If we got an item, focus on it