update size hints when decoration size becomes known, and preserve size hint increments

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71856 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Paul Cornett
2012-06-24 16:18:28 +00:00
parent 6186cb7416
commit 8f71e657f3
2 changed files with 13 additions and 3 deletions

View File

@@ -150,6 +150,9 @@ protected:
private: private:
wxSize& GetCachedDecorSize(); wxSize& GetCachedDecorSize();
// size hint increments
int m_incWidth, m_incHeight;
// is the frame currently iconized? // is the frame currently iconized?
bool m_isIconized; bool m_isIconized;

View File

@@ -488,6 +488,7 @@ void wxTopLevelWindowGTK::Init()
m_deferShowAllowed = true; m_deferShowAllowed = true;
m_updateDecorSize = true; m_updateDecorSize = true;
m_netFrameExtentsTimerId = 0; m_netFrameExtentsTimerId = 0;
m_incWidth = m_incHeight = 0;
m_urgency_hint = -2; m_urgency_hint = -2;
} }
@@ -686,7 +687,7 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent,
} }
// GTK sometimes chooses very small size if max size hint is not explicitly set // GTK sometimes chooses very small size if max size hint is not explicitly set
DoSetSizeHints(m_minWidth, m_minHeight, m_maxWidth, m_maxHeight, -1, -1); DoSetSizeHints(m_minWidth, m_minHeight, m_maxWidth, m_maxHeight, m_incWidth, m_incHeight);
m_decorSize = GetCachedDecorSize(); m_decorSize = GetCachedDecorSize();
int w, h; int w, h;
@@ -1100,6 +1101,8 @@ void wxTopLevelWindowGTK::DoSetSizeHints( int minW, int minH,
int incW, int incH ) int incW, int incH )
{ {
base_type::DoSetSizeHints(minW, minH, maxW, maxH, incW, incH); base_type::DoSetSizeHints(minW, minH, maxW, maxH, incW, incH);
m_incWidth = incW;
m_incHeight = incH;
const wxSize minSize = GetMinSize(); const wxSize minSize = GetMinSize();
const wxSize maxSize = GetMaxSize(); const wxSize maxSize = GetMaxSize();
@@ -1146,14 +1149,18 @@ void wxTopLevelWindowGTK::GTKUpdateDecorSize(const wxSize& decorSize)
const wxSize diff = decorSize - m_decorSize; const wxSize diff = decorSize - m_decorSize;
m_decorSize = decorSize; m_decorSize = decorSize;
bool resized = false; bool resized = false;
if (m_minWidth > 0 || m_minHeight > 0 || m_maxWidth > 0 || m_maxHeight > 0)
{
// update size hints, they depend on m_decorSize
DoSetSizeHints(m_minWidth, m_minHeight, m_maxWidth, m_maxHeight, m_incWidth, m_incHeight);
}
if (m_deferShow) if (m_deferShow)
{ {
// keep overall size unchanged by shrinking m_widget // keep overall size unchanged by shrinking m_widget
int w, h; int w, h;
GTKDoGetSize(&w, &h); GTKDoGetSize(&w, &h);
// but not if size would be less than minimum, it won't take effect // but not if size would be less than minimum, it won't take effect
const wxSize minSize = GetMinSize(); if (w >= m_minWidth - decorSize.x && h >= m_minHeight - decorSize.y )
if (w >= minSize.x && h >= minSize.y)
{ {
gtk_window_resize(GTK_WINDOW(m_widget), w, h); gtk_window_resize(GTK_WINDOW(m_widget), w, h);
resized = true; resized = true;