Re: Size allocation and redrawing issues



On 30 Oct 2001, Owen Taylor wrote:

> Attached is my attempt at implement what I described. Brief summary
> of what it does:
[...]

> But beyond that, it achieves my goals of eliminating hysteresis,
> and allowing widgets that want to handle resizes in a "smarter"
> to do so.

there's one thing that i'm a bit worried about.
iirc, one of the reasons for the hysteresis was:

window
  |
  vbox
    |
    +-hbox
    |  |
    |  +-label
    |
    +- foo (other) widgets

if label constantly changes text (say from a timeout), and thusly resizes
(grows and/or shrinks), that could screw the whole GUI, worst case
scenario was the window itself resizing with every timeout.

off head, what container would give me the old behaviour, say:
struct {
 GtkContainer...;
 guint old_width, old_height;
};
init () { old_width=old_height=0; }
size_request () {
  forall children do { old_width=MAX(old_width,child->width);
    old_height = MAX (old_height, child->height);
  }
 width=old_width;
 height=old_height;
}

and, to play nicely after some time, connect to toplevel's ::size_allocate,
and reset old_width=old_height=0; in the handler?

other than that, here're a few comments on the patch.


> diff -u -p -r1.24 gtkprivate.h
> --- gtk/gtkprivate.h    2001/10/29 07:06:36     1.24
> +++ gtk/gtkprivate.h    2001/10/29 23:17:04
> @@ -43,14 +43,16 @@ typedef enum
>  {
>    PRIVATE_GTK_USER_STYLE       = 1 <<  0,
>    PRIVATE_GTK_RESIZE_PENDING   = 1 <<  2,
> -  PRIVATE_GTK_RESIZE_NEEDED    = 1 <<  3,

if you do this, you need to adapt the shift counts so
they stay incrementing.

>    PRIVATE_GTK_LEAVE_PENDING    = 1 <<  4,
>    PRIVATE_GTK_HAS_SHAPE_MASK   = 1 <<  5,
>    PRIVATE_GTK_IN_REPARENT       = 1 <<  6,
>    PRIVATE_GTK_DIRECTION_SET     = 1 <<  7,   /* If the reading direction is not DIR_NONE */
>    PRIVATE_GTK_DIRECTION_LTR     = 1 <<  8,   /* If the reading direction is DIR_LTR */
>    PRIVATE_GTK_ANCHORED          = 1 <<  9,   /* If widget has a GtkWindow ancestor */
> -  PRIVATE_GTK_CHILD_VISIBLE     = 1 <<  10   /* If widget should be mapped when parent is mapped */
> +  PRIVATE_GTK_CHILD_VISIBLE     = 1 <<  10,  /* If widget should be mapped when parent is mapped */
> +  PRIVATE_GTK_REDRAW_ON_ALLOC   = 1 <<  11,  /* If we should queue a draw on the entire widget when it is reallocated */
> +  PRIVATE_GTK_ALLOC_NEEDED      = 1 <<  12,  /* If we we should allocate even if the allocation is the same */
> +  PRIVATE_GTK_REQUEST_NEEDED    = 1 <<  13   /* Whether we need to call gtk_widget_size_request */
>  } GtkPrivateFlags;


> diff -u -p -r1.3 gtksizegroup.c
> --- gtk/gtksizegroup.c  2001/10/26 23:47:38     1.3
> +++ gtk/gtksizegroup.c  2001/10/29 23:17:04
> @@ -20,6 +20,7 @@
> 
>  #include "gtkcontainer.h"
>  #include "gtkintl.h"
> +#include "gtkprivate.h"
>  #include "gtksignal.h"
>  #include "gtksizegroup.h"
> 
> @@ -116,8 +117,8 @@ add_widget_to_closure (GtkWidget       *
>  static void
>  real_queue_resize (GtkWidget *widget)
>  {
> -  if (GTK_IS_RESIZE_CONTAINER (widget))
> -    _gtk_container_clear_resize_widgets (GTK_CONTAINER (widget));
> +  GTK_PRIVATE_SET_FLAG (widget, GTK_ALLOC_NEEDED);
> +  GTK_PRIVATE_SET_FLAG (widget, GTK_REQUEST_NEEDED);
> 
>    if (widget->parent)
>      _gtk_container_queue_resize (GTK_CONTAINER (widget->parent));

hm, doesn't gtk_widget_queue_resize(widget) have the same effect as
GTK_PRIVATE_SET_FLAG (widget, GTK_ALLOC_NEEDED);
GTK_PRIVATE_SET_FLAG (widget, GTK_REQUEST_NEEDED);
_gtk_container_queue_resize (widget->Parent);
?

> @@ -1469,64 +1470,6 @@ gtk_widget_unparent (GtkWidget *widget)
[...]

unset GTK_ALLOC_NEEDED and GTK_REQUEST_NEEDED here, those flags
are bogus for unparented widgets (except prolly windows).

> 
> Regards,
>                                         Owen
> 

---
ciaoTJ




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