Re: [HELP REQUEST] property notifies and coalescing them



On Sat, 11 Aug 2001, Hans Breuer wrote:

> At 05:01 11.08.01 +0200, Tim Janik wrote:

> >> This is adding '| G_SIGNAL_TYPE_STATIC_SCOPE' to every 
> >> g_new_signal (..., GDK_TYPE_EVENT), right ?
> >> It appears to really give a performance gain of about 10%.
> >> Ok to apply a patch ?
> >
> >at least for all events in gtkwidget.c, which are emitted from
> >gtk_widget_event(), this is ok, as the event will definitely
> >stay around for the duration of a gtk_widget_event() call (the
> >caller has to ensure that).
> >
> 
> Combined patch below (excluding white-space-changes). Okt to commit?

cool, thanks. the patch looks mostly ok, with the fixes i mention below,
you can commit it.

> 
> Thanks,
>  	Hans
> 
> Index: ChangeLog
> ===================================================================
> RCS file: /cvs/gnome/gtk+/ChangeLog,v
> retrieving revision 1.2167
> diff -u -b -r1.2167 ChangeLog
> --- ChangeLog	2001/08/10 15:33:27	1.2167
> +++ ChangeLog	2001/08/11 10:19:32
> @@ -1,3 +1,16 @@
> +2001-08-11  Hans Breuer  <hans breuer org>
> +
> +	* gtk/gtkalignment.c, gtk/gtkarrow.c, gtk/gtkaspectframe.c,
> +	  gtk/gtkcellrenderer.c, gtk/gtkcellrenderertext.c, 
> +	  gtk/gtkcombo.c, gtk/gtkcurve.c, gtk/gtkfontsel.c, 
> +	  gtk/gtklayout.c, gtk/gtkmisc.c, gtk/gtkpacker.c, 
> +	  gtk/gtkprogress.c, gtk/gtkruler.c,, gtk/gtksettings.c,
> +	  gtk/gtkspinbutton.c : coalescing property notifies
> +
> +	* gtk/gtkclist.c, gtk/gtktipsquery.c, gtk/gtktexttag.c,
> +	  gtk/gtkwidget.c : added G_SIGNAL_TYPE_STATIC_SCOPE to all
> +	GDK_TYPE_EVENT signals
> +
>  Fri Aug 10 16:55:53 2001  Tim Janik  <timj gtk org>
>  
>  	* gtk/gtkwindow.c (gtk_window_set_policy): coalesce multiple
> Index: gtk/gtkalignment.c
> ===================================================================
> RCS file: /cvs/gnome/gtk+/gtk/gtkalignment.c,v
> retrieving revision 1.18
> diff -u -b -r1.18 gtkalignment.c
> --- gtk/gtkalignment.c	2001/07/18 23:39:21	1.18
> +++ gtk/gtkalignment.c	2001/08/11 10:20:07
> @@ -247,8 +247,6 @@
>  		   gfloat        xscale,
>  		   gfloat        yscale)
>  {
> -  gboolean values_changed = FALSE; 
> -  
>    g_return_if_fail (GTK_IS_ALIGNMENT (alignment));
>  
>    xalign = CLAMP (xalign, 0.0, 1.0);
> @@ -256,33 +254,34 @@
>    xscale = CLAMP (xscale, 0.0, 1.0);
>    yscale = CLAMP (yscale, 0.0, 1.0);
>  
> +  if (   (alignment->xalign != xalign)
> +      || (alignment->yalign != yalign)
> +      || (alignment->xscale != xscale)
> +      || (alignment->yscale != yscale))
> +    {
> +      g_object_freeze_notify (G_OBJECT (alignment));
>    if (alignment->xalign != xalign)
>      {
> -       values_changed = TRUE;
>         alignment->xalign = xalign;
>         g_object_notify (G_OBJECT(alignment), "xalign");
>      }
>    if (alignment->yalign != yalign)
>      {
> -       values_changed = TRUE;
>         alignment->yalign = yalign;
>         g_object_notify (G_OBJECT(alignment), "yalign");
>      }
>    if (alignment->xscale != xscale)
>      {
> -       values_changed = TRUE;
>         alignment->xscale = xscale;
>         g_object_notify (G_OBJECT(alignment), "xscale");
>      }
>    if (alignment->yscale != yscale)
>      {
> -       values_changed = TRUE;
>         alignment->yscale = yscale;
>         g_object_notify (G_OBJECT(alignment), "yscale");
>      }
> +      g_object_thaw_notify (G_OBJECT (alignment));
>  
> -   if (values_changed == TRUE)
> -    {
>        gtk_widget_size_allocate (GTK_WIDGET (alignment), &(GTK_WIDGET

uhm, looking at this (though not your change), doing direct allocation
here is actually a bug. if the alignment child requested a resize and
gtk_alignment_set() is issued prior to the resize idle handler being
executed, the child gets reallocated without a new ::size_request.
so gtk_widget_size_allocate (GTK_WIDGET (alignment),...) actually
needs to read:
  if (GTK_BIN (alignment)->child)
    gtk_widget_queue_resize (GTK_BIN (alignment)->child);

> (alignment)->allocation));
>        gtk_widget_queue_draw (GTK_WIDGET (alignment));
>      }
> Index: gtk/gtkarrow.c
> ===================================================================
> RCS file: /cvs/gnome/gtk+/gtk/gtkarrow.c,v
> retrieving revision 1.16
> diff -u -b -r1.16 gtkarrow.c
> --- gtk/gtkarrow.c	2001/07/18 23:39:21	1.16
> +++ gtk/gtkarrow.c	2001/08/11 10:20:08
> @@ -194,26 +194,27 @@
>  	       GtkArrowType   arrow_type,
>  	       GtkShadowType  shadow_type)
>  {
> -  gboolean changed = FALSE;
> -   
>    g_return_if_fail (GTK_IS_ARROW (arrow));
>  
> +  if (   ((GtkArrowType) arrow->arrow_type != arrow_type)
> +      || ((GtkShadowType) arrow->shadow_type != shadow_type))
> +    {
> +      g_object_freeze_notify (G_OBJECT (arrow));
> +
>    if ((GtkArrowType) arrow->arrow_type != arrow_type)
>      {
>        arrow->arrow_type = arrow_type;
>        g_object_notify (G_OBJECT (arrow), "arrow_type");
> -      changed = TRUE;
>      }
>  
>    if ((GtkShadowType) arrow->shadow_type != shadow_type)
>      {
>        arrow->shadow_type = shadow_type;
>        g_object_notify (G_OBJECT (arrow), "shadow_type");
> -      changed = TRUE;
>      }
>  
> -  if (changed == TRUE)
> -    {
> +      g_object_freeze_notify (G_OBJECT (arrow));
> +

typo, you mean to thaw here, not to freeze again ;)

>        if (GTK_WIDGET_DRAWABLE (arrow))
>  	gtk_widget_queue_clear (GTK_WIDGET (arrow));
>      }


---
ciaoTJ





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