]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/window.cpp
correct the test for Windows platform (this also fixes unit test failures in FormatCo...
[wxWidgets.git] / src / gtk / window.cpp
index ae545bf49aa704fb4eda7917b0e225cc4fa23205..845268de6727f481a1f0a39ecbf287c81aaa5e96 100644 (file)
@@ -1828,7 +1828,7 @@ gtk_window_realized_callback(GtkWidget* widget, wxWindow* win)
         gtk_im_context_set_client_window( win->m_imData->context,
                                           widget->window);
     }
-
+    
     // We cannot set colours and fonts before the widget
     // been realized, so we do this directly after realization
     // or otherwise in idle time
@@ -3529,35 +3529,42 @@ bool wxWindowGTK::ScrollPages(int pages)
 void wxWindowGTK::Refresh(bool WXUNUSED(eraseBackground),
                           const wxRect *rect)
 {
-    GtkWidget* widget;
-    if (m_wxwindow)
-        widget = m_wxwindow;
-    else if (m_widget)
-        widget = m_widget;
-    else
-        return;
-
-    if (!widget->window)
+    if ( !m_widget )
+    {
+        // it is valid to call Refresh() for a window which hasn't been created
+        // yet, it simply doesn't do anything in this case
         return;
+    }
 
-    if (rect == NULL)
-        gtk_widget_queue_draw(widget);
+    if (!m_wxwindow)
+    {
+        if (rect)
+            gtk_widget_queue_draw_area( m_widget, rect->x, rect->y, rect->width, rect->height );
+        else
+            gtk_widget_queue_draw( m_widget );
+    }
     else
     {
-        int x = rect->x;
-        if (GetLayoutDirection() == wxLayout_RightToLeft)
-            x = GetClientSize().x - x - rect->width;
+        // Just return if the widget or one of its ancestors isn't mapped
+        GtkWidget *w;
+        for (w = m_wxwindow; w != NULL; w = w->parent)
+            if (!GTK_WIDGET_MAPPED (w))
+                return;
 
-#if 0
-        gtk_widget_queue_draw_area(widget, x, rect->y, rect->width, rect->height);
-#else
-        GdkRectangle r;
-        r.x = rect->x;
-        r.y = rect->y;
-        r.width = rect->width;
-        r.height = rect->height;
-        gdk_window_invalidate_rect( m_wxwindow->window, &r, TRUE );
-#endif
+        if (rect)
+        {
+            int x = rect->x;
+            if (GetLayoutDirection() == wxLayout_RightToLeft)
+                x = GetClientSize().x - x - rect->width;
+            GdkRectangle r;
+            r.x = rect->x;
+            r.y = rect->y;
+            r.width = rect->width;
+            r.height = rect->height;
+            gdk_window_invalidate_rect( m_wxwindow->window, &r, TRUE );
+        }
+        else
+            gdk_window_invalidate_rect( m_wxwindow->window, NULL, TRUE );
     }
 }
 
@@ -3570,8 +3577,8 @@ void wxWindowGTK::Update()
         // This ensures nothing will overwrite the drawing we are about to do.
         gdk_display_sync(display);
 
-        gdk_window_process_updates(m_widget->window, true);
-
+        gdk_window_process_updates(m_widget->window, TRUE);
+        
         // Flush again, but no need to wait for it to finish
         gdk_display_flush(display);
     }