Tintin72 writes: > Do you think is there a way to improve/optimise my code and remove this > problem ?
Yes. Thanks to Mitch on #gimp for this hint: You should set the background of the window instead of trying to paint the background yourself in the expose_event handler. Below is your sample program corrected. Now I don't see any artefacts while scrolling any longer. --tml #include <gtk/gtk.h> #define WIDTH 500 #define HEIGHT 300 typedef struct APPLICATION { GtkWidget *pWin; GtkWidget *pDrawArea; GtkWidget *pVBox; GtkWidget *pScrollBar; }APPLICATION; static gboolean draw_cb(GtkWidget *drawArea, GdkEventExpose *event, gpointer userData) { PangoContext *pContext = gtk_widget_get_pango_context(drawArea); PangoLayout *pLayout = pango_layout_new(pContext); int i; for(i = 0; i < 30; i++) { pango_layout_set_text (pLayout, g_strdup_printf ("Test clipping %d", i), -1); gdk_draw_layout (drawArea->window, drawArea->style->fg_gc[GTK_WIDGET_STATE(drawArea)], 0,i * 15, pLayout); } g_object_unref(pLayout); return FALSE; } int main (int argc, char *argv[]) { APPLICATION myApp; gtk_init(&argc, &argv); myApp.pWin = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size(GTK_WINDOW(myApp.pWin), WIDTH, HEIGHT); g_signal_connect(G_OBJECT(myApp.pWin), "destroy", G_CALLBACK(gtk_main_quit), NULL); myApp.pVBox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(myApp.pWin), myApp.pVBox); myApp.pScrollBar = gtk_scrolled_window_new(NULL,NULL); gtk_box_pack_start(GTK_BOX(myApp.pVBox), myApp.pScrollBar, TRUE, TRUE, 0); myApp.pDrawArea = gtk_drawing_area_new (); gtk_widget_modify_bg (GTK_WIDGET(myApp.pDrawArea), GTK_STATE_NORMAL, >K_WIDGET(myApp.pDrawArea)->style->white); gtk_widget_set_size_request (myApp.pDrawArea, myApp.pWin->allocation.width, 500); g_signal_connect(G_OBJECT(myApp.pDrawArea),"expose_event",G_CALLBACK(draw_cb), &myApp); gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(myApp.pScrollBar), myApp.pDrawArea); gtk_window_set_title(GTK_WINDOW(myApp.pWin), "GTK-Win"); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(myApp.pScrollBar), GTK_POLICY_NEVER,GTK_POLICY_AUTOMATIC); gtk_widget_show_all (myApp.pWin); gtk_main (); return 0; } _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list