Allow dialogs to veto mouse-warping when called from context menu.
Fixes: lp:1745731
* https://bugs.launchpad.net/kicad/+bug/1745731
(cherry picked from commit adf3637476
)
This commit is contained in:
parent
c36c80a077
commit
90787e84bf
|
@ -26,6 +26,7 @@
|
||||||
#include <kiway_player.h>
|
#include <kiway_player.h>
|
||||||
#include <wx/evtloop.h>
|
#include <wx/evtloop.h>
|
||||||
#include <pgm_base.h>
|
#include <pgm_base.h>
|
||||||
|
#include <tool/tool_manager.h>
|
||||||
#include <eda_rect.h>
|
#include <eda_rect.h>
|
||||||
#include <wx/display.h>
|
#include <wx/display.h>
|
||||||
#include <wx/grid.h>
|
#include <wx/grid.h>
|
||||||
|
@ -92,6 +93,12 @@ DIALOG_SHIM::DIALOG_SHIM( wxWindow* aParent, wxWindowID id, const wxString& titl
|
||||||
// Inherit units from parent
|
// Inherit units from parent
|
||||||
m_units = kiwayHolder->GetUserUnits();
|
m_units = kiwayHolder->GetUserUnits();
|
||||||
|
|
||||||
|
// Don't mouse-warp after a dialog run from the context menu
|
||||||
|
TOOL_MANAGER* toolMgr = kiwayHolder->GetToolManager();
|
||||||
|
|
||||||
|
if( toolMgr )
|
||||||
|
toolMgr->VetoContextMenuMouseWarp();
|
||||||
|
|
||||||
// Set up the message bus
|
// Set up the message bus
|
||||||
SetKiway( this, &kiwayHolder->Kiway() );
|
SetKiway( this, &kiwayHolder->Kiway() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,12 @@ EDA_UNITS_T KIWAY_HOLDER::GetUserUnits() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TOOL_MANAGER* KIWAY_HOLDER::GetToolManager() const
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// this is not speed critical, hide it out of line.
|
// this is not speed critical, hide it out of line.
|
||||||
void KIWAY_HOLDER::SetKiway( wxWindow* aDest, KIWAY* aKiway )
|
void KIWAY_HOLDER::SetKiway( wxWindow* aDest, KIWAY* aKiway )
|
||||||
{
|
{
|
||||||
|
|
|
@ -689,6 +689,7 @@ void TOOL_MANAGER::dispatchContextMenu( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
m_viewControls->ForceCursorPosition( true, m_menuCursor );
|
m_viewControls->ForceCursorPosition( true, m_menuCursor );
|
||||||
|
m_warpMouseAfterContextMenu = true;
|
||||||
|
|
||||||
// Display a copy of menu
|
// Display a copy of menu
|
||||||
std::unique_ptr<CONTEXT_MENU> menu( m->Clone() );
|
std::unique_ptr<CONTEXT_MENU> menu( m->Clone() );
|
||||||
|
@ -703,8 +704,8 @@ void TOOL_MANAGER::dispatchContextMenu( const TOOL_EVENT& aEvent )
|
||||||
if( frame )
|
if( frame )
|
||||||
frame->PopupMenu( menu.get() );
|
frame->PopupMenu( menu.get() );
|
||||||
|
|
||||||
// Warp the cursor as long as the menu wasn't clicked out of
|
// Warp the cursor if a menu item was selected
|
||||||
if( menu->GetSelected() >= 0 )
|
if( menu->GetSelected() >= 0 && m_warpMouseAfterContextMenu )
|
||||||
m_viewControls->WarpCursor( m_menuCursor, true, false );
|
m_viewControls->WarpCursor( m_menuCursor, true, false );
|
||||||
// Otherwise notify the tool of a cancelled menu
|
// Otherwise notify the tool of a cancelled menu
|
||||||
else
|
else
|
||||||
|
|
|
@ -938,7 +938,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Return the tool manager instance, if any.
|
* Return the tool manager instance, if any.
|
||||||
*/
|
*/
|
||||||
TOOL_MANAGER* GetToolManager() const { return m_toolManager; }
|
TOOL_MANAGER* GetToolManager() const override { return m_toolManager; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A way to pass info to draw functions. the base class has no knowledge about
|
* A way to pass info to draw functions. the base class has no knowledge about
|
||||||
|
|
|
@ -34,6 +34,7 @@ class KIWAY;
|
||||||
class PROJECT;
|
class PROJECT;
|
||||||
struct KIFACE;
|
struct KIFACE;
|
||||||
class KIFACE_I;
|
class KIFACE_I;
|
||||||
|
class TOOL_MANAGER;
|
||||||
|
|
||||||
#define VTBL_ENTRY virtual
|
#define VTBL_ENTRY virtual
|
||||||
|
|
||||||
|
@ -78,6 +79,12 @@ public:
|
||||||
*/
|
*/
|
||||||
VTBL_ENTRY EDA_UNITS_T GetUserUnits() const;
|
VTBL_ENTRY EDA_UNITS_T GetUserUnits() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function GetToolManager
|
||||||
|
* Return the tool manager instance, if any.
|
||||||
|
*/
|
||||||
|
VTBL_ENTRY TOOL_MANAGER* GetToolManager() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function SetKiway
|
* Function SetKiway
|
||||||
*
|
*
|
||||||
|
|
|
@ -372,6 +372,12 @@ public:
|
||||||
*/
|
*/
|
||||||
const KIGFX::VC_SETTINGS& GetCurrentToolVC() const;
|
const KIGFX::VC_SETTINGS& GetCurrentToolVC() const;
|
||||||
|
|
||||||
|
void VetoContextMenuMouseWarp()
|
||||||
|
{
|
||||||
|
m_warpMouseAfterContextMenu = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::pair<TOOL_EVENT_LIST, TOOL_STATE_FUNC> TRANSITION;
|
typedef std::pair<TOOL_EVENT_LIST, TOOL_STATE_FUNC> TRANSITION;
|
||||||
|
|
||||||
|
@ -531,6 +537,8 @@ private:
|
||||||
/// Right click context menu position.
|
/// Right click context menu position.
|
||||||
VECTOR2D m_menuCursor;
|
VECTOR2D m_menuCursor;
|
||||||
|
|
||||||
|
bool m_warpMouseAfterContextMenu;
|
||||||
|
|
||||||
/// Flag indicating whether a context menu is currently displayed.
|
/// Flag indicating whether a context menu is currently displayed.
|
||||||
bool m_menuActive;
|
bool m_menuActive;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue