+
+// ----------------------------------------------------------------------------
+// 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, wxWindowGTK* win)
+{
+ wxASSERT( w && gtk_widget_get_has_window(w) );
+ wxASSERT( gtk_widget_get_realized(w) );
+
+ g_signal_handlers_disconnect_by_func
+ (
+ w,
+ (void*)wx_frozen_widget_realize,
+ win
+ );
+
+ GdkWindow* window;
+ if (w == win->m_wxwindow)
+ window = win->GTKGetDrawingWindow();
+ else
+ window = gtk_widget_get_window(w);
+ gdk_window_freeze_updates(window);
+}
+
+} // extern "C"
+
+void wxWindowGTK::GTKFreezeWidget(GtkWidget *w)
+{
+ if ( !w || !gtk_widget_get_has_window(w) )
+ return; // window-less widget, cannot be frozen
+
+ GdkWindow* window = gtk_widget_get_window(w);
+ if (window == NULL)
+ {
+ // 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),
+ this
+ );
+ return;
+ }
+
+ if (w == m_wxwindow)
+ window = GTKGetDrawingWindow();
+ gdk_window_freeze_updates(window);
+}
+
+void wxWindowGTK::GTKThawWidget(GtkWidget *w)
+{
+ if ( !w || !gtk_widget_get_has_window(w) )
+ return; // window-less widget, cannot be frozen
+
+ GdkWindow* window = gtk_widget_get_window(w);
+ if (window == NULL)
+ {
+ // the widget wasn't realized yet, no need to thaw
+ g_signal_handlers_disconnect_by_func
+ (
+ w,
+ (void*)wx_frozen_widget_realize,
+ this
+ );
+ return;
+ }
+
+ if (w == m_wxwindow)
+ window = GTKGetDrawingWindow();
+ gdk_window_thaw_updates(window);
+}
+
+void wxWindowGTK::DoFreeze()
+{
+ GTKFreezeWidget(m_widget);
+ if ( m_wxwindow && m_widget != m_wxwindow )
+ GTKFreezeWidget(m_wxwindow);
+}
+
+void wxWindowGTK::DoThaw()
+{
+ GTKThawWidget(m_widget);
+ if ( m_wxwindow && m_widget != m_wxwindow )
+ GTKThawWidget(m_wxwindow);
+}