fix saving/restoring size when WM supports _NET_FRAME_EXTENTS but not _NET_REQUEST_FRAME_EXTENTS

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57525 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Paul Cornett 2008-12-24 07:51:15 +00:00
parent 6a5a7fba9d
commit 11d8dfd2fb
2 changed files with 26 additions and 10 deletions

View File

@ -90,8 +90,6 @@ public:
GtkWidget *m_mainWidget; GtkWidget *m_mainWidget;
bool m_deferShow;
bool m_fsIsShowing; /* full screen */ bool m_fsIsShowing; /* full screen */
int m_fsSaveGdkFunc, m_fsSaveGdkDecor; int m_fsSaveGdkFunc, m_fsSaveGdkDecor;
wxRect m_fsSaveFrame; wxRect m_fsSaveFrame;
@ -138,6 +136,8 @@ protected:
// string shown in the title bar // string shown in the title bar
wxString m_title; wxString m_title;
bool m_deferShow;
private: private:
wxSize& GetCachedDecorSize(); wxSize& GetCachedDecorSize();
@ -146,6 +146,8 @@ private:
// is the frame currently grabbed explicitly by the application? // is the frame currently grabbed explicitly by the application?
bool m_grabbed; bool m_grabbed;
bool m_updateDecorSize;
}; };
#endif // _WX_GTK_TOPLEVEL_H_ #endif // _WX_GTK_TOPLEVEL_H_

View File

@ -442,6 +442,7 @@ void wxTopLevelWindowGTK::Init()
m_gdkFunc = 0; m_gdkFunc = 0;
m_grabbed = false; m_grabbed = false;
m_deferShow = true; m_deferShow = true;
m_updateDecorSize = true;
m_urgency_hint = -2; m_urgency_hint = -2;
} }
@ -779,18 +780,31 @@ bool wxTopLevelWindowGTK::Show( bool show )
{ {
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
bool deferShow = show && m_deferShow && !m_isShown; bool deferShow = show && !m_isShown && m_deferShow;
if (deferShow) if (deferShow)
{ {
m_deferShow = deferShow = false;
deferShow = !GTK_WIDGET_REALIZED(m_widget) && if (!GTK_WIDGET_REALIZED(m_widget) &&
gdk_x11_screen_supports_net_wm_hint(
gtk_widget_get_screen(m_widget),
gdk_atom_intern("_NET_REQUEST_FRAME_EXTENTS", false)) &&
g_signal_handler_find(m_widget, g_signal_handler_find(m_widget,
GSignalMatchType(G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DATA), GSignalMatchType(G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DATA),
g_signal_lookup("property_notify_event", GTK_TYPE_WIDGET), g_signal_lookup("property_notify_event", GTK_TYPE_WIDGET),
0, NULL, NULL, this); 0, NULL, NULL, this))
{
if (gdk_x11_screen_supports_net_wm_hint(
gtk_widget_get_screen(m_widget),
gdk_atom_intern("_NET_REQUEST_FRAME_EXTENTS", false)))
{
deferShow = true;
}
else
{
// Don't allow changes to m_decorSize, it breaks saving/restoring
// window size with GetSize()/SetSize() because it makes window
// bigger between each restore and save.
m_updateDecorSize = false;
}
}
m_deferShow = deferShow;
} }
if (deferShow) if (deferShow)
{ {
@ -995,7 +1009,7 @@ void wxTopLevelWindowGTK::GTKUpdateDecorSize(const wxSize& decorSize)
{ {
if (!IsMaximized() && !IsFullScreen()) if (!IsMaximized() && !IsFullScreen())
GetCachedDecorSize() = decorSize; GetCachedDecorSize() = decorSize;
if (m_decorSize != decorSize) if (m_updateDecorSize && m_decorSize != decorSize)
{ {
const wxSize diff = decorSize - m_decorSize; const wxSize diff = decorSize - m_decorSize;
m_decorSize = decorSize; m_decorSize = decorSize;