diff --git a/common/eda_base_frame.cpp b/common/eda_base_frame.cpp index cbbbcc9ce6..96d3d825a4 100644 --- a/common/eda_base_frame.cpp +++ b/common/eda_base_frame.cpp @@ -365,17 +365,9 @@ void EDA_BASE_FRAME::LoadWindowSettings( WINDOW_SETTINGS* aCfg ) wxLogTrace( traceDisplayLocation, "Using minimum size (%d, %d)", m_FrameSize.x, m_FrameSize.y ); } - wxPoint upperRight( m_FramePos.x + m_FrameSize.x, m_FramePos.y ); - wxPoint upperLeft( m_FramePos.x, m_FramePos.y ); - - // Check to see if the requested display is still attached to the computer - int leftInd = wxDisplay::GetFromPoint( upperLeft ); - int rightInd = wxDisplay::GetFromPoint( upperRight ); - wxLogTrace( traceDisplayLocation, "Number of displays: %d", wxDisplay::GetCount() ); - wxLogTrace( traceDisplayLocation, "Previous display indices: %d and %d", leftInd, rightInd ); - if( rightInd == wxNOT_FOUND && leftInd == wxNOT_FOUND ) + if( aCfg->display >= wxDisplay::GetCount() ) { wxLogTrace( traceDisplayLocation, "Previous display not found" ); @@ -398,19 +390,11 @@ void EDA_BASE_FRAME::LoadWindowSettings( WINDOW_SETTINGS* aCfg ) } else { - wxRect clientSize; + wxPoint upperRight( m_FramePos.x + m_FrameSize.x, m_FramePos.y ); + wxPoint upperLeft( m_FramePos.x, m_FramePos.y ); - if( leftInd == wxNOT_FOUND ) - { - // If the top-left point is off-screen, use the display for the top-right point - wxDisplay display( rightInd ); - clientSize = display.GetClientArea(); - } - else - { - wxDisplay display( leftInd ); - clientSize = display.GetClientArea(); - } + wxDisplay display( aCfg->display ); + wxRect clientSize = display.GetClientArea(); // The percentage size (represented in decimal) of the region around the screen's border where // an upper corner is not allowed @@ -499,6 +483,7 @@ void EDA_BASE_FRAME::SaveWindowSettings( WINDOW_SETTINGS* aCfg ) aCfg->size_x = m_FrameSize.x; aCfg->size_y = m_FrameSize.y; aCfg->maximized = IsMaximized(); + aCfg->display = wxDisplay::GetFromWindow( this ); wxLogTrace( traceDisplayLocation, "Saving window maximized: %s", IsMaximized() ? "true" : "false" ); wxLogTrace( traceDisplayLocation, "Saving config position (%d, %d) with size (%d, %d)", diff --git a/common/settings/app_settings.cpp b/common/settings/app_settings.cpp index 40703d7a26..9f98d4b33e 100644 --- a/common/settings/app_settings.cpp +++ b/common/settings/app_settings.cpp @@ -260,6 +260,8 @@ void APP_SETTINGS_BASE::addParamsForWindow( WINDOW_SETTINGS* aWindow, const std: m_params.emplace_back( new PARAM( aJsonPath + ".pos_y", &aWindow->pos_y, 0 ) ); + m_params.emplace_back( new PARAM( aJsonPath + ".display", &aWindow->display, 0 ) ); + m_params.emplace_back( new PARAM_LIST( aJsonPath + ".zoom_factors", &aWindow->zoom_factors, {} ) ); diff --git a/eeschema/eeschema_settings.cpp b/eeschema/eeschema_settings.cpp index 3b1d845a07..b2d56b4eb7 100644 --- a/eeschema/eeschema_settings.cpp +++ b/eeschema/eeschema_settings.cpp @@ -261,6 +261,9 @@ EESCHEMA_SETTINGS::EESCHEMA_SETTINGS() : m_params.emplace_back( new PARAM( "simulator.window.size_y", &m_Simulator.window.size_y, 400 ) ); + m_params.emplace_back( new PARAM( "simulator.window.display", + &m_Simulator.window.display, 0 ) ); + m_params.emplace_back( new PARAM( "simulator.window.maximized", &m_Simulator.window.maximized, false ) ); @@ -315,6 +318,9 @@ EESCHEMA_SETTINGS::EESCHEMA_SETTINGS() : m_params.emplace_back( new PARAM( "lib_view.window.size_y", &m_LibViewPanel.window.size_y, 400 ) ); + m_params.emplace_back( new PARAM( "lib_view.window.display", + &m_LibViewPanel.window.display, 0 ) ); + m_params.emplace_back( new PARAM( "lib_view.window.maximized", &m_LibViewPanel.window.maximized, false ) ); diff --git a/include/settings/app_settings.h b/include/settings/app_settings.h index ee1fe0b491..44d8a3a764 100644 --- a/include/settings/app_settings.h +++ b/include/settings/app_settings.h @@ -74,6 +74,7 @@ struct WINDOW_SETTINGS wxString perspective; int pos_x; int pos_y; + unsigned int display; std::vector zoom_factors;