From 8f71e657f32c352ce11d05902bbd60f428249687 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Sun, 24 Jun 2012 16:18:28 +0000 Subject: [PATCH] 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 --- include/wx/gtk/toplevel.h | 3 +++ src/gtk/toplevel.cpp | 13 ++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/include/wx/gtk/toplevel.h b/include/wx/gtk/toplevel.h index f056ed3102..1b69ba287b 100644 --- a/include/wx/gtk/toplevel.h +++ b/include/wx/gtk/toplevel.h @@ -150,6 +150,9 @@ protected: private: wxSize& GetCachedDecorSize(); + // size hint increments + int m_incWidth, m_incHeight; + // is the frame currently iconized? bool m_isIconized; diff --git a/src/gtk/toplevel.cpp b/src/gtk/toplevel.cpp index 323e1a00b3..21e0d8abcd 100644 --- a/src/gtk/toplevel.cpp +++ b/src/gtk/toplevel.cpp @@ -488,6 +488,7 @@ void wxTopLevelWindowGTK::Init() m_deferShowAllowed = true; m_updateDecorSize = true; m_netFrameExtentsTimerId = 0; + m_incWidth = m_incHeight = 0; 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 - 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(); int w, h; @@ -1100,6 +1101,8 @@ void wxTopLevelWindowGTK::DoSetSizeHints( int minW, int minH, int incW, int incH ) { base_type::DoSetSizeHints(minW, minH, maxW, maxH, incW, incH); + m_incWidth = incW; + m_incHeight = incH; const wxSize minSize = GetMinSize(); const wxSize maxSize = GetMaxSize(); @@ -1146,14 +1149,18 @@ void wxTopLevelWindowGTK::GTKUpdateDecorSize(const wxSize& decorSize) const wxSize diff = decorSize - m_decorSize; m_decorSize = decorSize; 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) { // keep overall size unchanged by shrinking m_widget int w, h; GTKDoGetSize(&w, &h); // but not if size would be less than minimum, it won't take effect - const wxSize minSize = GetMinSize(); - if (w >= minSize.x && h >= minSize.y) + if (w >= m_minWidth - decorSize.x && h >= m_minHeight - decorSize.y ) { gtk_window_resize(GTK_WINDOW(m_widget), w, h); resized = true; -- 2.45.2