GtkLayout expose_event bug




I think there's a bug in GtkLayout.
If you scroll left or up you get each expose event twice, which
could affect performance quite badly.

GtkLayout filters out expose events where the origin has been
temporarily moved, but when scrolling up/left the last expose event
automatically generated by X will be at 0, 0 and so won't be filtered:

A test program is attached.

If I turn off the expose events generated by the GtkLayout
itself, it works OK. This works:

--- gtklayout.c.orig    Sat Sep 25 23:03:13 1999
+++ gtklayout.c Thu Oct  7 21:39:44 1999
@@ -991,11 +991,13 @@
          /* FIXME */
        }
 
+#if 0
       gtk_layout_expose_area (layout,
                              0,
                              0,
                              MIN (-dx, widget->allocation.width),
                              widget->allocation.height);
+#endif
     }
 
   if (dy > 0)
@@ -1039,11 +1041,13 @@
        {
          /* FIXME */
        }
+#if 0
       gtk_layout_expose_area (layout, 
                              0,
                              0,
                              widget->allocation.width,
                              MIN (-dy, (gint)widget->allocation.height));
+#endif
     }
 
   gtk_layout_position_children (layout);

Damon
#include <gtk/gtk.h>

static gint on_layout_expose_event (GtkWidget *widget,
				    GdkEventExpose *e,
				    gpointer data);

int
main (int argc, char *argv[])
{
  GtkWidget *main_window, *scrolled_win, *layout;
  GtkAdjustment *hsba, *vsba;
 
  gtk_init (&argc, &argv);
  
  main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_policy (GTK_WINDOW(main_window), FALSE, TRUE, FALSE);
  gtk_window_set_default_size (GTK_WINDOW (main_window), 400, 400);

  hsba = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 10.0, 0.0, 0.0));
  vsba = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 10.0, 0.0, 0.0));

  scrolled_win = gtk_scrolled_window_new (hsba, vsba);
  gtk_container_add (GTK_CONTAINER (main_window), scrolled_win);  
  
  layout = gtk_layout_new (hsba, vsba);
  gtk_container_add (GTK_CONTAINER (scrolled_win), layout);  
  gtk_layout_set_size (GTK_LAYOUT (layout), 2500, 2500);
 
  gtk_signal_connect (GTK_OBJECT (layout), "expose_event",
		      (GtkSignalFunc) on_layout_expose_event, NULL);

  gtk_widget_show(layout);
  gtk_widget_show(scrolled_win);
  gtk_widget_show(main_window);

  gtk_main ();

  return(0);
}

static gint
on_layout_expose_event (GtkWidget *widget,
			GdkEventExpose *e,
			gpointer data)
{
  g_print ("In on_layout_expose_event send_event:%i X:%i Y:%i W:%i H:%i\n",
	   e->send_event, e->area.x, e->area.y, e->area.width, e->area.height);

  return FALSE;
}




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