Save the wxDisplay index to set the position of windows correctly

Fixes https://gitlab.com/kicad/code/kicad/-/issues/4338
This commit is contained in:
Mark Roszko 2020-07-27 02:53:56 +00:00 committed by Seth Hillbrand
parent 7bdb98f961
commit 8324cb30b7
4 changed files with 15 additions and 21 deletions

View File

@ -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)",

View File

@ -260,6 +260,8 @@ void APP_SETTINGS_BASE::addParamsForWindow( WINDOW_SETTINGS* aWindow, const std:
m_params.emplace_back( new PARAM<int>( aJsonPath + ".pos_y", &aWindow->pos_y, 0 ) );
m_params.emplace_back( new PARAM<unsigned int>( aJsonPath + ".display", &aWindow->display, 0 ) );
m_params.emplace_back( new PARAM_LIST<double>( aJsonPath + ".zoom_factors",
&aWindow->zoom_factors, {} ) );

View File

@ -261,6 +261,9 @@ EESCHEMA_SETTINGS::EESCHEMA_SETTINGS() :
m_params.emplace_back( new PARAM<int>( "simulator.window.size_y",
&m_Simulator.window.size_y, 400 ) );
m_params.emplace_back( new PARAM<unsigned int>( "simulator.window.display",
&m_Simulator.window.display, 0 ) );
m_params.emplace_back( new PARAM<bool>( "simulator.window.maximized",
&m_Simulator.window.maximized, false ) );
@ -315,6 +318,9 @@ EESCHEMA_SETTINGS::EESCHEMA_SETTINGS() :
m_params.emplace_back( new PARAM<int>( "lib_view.window.size_y",
&m_LibViewPanel.window.size_y, 400 ) );
m_params.emplace_back( new PARAM<unsigned int>( "lib_view.window.display",
&m_LibViewPanel.window.display, 0 ) );
m_params.emplace_back( new PARAM<bool>( "lib_view.window.maximized",
&m_LibViewPanel.window.maximized, false ) );

View File

@ -74,6 +74,7 @@ struct WINDOW_SETTINGS
wxString perspective;
int pos_x;
int pos_y;
unsigned int display;
std::vector<double> zoom_factors;