patch for flicker of gtk_paint_box



I just had a look at ggv for it's scrollpane widget - exactly what I was
looking for, thanks for the quick help.  However, it has a slightly
annoying flicker caused by repeatedly calling gtk_paint_box() when
re-drawing the trough of the control.  The big problem is that the shadows
get erased and re-drawn repeatedly.  Attached is a patch for
gtk/gtkstyle.c that, for the default draw_box, elliminates the needless
erasure of the shadow since it will simply be drawn on top of anyway.
It's against 1.2.6, not the CVS tree, 'cause I haven't bothered to get
that.  It's only slightly kludgy in that it relies on the shadow width
being 2 pixels for the default draw_shadow (which it always is), but it
might not be obvious that there is such linkage.

I noted in the tutorial that the progress bar was relieved of flicker by
using an off-screen pixmap.  That suggests to me that needless overlapped
drawing of rectangles isn't frowned upon within the toolkit.  IMHO, it
should be.

harry
***BEGIN DIFF***
--- gtkstyle.c	Mon Aug 23 15:40:34 1999
+++ gtkstyle.c.new	Sun Feb  6 00:40:29 2000
@@ -2177,6 +2177,9 @@
 		      gint           width,
 		      gint           height)
 {
+  gint inset = 0;
+  gint delta = 0;
+
   g_return_if_fail (style != NULL);
   g_return_if_fail (window != NULL);
   
@@ -2187,6 +2190,13 @@
   else if (height == -1)
     gdk_window_get_size (window, NULL, &height);
   
+  if (shadow_type != GTK_SHADOW_NONE && style->klass != NULL &&
+      style->klass->draw_shadow == gtk_default_draw_shadow)
+    {
+      inset = 2;
+      delta = 4;
+    }
+
   if (!style->bg_pixmap[state_type] || 
       gdk_window_get_type (window) == GDK_WINDOW_PIXMAP)
     {
@@ -2194,14 +2204,16 @@
 	gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
 
       gdk_draw_rectangle (window, style->bg_gc[state_type], TRUE,
-                          x, y, width, height);
+                          x + inset, y + inset, width - delta,
+                          height - delta);
       if (area)
 	gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
     }
   else
     gtk_style_apply_default_background (style, window,
                                         widget && !GTK_WIDGET_NO_WINDOW (widget
),
-                                        state_type, area, x, y, width, height);

+                                        state_type, area, x + inset, y + inset,

+                                        width - delta, height - delta);
   
   gtk_paint_shadow (style, window, state_type, shadow_type, area, widget, detai
l,
                     x, y, width, height);
**** END DIFF ****



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]