diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 77b741a7a7..e102c6872a 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -276,6 +276,10 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ): GetToolManager()->RunAction( ACTIONS::zoomFitScreen, true ); + // This is used temporarily to fix a client size issue on GTK that causes zoom to fit + // to calculate the wrong zoom size. See SCH_EDIT_FRAME::onSize(). + Bind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this ); + if( GetCanvas() ) { GetCanvas()->GetGAL()->SetAxesEnabled( false ); @@ -1342,3 +1346,18 @@ SELECTION& SCH_EDIT_FRAME::GetCurrentSelection() { return m_toolManager->GetTool()->GetSelection(); } + + +void SCH_EDIT_FRAME::onSize( wxSizeEvent& aEvent ) +{ + if( IsShown() ) + { + // We only need this until the frame is done resizing and the final client size is + // established. + Unbind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this ); + GetToolManager()->RunAction( ACTIONS::zoomFitScreen, true ); + } + + // Skip() is called in the base class. + EDA_DRAW_FRAME::OnSize( aEvent ); +} diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index ae040fa56a..6f09237a19 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -154,6 +154,8 @@ protected: */ void sendNetlistToCvpcb(); + void onSize( wxSizeEvent& aEvent ); + public: SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ); ~SCH_EDIT_FRAME() override; diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index 0ded2b4da6..bde5ca47e4 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -110,7 +110,6 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME ) EVT_CHOICE( ID_ON_GRID_SELECT, PCB_EDIT_FRAME::OnSelectGrid ) EVT_CLOSE( PCB_EDIT_FRAME::OnCloseWindow ) - EVT_SIZE( PCB_EDIT_FRAME::OnSize ) EVT_TOOL( ID_MENU_RECOVER_BOARD_AUTOSAVE, PCB_EDIT_FRAME::Files_io ) @@ -296,6 +295,10 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : GetToolManager()->RunAction( ACTIONS::zoomFitScreen, false ); + // This is used temporarily to fix a client size issue on GTK that causes zoom to fit + // to calculate the wrong zoom size. See PCB_EDIT_FRAME::onSize(). + Bind( wxEVT_SIZE, &PCB_EDIT_FRAME::onSize, this ); + m_canvasType = LoadCanvasTypeSetting(); // Nudge user to switch to OpenGL if they are on Cairo @@ -1624,3 +1627,18 @@ bool PCB_EDIT_FRAME::MicrowaveToolbarShown() { return m_auimgr.GetPane( "MicrowaveToolbar" ).IsShown(); } + + +void PCB_EDIT_FRAME::onSize( wxSizeEvent& aEvent ) +{ + if( IsShown() ) + { + // We only need this until the frame is done resizing and the final client size is + // established. + Unbind( wxEVT_SIZE, &PCB_EDIT_FRAME::onSize, this ); + GetToolManager()->RunAction( ACTIONS::zoomFitScreen, true ); + } + + // Skip() is called in the base class. + EDA_DRAW_FRAME::OnSize( aEvent ); +} diff --git a/pcbnew/pcb_edit_frame.h b/pcbnew/pcb_edit_frame.h index 80b1c71812..61a978e927 100644 --- a/pcbnew/pcb_edit_frame.h +++ b/pcbnew/pcb_edit_frame.h @@ -243,6 +243,8 @@ protected: // protected so that PCB::IFACE::CreateWindow() is the only factory. PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ); + void onSize( wxSizeEvent& aEvent ); + public: PCB_LAYER_BOX_SELECTOR* m_SelLayerBox; // a combo box to display and select active layer wxChoice* m_SelTrackWidthBox; // a choice box to display and select current track width