Get the undecorated window size on GTK when saving the window config

The window decorations introduce an offset to our window size, since
they are not used when restoring the window size at startup they are
added by the window manager again.

Fixes https://gitlab.com/kicad/code/kicad/issues/4278
This commit is contained in:
Ian McInerney 2020-05-06 14:51:07 +01:00
parent 91494fc561
commit c43122a45f
2 changed files with 31 additions and 2 deletions

View File

@ -474,7 +474,7 @@ void EDA_BASE_FRAME::SaveWindowSettings( WINDOW_SETTINGS* aCfg )
}
else
{
m_FrameSize = GetSize();
m_FrameSize = GetWindowSize();
m_FramePos = GetPosition();
}
@ -776,7 +776,7 @@ void EDA_BASE_FRAME::OnMaximize( wxMaximizeEvent& aEvent )
// size information when we maximize the window.
if( !IsMaximized() )
{
m_NormalFrameSize = GetSize();
m_NormalFrameSize = GetWindowSize();
m_NormalFramePos = GetPosition();
wxLogTrace( traceDisplayLocation, "Maximizing window - Saving position (%d, %d) with size (%d, %d)",
m_NormalFramePos.x, m_NormalFramePos.y, m_NormalFrameSize.x, m_NormalFrameSize.y );
@ -785,3 +785,22 @@ void EDA_BASE_FRAME::OnMaximize( wxMaximizeEvent& aEvent )
// Skip event to actually maximize the window
aEvent.Skip();
}
wxSize EDA_BASE_FRAME::GetWindowSize()
{
#ifdef __WXGTK__
// GTK includes the window decorations in the normal GetSize call,
// so we have to use a GTK-specific sizing call that returns the
// non-decorated window size.
int width = 0;
int height = 0;
GTKDoGetSize( &width, &height );
wxSize winSize( width, height );
#else
wxSize winSize = GetSize();
#endif
return winSize;
}

View File

@ -490,6 +490,16 @@ public:
* @return true if the contents of the frame have not been saved
*/
virtual bool IsContentModified();
/**
* Get the undecorated window size that can be used for restoring the window size.
*
* This is needed for GTK, since the normal wxWidgets GetSize() call will return
* a window size that includes the window decorations added by the window manager.
*
* @return the undecorated window size
*/
wxSize GetWindowSize();
};