diff --git a/common/dialog_shim.cpp b/common/dialog_shim.cpp
index 0b0c03e582..2ba8ebd72e 100644
--- a/common/dialog_shim.cpp
+++ b/common/dialog_shim.cpp
@@ -60,7 +60,7 @@ public:
if( m_win )
{
m_win->Enable();
- m_win->SetFocus(); // let's focus back on the parent window
+ m_win->Raise(); // let's focus back on the parent window
}
}
};
diff --git a/common/dialogs/panel_common_settings.cpp b/common/dialogs/panel_common_settings.cpp
index 9d2ff169b8..5fad4edafe 100644
--- a/common/dialogs/panel_common_settings.cpp
+++ b/common/dialogs/panel_common_settings.cpp
@@ -292,15 +292,16 @@ bool PANEL_COMMON_SETTINGS::TransferDataFromWindow()
m_highContrastCtrl->GetValue().ToDouble( &dimmingPercent );
commonSettings->m_Appearance.hicontrast_dimming_factor = dimmingPercent / 100.0f;
- commonSettings->m_Input.immediate_actions = !m_NonImmediateActions->GetValue();
- commonSettings->m_Input.warp_mouse_on_move = m_warpMouseOnMove->GetValue();
+ commonSettings->m_Input.focus_follow_sch_pcb = m_focusFollowSchPcb->GetValue();
+ commonSettings->m_Input.immediate_actions = !m_NonImmediateActions->GetValue();
+ commonSettings->m_Input.warp_mouse_on_move = m_warpMouseOnMove->GetValue();
- commonSettings->m_Backup.enabled = m_cbBackupEnabled->GetValue();
- commonSettings->m_Backup.backup_on_autosave = m_cbBackupAutosave->GetValue();
- commonSettings->m_Backup.limit_total_files = m_backupLimitTotalFiles->GetValue();
- commonSettings->m_Backup.limit_daily_files = m_backupLimitDailyFiles->GetValue();
- commonSettings->m_Backup.min_interval = m_backupMinInterval->GetValue() * 60;
- commonSettings->m_Backup.limit_total_size = m_backupLimitTotalSize->GetValue() * 1024 * 1024;
+ commonSettings->m_Backup.enabled = m_cbBackupEnabled->GetValue();
+ commonSettings->m_Backup.backup_on_autosave = m_cbBackupAutosave->GetValue();
+ commonSettings->m_Backup.limit_total_files = m_backupLimitTotalFiles->GetValue();
+ commonSettings->m_Backup.limit_daily_files = m_backupLimitDailyFiles->GetValue();
+ commonSettings->m_Backup.min_interval = m_backupMinInterval->GetValue() * 60;
+ commonSettings->m_Backup.limit_total_size = m_backupLimitTotalSize->GetValue() * 1024 * 1024;
commonSettings->m_Session.remember_open_files = m_cbRememberOpenFiles->GetValue();
@@ -384,6 +385,7 @@ void PANEL_COMMON_SETTINGS::applySettingsToPanel( COMMON_SETTINGS& aSettings )
double dimmingPercent = aSettings.m_Appearance.hicontrast_dimming_factor * 100.0f;
m_highContrastCtrl->SetValue( wxString::Format( "%.0f", dimmingPercent ) );
+ m_focusFollowSchPcb->SetValue( aSettings.m_Input.focus_follow_sch_pcb );
m_warpMouseOnMove->SetValue( aSettings.m_Input.warp_mouse_on_move );
m_NonImmediateActions->SetValue( !aSettings.m_Input.immediate_actions );
diff --git a/common/dialogs/panel_common_settings_base.cpp b/common/dialogs/panel_common_settings_base.cpp
index 0416ad3d9d..5dd9c377a9 100644
--- a/common/dialogs/panel_common_settings_base.cpp
+++ b/common/dialogs/panel_common_settings_base.cpp
@@ -127,6 +127,11 @@ PANEL_COMMON_SETTINGS_BASE::PANEL_COMMON_SETTINGS_BASE( wxWindow* parent, wxWind
bSizer81->Add( m_showScrollbars, 0, wxALIGN_LEFT|wxBOTTOM, 5 );
+ m_focusFollowSchPcb = new wxCheckBox( m_sbUserInterface->GetStaticBox(), wxID_ANY, _("Focus follows mouse between schematic and PCB editors"), wxDefaultPosition, wxDefaultSize, 0 );
+ m_focusFollowSchPcb->SetToolTip( _("If the mouse cursor is moved over the canvas of a schematic or PCB editor window, that window is raised.") );
+
+ bSizer81->Add( m_focusFollowSchPcb, 0, wxALIGN_LEFT|wxBOTTOM, 5 );
+
m_gbUserInterface->Add( bSizer81, wxGBPosition( 0, 0 ), wxGBSpan( 2, 4 ), wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxEXPAND, 5 );
diff --git a/common/dialogs/panel_common_settings_base.fbp b/common/dialogs/panel_common_settings_base.fbp
index b03f95afbc..c64d33e686 100644
--- a/common/dialogs/panel_common_settings_base.fbp
+++ b/common/dialogs/panel_common_settings_base.fbp
@@ -1050,6 +1050,70 @@
+
diff --git a/common/dialogs/panel_common_settings_base.h b/common/dialogs/panel_common_settings_base.h
index 0394266998..695df9cf9f 100644
--- a/common/dialogs/panel_common_settings_base.h
+++ b/common/dialogs/panel_common_settings_base.h
@@ -55,6 +55,7 @@ class PANEL_COMMON_SETTINGS_BASE : public RESETTABLE_PANEL
wxGridBagSizer* m_gbUserInterface;
wxCheckBox* m_checkBoxIconsInMenus;
wxCheckBox* m_showScrollbars;
+ wxCheckBox* m_focusFollowSchPcb;
wxStaticText* m_stIconTheme;
wxRadioButton* m_rbIconThemeLight;
wxRadioButton* m_rbIconThemeDark;
diff --git a/common/settings/common_settings.cpp b/common/settings/common_settings.cpp
index b6d18ba596..b9361aadb4 100644
--- a/common/settings/common_settings.cpp
+++ b/common/settings/common_settings.cpp
@@ -227,6 +227,9 @@ COMMON_SETTINGS::COMMON_SETTINGS() :
},
{} ) );
+ m_params.emplace_back( new PARAM( "input.focus_follow_sch_pcb",
+ &m_Input.focus_follow_sch_pcb, false ) );
+
m_params.emplace_back( new PARAM( "input.auto_pan", &m_Input.auto_pan, false ) );
m_params.emplace_back( new PARAM( "input.auto_pan_acceleration",
diff --git a/common/view/wx_view_controls.cpp b/common/view/wx_view_controls.cpp
index 00c9e57cf2..23985b3212 100644
--- a/common/view/wx_view_controls.cpp
+++ b/common/view/wx_view_controls.cpp
@@ -39,6 +39,8 @@
#include
#include
#include
+#include
+#include
#include
#include
@@ -156,6 +158,7 @@ void WX_VIEW_CONTROLS::LoadSettings()
COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
m_settings.m_warpCursor = cfg->m_Input.center_on_zoom;
+ m_settings.m_focusFollowSchPcb = cfg->m_Input.focus_follow_sch_pcb;
m_settings.m_autoPanSettingEnabled = cfg->m_Input.auto_pan;
m_settings.m_autoPanAcceleration = cfg->m_Input.auto_pan_acceleration;
m_settings.m_horizontalPan = cfg->m_Input.horizontal_pan;
@@ -201,6 +204,30 @@ void WX_VIEW_CONTROLS::onMotion( wxMouseEvent& aEvent )
int y = aEvent.GetY();
VECTOR2D mousePos( x, y );
+ // Automatic focus switching between SCH and PCB windows on canvas mouse motion
+ if( m_settings.m_focusFollowSchPcb )
+ {
+ if( EDA_DRAW_FRAME* frame = m_parentPanel->GetParentEDAFrame() )
+ {
+ KIWAY_PLAYER* otherFrame = nullptr;
+
+ if( frame->IsType( FRAME_PCB_EDITOR ) )
+ {
+ otherFrame = frame->Kiway().Player( FRAME_SCH, false );
+ }
+ else if( frame->IsType( FRAME_SCH ) )
+ {
+ otherFrame = frame->Kiway().Player( FRAME_PCB_EDITOR, false );
+ }
+
+ if( otherFrame && KIPLATFORM::UI::IsWindowActive( otherFrame )
+ && !KIPLATFORM::UI::IsWindowActive( frame ) )
+ {
+ frame->Raise();
+ }
+ }
+ }
+
if( m_state != DRAG_PANNING && m_state != DRAG_ZOOMING )
handleCursorCapture( x, y );
diff --git a/include/settings/common_settings.h b/include/settings/common_settings.h
index ce7876fa3c..a7795801bc 100644
--- a/include/settings/common_settings.h
+++ b/include/settings/common_settings.h
@@ -78,6 +78,7 @@ public:
struct INPUT
{
+ bool focus_follow_sch_pcb;
bool auto_pan;
int auto_pan_acceleration;
bool center_on_zoom;
diff --git a/include/view/view_controls.h b/include/view/view_controls.h
index 2aa1e815bc..a360e9906b 100644
--- a/include/view/view_controls.h
+++ b/include/view/view_controls.h
@@ -66,6 +66,9 @@ struct VC_SETTINGS
///< Flag for grabbing the mouse cursor.
bool m_grabMouse;
+ ///< Flag for automatic focus switching between Schematic and PCB editors.
+ bool m_focusFollowSchPcb;
+
///< Flag for turning on autopanning.
bool m_autoPanEnabled;