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
This commit is contained in:
Václav Slavík 2008-03-22 11:55:11 +00:00
parent 22f43cb5a7
commit 89267fe552
2 changed files with 77 additions and 13 deletions

View File

@ -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()

View File

@ -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)