From 89267fe552799e2baeadae4c88fc53508974339d Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Sat, 22 Mar 2008 11:55:11 +0000 Subject: [PATCH] fixes to Freeze/Thawn when the window is shown or hidden in between Freeze and Thaw git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52688 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/window.cpp | 60 ++++++++++++++++++++++++++++++++++++++++++---- src/msw/window.cpp | 30 ++++++++++++++++------- 2 files changed, 77 insertions(+), 13 deletions(-) diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index f71bac7cec..e2626da0a8 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -4311,16 +4311,68 @@ GdkWindow* wxWindowGTK::GTKGetDrawingWindow() const // freeze/thaw // ---------------------------------------------------------------------------- +extern "C" +{ + +// this is called if we attempted to freeze unrealized widget when it finally +// is realized (and so can be frozen): +static void wx_frozen_widget_realize(GtkWidget* w, void* WXUNUSED(data)) +{ + wxASSERT( w && !GTK_WIDGET_NO_WINDOW(w) ); + wxASSERT( GTK_WIDGET_REALIZED(w) ); + + g_signal_handlers_disconnect_by_func + ( + w, + (void*)wx_frozen_widget_realize, + NULL + ); + + gdk_window_freeze_updates(w->window); +} + +} // extern "C" + void wxWindowGTK::GTKFreezeWidget(GtkWidget *w) { - if ( w && !GTK_WIDGET_NO_WINDOW(w) ) - gdk_window_freeze_updates(w->window); + if ( !w || GTK_WIDGET_NO_WINDOW(w) ) + return; // window-less widget, cannot be frozen + + if ( !GTK_WIDGET_REALIZED(w) ) + { + // we can't thaw unrealized widgets because they don't have GdkWindow, + // so set it up to be done immediately after realization: + g_signal_connect_after + ( + w, + "realize", + G_CALLBACK(wx_frozen_widget_realize), + NULL + ); + return; + } + + gdk_window_freeze_updates(w->window); } void wxWindowGTK::GTKThawWidget(GtkWidget *w) { - if ( w && !GTK_WIDGET_NO_WINDOW(w) ) - gdk_window_thaw_updates(w->window); + if ( !w || GTK_WIDGET_NO_WINDOW(w) ) + return; // window-less widget, cannot be frozen + + if ( !GTK_WIDGET_REALIZED(w) ) + { + // the widget wasn't realized yet, no need to thaw + g_signal_handlers_disconnect_by_func + ( + w, + (void*)wx_frozen_widget_realize, + NULL + ); + return; + } + + gdk_window_thaw_updates(w->window); } void wxWindowGTK::DoFreeze() diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 87a4f12601..53d7313f36 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -716,6 +716,16 @@ bool wxWindowMSW::Show(bool show) ::ShowWindow(hWnd, show ? SW_SHOW : SW_HIDE); } + if ( IsFrozen() ) + { + // DoFreeze/DoThaw don't do anything if the window is not shown, so + // we have to call them from here now + if ( show ) + DoFreeze(); + else + DoThaw(); + } + return true; } @@ -1615,20 +1625,22 @@ static inline void SendSetRedraw(HWND hwnd, bool on) void wxWindowMSW::DoFreeze() { - if ( IsShown() ) - SendSetRedraw(GetHwnd(), false); + if ( !IsShown() ) + return; // no point in freezing hidden window + + SendSetRedraw(GetHwnd(), false); } void wxWindowMSW::DoThaw() { - if ( IsShown() ) - { - SendSetRedraw(GetHwnd(), true); + if ( !IsShown() ) + return; // hidden windows aren't frozen by DoFreeze - // we need to refresh everything or otherwise the invalidated area - // is not going to be repainted - Refresh(); - } + SendSetRedraw(GetHwnd(), true); + + // we need to refresh everything or otherwise the invalidated area + // is not going to be repainted + Refresh(); } void wxWindowMSW::Refresh(bool eraseBack, const wxRect *rect) -- 2.45.2